public JsonNode _set(int index, JsonNode value) { if (_children == null || index < 0 || index >= _children.size()) { throw new IndexOutOfBoundsException("Illegal index "+index+", array size "+size()); } return _children.set(index, value); }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { // final class, can do this return false; } ArrayNode other = (ArrayNode) o; if (_children == null || _children.size() == 0) { return other.size() == 0; } return other._sameChildren(_children); }
@Override public String toString() { StringBuilder sb = new StringBuilder(16 + (size() << 4)); sb.append('['); if (_children != null) { for (int i = 0, len = _children.size(); i < len; ++i) { if (i > 0) { sb.append(','); } sb.append(_children.get(i).toString()); } } sb.append(']'); return sb.toString(); }
/** * Note: this method gets called iff <code>otherChildren</code> * is non-empty */ private boolean _sameChildren(ArrayList<JsonNode> otherChildren) { int len = otherChildren.size(); if (this.size() != len) { // important: call size() to handle case of null list... return false; } for (int i = 0; i < len; ++i) { if (!_children.get(i).equals(otherChildren.get(i))) { return false; } } return true; } }
/** * Method for adding all child nodes of given Array, appending to * child nodes this array contains * * @param other Array to add contents from * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode addAll(ArrayNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new ArrayList<JsonNode>(len+2); } other.addContentsTo(_children); } return this; }
final int numElements = arrayNode.size(); final Object[] arrayElements = new Object[numElements]; int count = 0;
final int numElements = arrayNode.size(); final Object[] arrayElements = new Object[numElements]; int count = 0;
final int numElements = arrayNode.size(); final Object[] arrayElements = new Object[numElements]; int count = 0;
final int numElements = arrayNode.size(); final Object[] arrayElements = new Object[numElements]; int count = 0;
for (int i=0; i < arrayNode.size(); i++) { final JsonNode jsonNode = arrayNode.get(i); attributes.put(attributePrefix + ".table", tableName); attributes.put(FRAGMENT_ID.key(), fragmentIdentifier); attributes.put(FRAGMENT_COUNT.key(), String.valueOf(arrayNode.size())); attributes.put(FRAGMENT_INDEX.key(), String.valueOf(i)); FlowFile newFlowFile = copyAttributesToOriginal(session, flowFile, fragmentIdentifier, arrayNode.size()); session.transfer(newFlowFile, REL_ORIGINAL);
public JsonNode _set(int index, JsonNode value) { if (_children == null || index < 0 || index >= _children.size()) { throw new IndexOutOfBoundsException("Illegal index "+index+", array size "+size()); } return _children.set(index, value); }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { // final class, can do this return false; } ArrayNode other = (ArrayNode) o; if (_children == null || _children.size() == 0) { return other.size() == 0; } return other._sameChildren(_children); }
@Override public String toString() { StringBuilder sb = new StringBuilder(16 + (size() << 4)); sb.append('['); if (_children != null) { for (int i = 0, len = _children.size(); i < len; ++i) { if (i > 0) { sb.append(','); } sb.append(_children.get(i).toString()); } } sb.append(']'); return sb.toString(); }
/** * Note: this method gets called iff <code>otherChildren</code> * is non-empty */ private boolean _sameChildren(ArrayList<JsonNode> otherChildren) { int len = otherChildren.size(); if (this.size() != len) { // important: call size() to handle case of null list... return false; } for (int i = 0; i < len; ++i) { if (!_children.get(i).equals(otherChildren.get(i))) { return false; } } return true; } }
/** * Method for adding all child nodes of given Array, appending to * child nodes this array contains * * @param other Array to add contents from * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode addAll(ArrayNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new ArrayList<JsonNode>(len+2); } other.addContentsTo(_children); } return this; }
public JsonNode _set(int index, JsonNode value) { if (_children == null || index < 0 || index >= _children.size()) { throw new IndexOutOfBoundsException("Illegal index "+index+", array size "+size()); } return _children.set(index, value); }
public JsonNode _set(int index, JsonNode value) { if (_children == null || index < 0 || index >= _children.size()) { throw new IndexOutOfBoundsException("Illegal index "+index+", array size "+size()); } return _children.set(index, value); }
@Override protected CharBuffer deserialize(final ArrayNode input) throws JsonProcessingException { final CharBuffer result = CharBuffer.allocate(input.size()); for (final JsonNode node : input) result.put(node.asText()); return result; } }
private Object handleArray(JsonParser jp, ArrayNode arrayNode) throws IOException { Object[] arrayInstance = (Object[]) Array.newInstance(rawClass.getComponentType(), arrayNode.size()); for (int i = 0; i < arrayInstance.length; i++) { Object value = handleObject(jp, arrayNode.get(i)); arrayInstance[i] = value; } return arrayInstance; } }
@Override protected DoubleBuffer deserialize(final ArrayNode input) throws JsonProcessingException { final DoubleBuffer result = DoubleBuffer.allocate(input.size()); for(final JsonNode node: input) result.put(node.asDouble()); return result; } }