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


Java ClientValue.asComplex方法代码示例

本文整理汇总了Java中org.apache.olingo.client.api.domain.ClientValue.asComplex方法的典型用法代码示例。如果您正苦于以下问题:Java ClientValue.asComplex方法的具体用法?Java ClientValue.asComplex怎么用?Java ClientValue.asComplex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.client.api.domain.ClientValue的用法示例。


在下文中一共展示了ClientValue.asComplex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prettyPrint

import org.apache.olingo.client.api.domain.ClientValue; //导入方法依赖的package包/类
private static String prettyPrint(Collection<ClientProperty> properties, int level) {
  StringBuilder b = new StringBuilder();

  for (ClientProperty entry : properties) {
    intend(b, level);
    ClientValue value = entry.getValue();
    if (value.isCollection()) {
      ClientCollectionValue cclvalue = value.asCollection();
      b.append(prettyPrint(cclvalue.asJavaCollection(), level + 1));
    } else if (value.isComplex()) {
      ClientComplexValue cpxvalue = value.asComplex();
      b.append(prettyPrint(cpxvalue.asJavaMap(), level + 1));
    } else if (value.isEnum()) {
      ClientEnumValue cnmvalue = value.asEnum();
      b.append(entry.getName()).append(": ");
      b.append(cnmvalue.getValue()).append("\n");
    } else if (value.isPrimitive()) {
      b.append(entry.getName()).append(": ");
      b.append(entry.getValue()).append("\n");
    }
  }
  return b.toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:OlingoSampleApp.java

示例2: readChassisCollection

import org.apache.olingo.client.api.domain.ClientValue; //导入方法依赖的package包/类
/**
 * get a set of Paths used to identify unique chassis. Each Path can be used in a URL to identify
 * a chassis.
 *
 * @param ctx the communication context to single Redfish server.
 * @return A set of Paths. No element in the set is null.
 * @throws RedHxChassisParseException
 * @throws RedHxHttpResponseException
 */
public static Set<RedHxUriPath> readChassisCollection(RedHxServerConnectionContext ctx)
    throws RedHxChassisParseException, RedHxHttpResponseException {
  final ODataRetrieveResponse<ClientEntity> response = ctx.getChassisEntityRequest().execute();
  final Set<RedHxUriPath> chassisPathSet = new HashSet<>();

  if (response.getStatusCode() == HttpURLConnection.HTTP_OK) {
    ClientEntity entity = response.getBody();

    /**
     * get the JSON entity
     */
    ClientProperty chassisProperty = entity.getProperty(JSON_CHASSIS_COLLECTION_KEYWORD);

    for (ClientValue chassisValue : chassisProperty.getCollectionValue()) {
      ClientComplexValue cplx = chassisValue.asComplex();

      if (cplx != null) {
        ClientAnnotation anno = cplx.getAnnotations().get(0);

        if (anno.getTerm().equals(ODATA_SINGLE_CHASSIS_KEYWORD)) {
          String chassisPath = anno.getValue().toString();

          if (chassisPath == null) {
            throw new RedHxChassisParseException(
                "The JSON annotation pointing to a specific chassis was null.");
          }

          RedHxUriPath path = new RedHxUriPathImpl(chassisPath);

          chassisPathSet.add(path);
        } else {
          throw new RedHxChassisParseException(
              "Unable to find keyword " + ODATA_SINGLE_CHASSIS_KEYWORD);
        }
      } else {
        throw new RedHxChassisParseException("The JSON message did not contains a class "
            + ClientComplexValue.class.getSimpleName());
      }
    }
  } else {
    throw new RedHxHttpResponseException(RedHxServiceRootIdEum.CHASSIS, response.getStatusCode(),
        "Can not read Chassis Collection.");
  }

  return chassisPathSet;
}
 
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:56,代码来源:RedHxChassisPathCollectionReader.java


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