• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AutoBeanCodex类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.web.bindery.autobean.shared.AutoBeanCodex的典型用法代码示例。如果您正苦于以下问题:Java AutoBeanCodex类的具体用法?Java AutoBeanCodex怎么用?Java AutoBeanCodex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AutoBeanCodex类属于com.google.web.bindery.autobean.shared包,在下文中一共展示了AutoBeanCodex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decodeTestJson

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private ApiDirectory decodeTestJson() {
  InputStream stream = getClass().getResourceAsStream("directory-small.json");
  if (stream == null) {
    fail("directory-small.json missing");
  }
  try {
    Reader reader = new InputStreamReader(stream, Charsets.UTF_8);
    String jsonString = CharStreams.toString(reader);
    stream.close();

    Factory factory = AutoBeanFactorySource.create(Factory.class);
    return AutoBeanCodex.decode(factory, ApiDirectory.class, jsonString).as();
  } catch (IOException e) {
    fail("IOException: " + e.getMessage());
  }
  return null;
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:18,代码来源:ApiDirectoryTest.java


示例2: decodeTestJson

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
/**
 * Reads discovery-small.json and parses it into a {@link RestApiService}
 * that can be tested.
 */
protected RpcApiService decodeTestJson() {
  InputStream stream = getClass().getResourceAsStream("discovery-small.json");
  if (stream == null) {
    fail("discovery-small.json missing");
  }
  try {
    Reader reader = new InputStreamReader(stream, Charsets.UTF_8);
    String jsonString = CharStreams.toString(reader);
    stream.close();

    Factory factory = AutoBeanFactorySource.create(Factory.class);
    RpcApiService service =
        AutoBeanCodex.decode(factory, RpcApiService.class, jsonString).as();
    return service;
  } catch (IOException e) {
    fail("IOException: " + e.getMessage());
  }
  return null;
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:24,代码来源:RpcApiServiceTest.java


示例3: decodeTestJson

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
/**
 * Reads discovery-small.json and parses it into a {@link RestApiService}
 * that can be tested.
 */
protected RestApiService decodeTestJson() {
  InputStream stream = getClass().getResourceAsStream("discovery-small.json");
  if (stream == null) {
    fail("discovery-small.json missing");
  }
  try {
    Reader reader = new InputStreamReader(stream, Charsets.UTF_8);
    String jsonString = CharStreams.toString(reader);
    stream.close();

    Factory factory = AutoBeanFactorySource.create(Factory.class);
    RestApiService service =
        AutoBeanCodex.decode(factory, RestApiService.class, jsonString).as();
    return service;
  } catch (IOException e) {
    fail("IOException: " + e.getMessage());
  }
  return null;
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:24,代码来源:RestApiServiceTest.java


示例4: makePayload

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
@Override
public String makePayload() {
  final RequestData data =
      AbstractRequestContext.this.state.invocations.get(0).getRequestData();

  final AutoBean<JsonRpcRequest> bean = MessageFactoryHolder.FACTORY.jsonRpcRequest();
  final JsonRpcRequest request = bean.as();

  request.setVersion("2.0");
  request.setApiVersion(data.getApiVersion());
  request.setId(payloadId++);

  final Map<String, Splittable> params = new HashMap<>();
  for (final Map.Entry<String, Object> entry : data.getNamedParameters().entrySet()) {
    final Object obj = entry.getValue();
    final Splittable value = this.encode(obj);
    params.put(entry.getKey(), value);
  }
  if (data.getRequestResource() != null) {
    params.put("resource", this.encode(data.getRequestResource()));
  }
  request.setParams(params);
  request.setMethod(data.getOperation());

  return AutoBeanCodex.encode(bean).getPayload();
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:27,代码来源:AbstractRequestContext.java


示例5: nonCollectionEncode

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Splittable nonCollectionEncode(final Object obj) {
  if (obj instanceof Collection) {
    // TODO: Allow for the encoding of nested collections. See issue 5974.
    // Once we do this, this can turn into an assert.
    throw new RuntimeException(
        "Unable to encode request as JSON payload; Request methods must have parameters of "
            + "the form List<T> or Set<T>, where T is a scalar (non-collection) type.");
  }
  Splittable value;
  if (obj instanceof Enum
      && AbstractRequestContext.this.getAutoBeanFactory() instanceof EnumMap) {
    value = ValueCodex.encode(
        ((EnumMap) AbstractRequestContext.this.getAutoBeanFactory()).getToken((Enum<?>) obj));
  } else if (ValueCodex.canDecode(obj.getClass())) {
    value = ValueCodex.encode(obj);
  } else {
    // XXX user-provided implementation of interface?
    value = AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(obj));
  }
  return value;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:22,代码来源:AbstractRequestContext.java


示例6: getSerializedProxyId

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
/**
 * EntityCodex support.
 */
@Override
public Splittable getSerializedProxyId(final SimpleProxyId<?> stableId) {
  final AutoBean<IdMessage> bean = MessageFactoryHolder.FACTORY.id();
  final IdMessage ref = bean.as();
  ref.setServerId(stableId.getServerId());
  ref.setTypeToken(this.getRequestFactory().getTypeToken(stableId.getProxyClass()));
  if (stableId.isSynthetic()) {
    ref.setStrength(Strength.SYNTHETIC);
    ref.setSyntheticId(stableId.getSyntheticId());
  } else if (stableId.isEphemeral()) {
    ref.setStrength(Strength.EPHEMERAL);
    ref.setClientId(stableId.getClientId());
  }
  return AutoBeanCodex.encode(bean);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:19,代码来源:AbstractRequestContext.java


示例7: toJsonString

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
public String toJsonString(AutoBean<?> obj) {
	String result = "";
	if (obj != null) {
		result = AutoBeanCodex.encode(obj).getPayload();
	}
	return result;
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:8,代码来源:AutoBeanService.java


示例8: fromJsonString

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
public <T> AutoBean<T> fromJsonString(Class<T> clazz, String json) {
	AutoBean<T> bean = null;
	if (json != null && !json.equals("")) {
    bean = AutoBeanCodex.decode(factory, clazz, json);
	}
  return bean;
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:8,代码来源:AutoBeanService.java


示例9: createSystemDetails

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private SystemDetails createSystemDetails(final ModelNode systemDetailsNode) {
    try {
        return AutoBeanCodex.decode(_factory, SystemDetails.class, systemDetailsNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例10: createApplication

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Application createApplication(final ModelNode applicationNode) {
    try {
        return AutoBeanCodex.decode(_factory, Application.class, applicationNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例11: createComponent

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Component createComponent(final ModelNode componentNode) {
    try {
        return AutoBeanCodex.decode(_factory, Component.class, componentNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例12: createExtension

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Component createExtension(final ModelNode extensionNode) {
    try {
        return AutoBeanCodex.decode(_factory, Component.class, extensionNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例13: createServiceStub

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Service createServiceStub(final ModelNode serviceNode) {
    try {
        return AutoBeanCodex.decode(_factory, Service.class, serviceNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例14: createService

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Service createService(final ModelNode serviceNode) {
    try {
        return AutoBeanCodex.decode(_factory, Service.class, serviceNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例15: createServiceMetrics

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private List<ServiceMetrics> createServiceMetrics(final ModelNode metricsNode) {
    final List<ModelNode> items = metricsNode.asList();
    final List<ServiceMetrics> metrics = new ArrayList<ServiceMetrics>(items.size());
    for (ModelNode item : items) {
        try {
            metrics.add(AutoBeanCodex.decode(_factory, ServiceMetrics.class, item.toJSONString(true)).as());
        } catch (Exception e) {
            Log.error(PARSE_ERROR_MESSAGE, e);
        }
    }
    return metrics;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:13,代码来源:SwitchYardStoreImpl.java


示例16: createMessageMetrics

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private MessageMetrics createMessageMetrics(final ModelNode metricsNode) {
    try {
        return AutoBeanCodex.decode(_factory, MessageMetrics.class, metricsNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例17: createReferenceStub

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Reference createReferenceStub(final ModelNode referenceNode) {
    try {
        return AutoBeanCodex.decode(_factory, Reference.class, referenceNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例18: createReference

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
private Reference createReference(final ModelNode referenceNode) {
    try {
        return AutoBeanCodex.decode(_factory, Reference.class, referenceNode.toJSONString(true)).as();
    } catch (Exception e) {
        Log.error(PARSE_ERROR_MESSAGE, e);
        return null;
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:9,代码来源:SwitchYardStoreImpl.java


示例19: getBeanForPayload

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
/**
 * EntityCodex support.
 */
@Override
public <Q extends BaseProxy> AutoBean<Q> getBeanForPayload(final Splittable serializedProxyId) {
  final IdMessage ref =
      AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, IdMessage.class, serializedProxyId).as();
  @SuppressWarnings("unchecked")
  final SimpleProxyId<Q> id = (SimpleProxyId<Q>) this.getId(ref);
  return this.getProxyForReturnPayloadGraph(id);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:12,代码来源:AbstractRequestContext.java


示例20: generateListItems

import com.google.web.bindery.autobean.shared.AutoBeanCodex; //导入依赖的package包/类
public List<ListItem> generateListItems(List<DataValuePairContainer> data) {
	List<ListItem> listItems = new ArrayList<ListItem>();
	
	inputObject = DataBindingService.getInstance().getData(dataSource, data);
	if (inputObject != null) {
		dataMap = AutoBeanCodex.encode(inputObject);
		
		// Populate list using binding data
		if (dataMap != null && itemBindingObject != null && !itemBindingObject.equals("")) {
			dataBindingActive = true;
			// Create List Items
			try {
				Splittable listArrMap = dataMap.get(itemBindingObject);
				if (listArrMap != null) {
					String templateStr = AutoBeanService.getInstance().toJsonString(ListItemLayout.class, itemTemplate);		
					for (int i=0; i< listArrMap.size(); i++) {
						String instanceStr = templateStr;
						Splittable fieldMap = listArrMap.get(i);
						if (fieldMap != null) {
							RegExp regex = RegExp.compile(BINDING_FIELD_REGEX, "g");
							for (MatchResult result = regex.exec(templateStr); result != null; result = regex.exec(templateStr)) {
								instanceStr = instanceStr.replace(result.getGroup(0), fieldMap.get(result.getGroup(1)).asString());
							}
							AutoBean<ListItemLayout> instanceBean = AutoBeanService.getInstance().fromJsonString(ListItemLayout.class, instanceStr);
							ListItemLayout layout = instanceBean.as();
							ListItem item = ListItem.build(layout);
							item.setParentList(this);
							item.setWidth(getWidth());
							listItems.add(item);
						}
					}
				}
			} catch (Exception e) {
				// TODO: Problem binding to data source do something
				//Window.alert("Failed to bind data source!");
			}
		}
	}
	
	return listItems;
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:42,代码来源:ListPanelComponent.java



注:本文中的com.google.web.bindery.autobean.shared.AutoBeanCodex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MapTaskKeys类代码示例发布时间:2022-05-22
下一篇:
Java Number160类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap