本文整理汇总了Java中com.fasterxml.jackson.databind.node.ContainerNode类的典型用法代码示例。如果您正苦于以下问题:Java ContainerNode类的具体用法?Java ContainerNode怎么用?Java ContainerNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了ContainerNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSourceDocuments
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
@Override
public List<JsonNode> getSourceDocuments() {
LOGGER.debug("Retrieving source docs");
try {
DataFindRequest sourceRequest = new DataFindRequest(getMigrationConfiguration().getSourceEntityName(),
getMigrationConfiguration().getSourceEntityVersion());
sourceRequest.where(Query.query((ContainerNode) JSON.toJsonNode(getMigrationJob().getQuery())));
sourceRequest.select(Projection.includeFieldRecursively("*"), Projection.excludeField("objectType"));
LOGGER.debug("Source docs retrieval req: {}", sourceRequest.getBody());
JsonNode[] results = getSourceCli().data(sourceRequest, JsonNode[].class);
LOGGER.debug("There are {} source docs", results.length);
return Arrays.asList(results);
} catch (Exception e) {
LOGGER.error("Error while retrieving source documents:{}", e);
throw new RuntimeException("Cannot retrieve source documents:" + e);
}
}
开发者ID:lightblue-platform,项目名称:lightblue-migrator,代码行数:18,代码来源:DefaultMigrator.java
示例2: appendToJsonNode
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
@Override
protected void appendToJsonNode(Object value, ContainerNode<?> targetNode, FieldCursor cursor) {
FieldTreeNode field = cursor.getCurrentNode();
if(PredefinedFields.isFieldAnArrayCount(field.getName(), currentFields)){
/*
* This case will be handled by the array itself, allowing this to
* process runs the risk of nulling out the correct value.
*/
return;
}
Path fieldPath = cursor.getCurrentPath();
if (targetNode instanceof ObjectNode) {
currentTargetObjectNode = (ObjectNode) targetNode;
}
if(PredefinedFields.isFieldObjectType(fieldPath.toString())){
((ObjectNode) targetNode).set(fieldPath.toString(), toJson(StringType.TYPE, entityMetadata.getEntityInfo().getName()));
}
else{
super.appendToJsonNode(value, targetNode, cursor);
}
}
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:26,代码来源:NonPersistedPredefinedFieldTranslatorToJson.java
示例3: findParent
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* This method here expands our horizons in writing code that sucks.
* JsonNodes have no parent pointer, so finding a parent involves iterating
* all nodes with the hope of finding the node, and returning the container
* that contains it.
*
* The whole JsonNode thing should be reengineered at some point.
*/
public static JsonNode findParent(final JsonNode root, final JsonNode node) {
if (root instanceof ContainerNode) {
for (Iterator<JsonNode> itr = root.elements(); itr.hasNext();) {
JsonNode child = itr.next();
if (child == node) {
return root;
} else {
JsonNode found = findParent(child, node);
if (found != null) {
return found;
}
}
}
}
return null;
}
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:25,代码来源:JsonDoc.java
示例4: withDataRequest
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
private TestRackInterface withDataRequest(String resource, ContainerNode<ObjectNode> body, MockHttpServletRequestBuilder requestBuilder) throws Exception {
MvcResult result = getMockMvc().perform(requestBuilder
.content(body.toString())
.contentType(contentType))
.andReturn();
return toSimpleResponse(result);
}
开发者ID:shairontoledo,项目名称:cloudstatus,代码行数:9,代码来源:TestHttpRequest.java
示例5: stripEmptyContainerNodes
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
public static void stripEmptyContainerNodes(ObjectNode objectNode) {
Iterator<Entry<String, JsonNode>> i = objectNode.fields();
while (i.hasNext()) {
Entry<String, JsonNode> entry = i.next();
JsonNode value = entry.getValue();
if (value instanceof ContainerNode && ((ContainerNode<?>) value).size() == 0) {
// remove empty nodes, e.g. unused "smtp" and "alerts" nodes
i.remove();
}
}
}
开发者ID:glowroot,项目名称:glowroot,代码行数:12,代码来源:ObjectMappers.java
示例6: appendToJsonNode
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
@Override
protected void appendToJsonNode(Object value, ContainerNode<?> targetNode, FieldCursor cursor) {
Path fieldPath = cursor.getCurrentPath();
if(dnPath.equals(fieldPath)){
//DN is not technically an attribute and can be skipped.
return;
}
super.appendToJsonNode(value, targetNode, cursor);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:12,代码来源:ResultTranslatorToJson.java
示例7: appendToJsonNode
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
protected void appendToJsonNode(Object value, ContainerNode<?> targetNode, FieldCursor cursor) {
FieldTreeNode field = cursor.getCurrentNode();
Error.push(field.getName());
try{
JsonNode newJsonNode = null;
Object newValue = null;
if (field instanceof ObjectField || field instanceof ObjectArrayElement) {
newJsonNode = translateToObjectNode(value, cursor);
}
else if((newValue = getValueFor(value, cursor.getCurrentPath())) != null){
if (field instanceof SimpleField) {
newJsonNode = translate((SimpleField)field, newValue);
}
else if (field instanceof ArrayField){
newJsonNode = translateToArrayNode((ArrayField) field, newValue, cursor);
}
else{
throw new UnsupportedOperationException("Unknown Field type: " + field.getClass().getName());
}
}
if (targetNode instanceof ObjectNode) {
((ObjectNode) targetNode).set(cursor.getCurrentNode().getName(), newJsonNode);
}
else {
((ArrayNode) targetNode).add(newJsonNode);
}
}
finally{
Error.pop();
}
}
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:35,代码来源:TranslatorToJson.java
示例8: createIntermediate
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private static JsonNode createIntermediate(JsonNode node, StringBuffer pathSofar, String index,
String nextIndex) {
if (node instanceof ContainerNode) {
ContainerNode temp = (ContainerNode) node;
JsonNode value = PATTERN_INDEX.matcher(nextIndex).matches() ? temp.arrayNode()
: temp.objectNode();
return createIntermediate(temp, pathSofar, index, value);
}
return null;
}
开发者ID:DDTH,项目名称:ddth-commons,代码行数:13,代码来源:DPathUtils.java
示例9: POST
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
public TestRackInterface POST(String resource, ContainerNode<ObjectNode> body) throws Exception {
return withDataRequest(resource, body, post(resource));
}
开发者ID:shairontoledo,项目名称:cloudstatus,代码行数:4,代码来源:TestHttpRequest.java
示例10: PUT
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
public TestRackInterface PUT(String resource, ContainerNode<ObjectNode> body) throws Exception {
return withDataRequest(resource, body, put(resource));
}
开发者ID:shairontoledo,项目名称:cloudstatus,代码行数:4,代码来源:TestHttpRequest.java
示例11: Projection
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Constructs a projection node from an array or object node
*/
public Projection(ContainerNode node) {
super(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:7,代码来源:Projection.java
示例12: project
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Returns a projection based on an array or object node
*/
public static Projection project(ContainerNode node) {
return new Projection(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:7,代码来源:Projection.java
示例13: Update
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Creates an update node with the given array or object node
*/
public Update(ContainerNode node) {
super(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:7,代码来源:Update.java
示例14: update
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
public static Update update(ContainerNode node) {
return new Update(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:4,代码来源:Update.java
示例15: Query
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Constructs a query object from a json array or object
*/
public Query(ContainerNode node) {
super(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:7,代码来源:Query.java
示例16: Sort
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Creates a sort node using the array or object node
*/
public Sort(ContainerNode node) {
super(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:7,代码来源:Sort.java
示例17: sort
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
public static Sort sort(ContainerNode node) {
return new Sort(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:4,代码来源:Sort.java
示例18: Expression
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Construct expression with the given object or array node
*/
protected Expression(ContainerNode node) {
super(node);
}
开发者ID:lightblue-platform,项目名称:lightblue-client,代码行数:7,代码来源:Expression.java
示例19: handleSingle
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Performs single JSON-RPC request and return JSON-RPC response
*
* @param request JSON-RPC request as a Java object
* @param service service object
* @return JSON-RPC response as a Java object
* @throws Exception in case of a runtime error (reflections, business logic...)
*/
@NotNull
private Response handleSingle(@NotNull Request request, @NotNull Object service) throws Exception {
// Check mandatory fields and correct protocol version
String requestMethod = request.getMethod();
String jsonrpc = request.getJsonrpc();
ValueNode id = request.getId();
if (jsonrpc == null || requestMethod == null) {
log.error("Not a JSON-RPC request: " + request);
return new ErrorResponse(id, INVALID_REQUEST);
}
if (!jsonrpc.equals(VERSION)) {
log.error("Not a JSON_RPC 2.0 request: " + request);
return new ErrorResponse(id, INVALID_REQUEST);
}
JsonNode params = request.getParams();
if (!params.isObject() && !params.isArray() && !params.isNull()) {
log.error("Params of request: '" + request + "' should be an object, an array or null");
return new ErrorResponse(id, INVALID_REQUEST);
}
ClassMetadata classMetadata = classesMetadata.get(service.getClass());
if (!classMetadata.isService()) {
log.warn(service.getClass() + " is not available as a JSON-RPC 2.0 service");
return new ErrorResponse(id, METHOD_NOT_FOUND);
}
MethodMetadata method = classMetadata.getMethods().get(requestMethod);
if (method == null) {
log.error("Unable find a method: '" + requestMethod + "' in a " + service.getClass());
return new ErrorResponse(id, METHOD_NOT_FOUND);
}
ContainerNode<?> notNullParams = !params.isNull() ?
(ContainerNode<?>) params : mapper.createObjectNode();
Object[] methodParams;
try {
methodParams = convertToMethodParams(notNullParams, method);
} catch (IllegalArgumentException e) {
log.error("Bad params: " + notNullParams + " of a method '" + method.getName() + "'", e);
return new ErrorResponse(id, INVALID_PARAMS);
}
Object result = method.getMethod().invoke(service, methodParams);
return new SuccessResponse(id, result);
}
开发者ID:arteam,项目名称:simple-json-rpc,代码行数:56,代码来源:JsonRpcServer.java
示例20: convertToMethodParams
import com.fasterxml.jackson.databind.node.ContainerNode; //导入依赖的package包/类
/**
* Converts JSON params to java params in the appropriate order of the invoked method
*
* @param params json params (map or array)
* @param method invoked method metadata
* @return array of java objects for passing to the method
*/
@NotNull
private Object[] convertToMethodParams(@NotNull ContainerNode<?> params,
@NotNull MethodMetadata method) {
int methodParamsSize = method.getParams().size();
int jsonParamsSize = params.size();
// Check amount arguments
if (jsonParamsSize > methodParamsSize) {
throw new IllegalArgumentException("Wrong amount arguments: " + jsonParamsSize +
" for a method '" + method.getName() + "'. Actual amount: " + methodParamsSize);
}
Object[] methodParams = new Object[methodParamsSize];
int processed = 0;
for (ParameterMetadata param : method.getParams().values()) {
Class<?> parameterType = param.getType();
int index = param.getIndex();
String name = param.getName();
JsonNode jsonNode = params.isObject() ? params.get(name) : params.get(index);
// Handle omitted value
if (jsonNode == null || jsonNode.isNull()) {
if (param.isOptional()) {
methodParams[index] = getDefaultValue(parameterType);
if (jsonNode != null) {
processed++;
}
continue;
} else {
throw new IllegalArgumentException("Mandatory parameter '" + name +
"' of a method '" + method.getName() + "' is not set");
}
}
// Convert JSON object to an actual Java object
try {
JsonParser jsonParser = mapper.treeAsTokens(jsonNode);
JavaType javaType = mapper.getTypeFactory().constructType(param.getGenericType());
methodParams[index] = mapper.readValue(jsonParser, javaType);
processed++;
} catch (IOException e) {
throw new IllegalArgumentException("Wrong param: " + jsonNode + ". Expected type: '" + param, e);
}
}
// Check that some unprocessed parameters were not passed
if (processed < jsonParamsSize) {
throw new IllegalArgumentException("Some unspecified parameters in " + params +
" are passed to a method '" + method.getName() + "'");
}
return methodParams;
}
开发者ID:arteam,项目名称:simple-json-rpc,代码行数:59,代码来源:JsonRpcServer.java
注:本文中的com.fasterxml.jackson.databind.node.ContainerNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论