当前位置: 首页>>代码示例>>Java>>正文


Java AutoBeanCodex类代码示例

本文整理汇总了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;
}
 
开发者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


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