本文整理汇总了Java中com.google.web.bindery.autobean.shared.AutoBeanCodex类的典型用法代码示例。如果您正苦于以下问题:Java AutoBeanCodex类的具体用法?Java AutoBeanCodex怎么用?Java AutoBeanCodex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoBeanCodex类属于com.google.web.bindery.autobean.shared包,在下文中一共展示了AutoBeanCodex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}