@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { ContainerNode<?> container = asJson(target); Integer index = maybeIndex(name); if (index != null && container.has(index)) { return typedValue(container.get(index)); } else { return typedValue(container.get(name)); } }
@Override public Object[] getParams(Type[] types) { if (params == null) { return new Object[0]; } try { Object[] args = new Object[types.length]; for (int i = 0; i < args.length; i++) { JsonNode param = params.get(i); if (param.isNull()) { args[i] = null; } else { args[i] = objectMapper.convertValue(param, objectMapper.constructType(types[i])); } } return args; } catch (Exception e) { LOG.debug("params error!", e); return null; } }
if (FieldType.STRING.equals(type)) { if (value != null) { valueNode = rootNode.textNode(String.valueOf(value)); } else { valueNode = rootNode.nullNode(); valueNode = rootNode.textNode(Character.toString((char) value)); } else if (FieldType.BOOLEAN.equals(type)) { valueNode = rootNode.booleanNode((Boolean) value); } else if (FieldType.INTEGER.equals(type)) { valueNode = rootNode.numberNode((Integer) value); } else if (FieldType.DOUBLE.equals(type) || FieldType.FLOAT.equals(type) || FieldType.NUMBER.equals(type)) { valueNode = rootNode.numberNode(new BigDecimal(String.valueOf(value))); } else if (FieldType.SHORT.equals(type)) { valueNode = rootNode.numberNode(Short.valueOf(String.valueOf(value))); } else if (FieldType.LONG.equals(type)) { valueNode = rootNode.numberNode(Long.valueOf(String.valueOf(value))); } else if (FieldType.BYTE.equals(type)) { valueNode = rootNode.numberNode(Byte.valueOf(String.valueOf(value))); } else { valueNode = rootNode.nullNode();
@Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { ContainerNode<?> container = asJson(target); Integer index = maybeIndex(name); if (container instanceof ArrayNode) { return index != null; } else { return ((index != null && container.has(index)) || container.has(name)); } }
@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; }
@Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { ContainerNode<?> container = asJson(target); Integer index = maybeIndex(name); if (index != null && container.has(index)) { return typedValue(container.get(index)); } else { return typedValue(container.get(name)); } }
@Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { ContainerNode<?> container = asJson(target); Integer index = maybeIndex(name); if (container instanceof ArrayNode) { return index != null; } else { return ((index != null && container.has(index)) || container.has(name)); } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
public static void stripEmptyContainerNodes(ObjectNode objectNode) { Iterator<Map.Entry<String, JsonNode>> i = objectNode.fields(); while (i.hasNext()) { Map.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(); } } }
@Override public int getParamCount() { if (params == null) { return 0; } return params.size(); }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }
@Override public boolean currentHasChildren() { // note: ONLY to be called for container nodes return ((ContainerNode<?>) currentNode()).size() > 0; } }