本文整理汇总了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();
}
示例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;
}