public abstract class ContainerNode<T extends ContainerNode<T>> extends BaseJsonNode
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ContainerNode.NoNodesIterator |
protected static class |
ContainerNode.NoStringsIterator |
| Modifier and Type | Field and Description |
|---|---|
protected JsonNodeFactory |
_nodeFactory
We will keep a reference to the Object (usually TreeMapper)
that can construct instances of nodes to add to this container
node.
|
NO_NODES, NO_STRINGS| Modifier | Constructor and Description |
|---|---|
protected |
ContainerNode(JsonNodeFactory nc) |
| Modifier and Type | Method and Description |
|---|---|
ArrayNode |
arrayNode()
Factory method that constructs and returns an empty
ArrayNode
Construction is done using registered JsonNodeFactory. |
String |
asText()
Method that will return a valid String representation of
the container value, if the node is a value node
(method
JsonNode.isValueNode() returns true),
otherwise empty String. |
abstract JsonToken |
asToken()
Method that can be used for efficient type detection
when using stream abstraction for traversing nodes.
|
BinaryNode |
binaryNode(byte[] data) |
BinaryNode |
binaryNode(byte[] data,
int offset,
int length) |
BooleanNode |
booleanNode(boolean v) |
abstract ObjectNode |
findParent(String fieldName)
Method for finding a JSON Object that contains specified field,
within this node or its descendants.
|
abstract List<JsonNode> |
findParents(String fieldName,
List<JsonNode> foundSoFar) |
abstract JsonNode |
findValue(String fieldName)
Method for finding a JSON Object field with specified name in this
node or its child nodes, and returning value it has.
|
abstract List<JsonNode> |
findValues(String fieldName,
List<JsonNode> foundSoFar) |
abstract List<String> |
findValuesAsText(String fieldName,
List<String> foundSoFar) |
abstract JsonNode |
get(int index)
Method for accessing value of the specified element of
an array node.
|
abstract JsonNode |
get(String fieldName)
Method for accessing value of the specified field of
an object node.
|
boolean |
isContainerNode()
Method that returns true for container nodes: Arrays and Objects.
|
NullNode |
nullNode() |
NumericNode |
numberNode(BigDecimal v) |
NumericNode |
numberNode(byte v) |
NumericNode |
numberNode(double v) |
NumericNode |
numberNode(float v) |
NumericNode |
numberNode(int v) |
NumericNode |
numberNode(long v) |
NumericNode |
numberNode(short v) |
ObjectNode |
objectNode()
Factory method that constructs and returns an empty
ObjectNode
Construction is done using registered JsonNodeFactory. |
POJONode |
POJONode(Object pojo) |
abstract T |
removeAll()
Method for removing all children container has (if any)
|
abstract int |
size()
Method that returns number of child nodes this node contains:
for Array nodes, number of child elements, for Object nodes,
number of fields, and for all other nodes 0.
|
TextNode |
textNode(String text) |
findPath, numberType, serialize, serializeWithType, traverseasBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, bigIntegerValue, binaryValue, booleanValue, canConvertToInt, canConvertToLong, decimalValue, deepCopy, doubleValue, elements, equals, fieldNames, fields, findParents, findValues, findValuesAsText, has, has, hasNonNull, hasNonNull, intValue, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isDouble, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isTextual, isValueNode, iterator, longValue, numberValue, path, path, textValue, toString, with, withArrayprotected final JsonNodeFactory _nodeFactory
protected ContainerNode(JsonNodeFactory nc)
public boolean isContainerNode()
JsonNode
Note: one and only one of methods JsonNode.isValueNode(),
JsonNode.isContainerNode() and JsonNode.isMissingNode() ever
returns true for any given node.
isContainerNode in class JsonNodepublic abstract JsonToken asToken()
BaseJsonNodeJsonToken that equivalent
stream event would produce (for most nodes there is just
one token but for structured/container types multiple)asToken in interface TreeNodeasToken in class BaseJsonNodepublic String asText()
JsonNodeJsonNode.isValueNode() returns true),
otherwise empty String.public abstract JsonNode findValue(String fieldName)
JsonNodefindValue in class BaseJsonNodefieldName - Name of field to look forpublic abstract ObjectNode findParent(String fieldName)
JsonNodefindParent in class BaseJsonNodefieldName - Name of field to look forpublic abstract List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
findValues in class BaseJsonNodepublic abstract List<JsonNode> findParents(String fieldName, List<JsonNode> foundSoFar)
findParents in class BaseJsonNodepublic abstract List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
findValuesAsText in class BaseJsonNodepublic abstract int size()
JsonNodepublic abstract JsonNode get(int index)
JsonNode
For array nodes, index specifies
exact location within array and allows for efficient iteration
over child elements (underlying storage is guaranteed to
be efficiently indexable, i.e. has random-access to elements).
If index is less than 0, or equal-or-greater than
node.size(), null is returned; no exception is
thrown for any index.
NOTE: if the element value has been explicitly set as null
(which is different from removal!),
a NullNode will be returned,
not null.
public abstract JsonNode get(String fieldName)
JsonNode
NOTE: if the property value has been explicitly set as null
(which is different from removal!),
a NullNode will be returned,
not null.
public final ArrayNode arrayNode()
ArrayNode
Construction is done using registered JsonNodeFactory.public final ObjectNode objectNode()
ObjectNode
Construction is done using registered JsonNodeFactory.public final NullNode nullNode()
public final BooleanNode booleanNode(boolean v)
public final NumericNode numberNode(byte v)
public final NumericNode numberNode(short v)
public final NumericNode numberNode(int v)
public final NumericNode numberNode(long v)
public final NumericNode numberNode(float v)
public final NumericNode numberNode(double v)
public final NumericNode numberNode(BigDecimal v)
public final BinaryNode binaryNode(byte[] data)
public final BinaryNode binaryNode(byte[] data, int offset, int length)
public abstract T removeAll()
Copyright © 2012-2013 FasterXML. All Rights Reserved.