Class ContainerNode<T extends ContainerNode<T>>
- java.lang.Object
-
- com.fasterxml.jackson.databind.JsonSerializable.Base
-
- com.fasterxml.jackson.databind.JsonNode
-
- com.fasterxml.jackson.databind.node.BaseJsonNode
-
- com.fasterxml.jackson.databind.node.ContainerNode<T>
-
- All Implemented Interfaces:
TreeNode
,JsonSerializable
,JsonNodeCreator
,java.io.Serializable
,java.lang.Iterable<JsonNode>
- Direct Known Subclasses:
ArrayNode
,ObjectNode
public abstract class ContainerNode<T extends ContainerNode<T>> extends BaseJsonNode implements JsonNodeCreator
This intermediate base class is used for all container nodes, specifically, array and object nodes.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.JsonSerializable
JsonSerializable.Base
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ArrayNode
arrayNode()
Factory method that constructs and returns an emptyArrayNode
Construction is done using registeredJsonNodeFactory
.ArrayNode
arrayNode(int capacity)
Factory method that constructs and returns anArrayNode
with an initial capacity Construction is done using registeredJsonNodeFactory
java.lang.String
asText()
Method that will return a valid String representation of the container value, if the node is a value node (methodJsonNode.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 JsonNode
get(int index)
Method for accessing value of the specified element of an array node.abstract JsonNode
get(java.lang.String fieldName)
Method for accessing value of the specified field of an object node.JsonNode
missingNode()
NullNode
nullNode()
NumericNode
numberNode(byte v)
NumericNode
numberNode(double v)
NumericNode
numberNode(float v)
NumericNode
numberNode(int v)
NumericNode
numberNode(long v)
NumericNode
numberNode(short v)
ValueNode
numberNode(java.lang.Byte v)
ValueNode
numberNode(java.lang.Double v)
ValueNode
numberNode(java.lang.Float v)
ValueNode
numberNode(java.lang.Integer v)
ValueNode
numberNode(java.lang.Long v)
ValueNode
numberNode(java.lang.Short v)
ValueNode
numberNode(java.math.BigDecimal v)
ValueNode
numberNode(java.math.BigInteger v)
ObjectNode
objectNode()
Factory method that constructs and returns an emptyObjectNode
Construction is done using registeredJsonNodeFactory
.ValueNode
pojoNode(java.lang.Object pojo)
ValueNode
rawValueNode(RawValue value)
Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized.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(java.lang.String text)
-
Methods inherited from class com.fasterxml.jackson.databind.node.BaseJsonNode
findPath, hashCode, numberType, required, required, serialize, serializeWithType, toPrettyString, toString, traverse, traverse
-
Methods inherited from class com.fasterxml.jackson.databind.JsonNode
asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, asText, at, at, bigIntegerValue, binaryValue, booleanValue, canConvertToExactIntegral, canConvertToInt, canConvertToLong, decimalValue, deepCopy, doubleValue, elements, equals, equals, fieldNames, fields, findParent, findParents, findParents, findValue, findValues, findValues, findValuesAsText, findValuesAsText, floatValue, getNodeType, has, has, hasNonNull, hasNonNull, intValue, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isEmpty, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isShort, isTextual, isValueNode, iterator, longValue, numberValue, path, path, require, requiredAt, requiredAt, requireNonNull, shortValue, textValue, with, withArray
-
Methods inherited from class com.fasterxml.jackson.databind.JsonSerializable.Base
isEmpty
-
-
-
-
Method Detail
-
asToken
public abstract JsonToken asToken()
Description copied from class:BaseJsonNode
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonToken
that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)- Specified by:
asToken
in interfaceTreeNode
- Specified by:
asToken
in classBaseJsonNode
- Returns:
JsonToken
that is most closely associated with the node type
-
asText
public java.lang.String asText()
Description copied from class:JsonNode
Method that will return a valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()
returns true), otherwise empty String.
-
size
public abstract int size()
Description copied from interface:TreeNode
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.
-
get
public abstract JsonNode get(int index)
Description copied from class:JsonNode
Method for accessing value of the specified element of an array node. For other nodes, null is always returned.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!), aNullNode
will be returned, not null.
-
get
public abstract JsonNode get(java.lang.String fieldName)
Description copied from class:JsonNode
Method for accessing value of the specified field of an object node. If this node is not an object (or it does not have a value for specified field name), or if there is no field with such name, null is returned.NOTE: if the property value has been explicitly set as
null
(which is different from removal!), aNullNode
will be returned, not null.
-
booleanNode
public final BooleanNode booleanNode(boolean v)
- Specified by:
booleanNode
in interfaceJsonNodeCreator
-
missingNode
public JsonNode missingNode()
-
nullNode
public final NullNode nullNode()
- Specified by:
nullNode
in interfaceJsonNodeCreator
-
arrayNode
public final ArrayNode arrayNode()
Factory method that constructs and returns an emptyArrayNode
Construction is done using registeredJsonNodeFactory
.- Specified by:
arrayNode
in interfaceJsonNodeCreator
-
arrayNode
public final ArrayNode arrayNode(int capacity)
Factory method that constructs and returns anArrayNode
with an initial capacity Construction is done using registeredJsonNodeFactory
- Specified by:
arrayNode
in interfaceJsonNodeCreator
- Parameters:
capacity
- the initial capacity of the ArrayNode
-
objectNode
public final ObjectNode objectNode()
Factory method that constructs and returns an emptyObjectNode
Construction is done using registeredJsonNodeFactory
.- Specified by:
objectNode
in interfaceJsonNodeCreator
-
numberNode
public final NumericNode numberNode(byte v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final NumericNode numberNode(short v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final NumericNode numberNode(int v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final NumericNode numberNode(long v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final NumericNode numberNode(float v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final NumericNode numberNode(double v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.math.BigInteger v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.math.BigDecimal v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.lang.Byte v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.lang.Short v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.lang.Integer v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.lang.Long v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.lang.Float v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
public final ValueNode numberNode(java.lang.Double v)
- Specified by:
numberNode
in interfaceJsonNodeCreator
-
textNode
public final TextNode textNode(java.lang.String text)
- Specified by:
textNode
in interfaceJsonNodeCreator
-
binaryNode
public final BinaryNode binaryNode(byte[] data)
- Specified by:
binaryNode
in interfaceJsonNodeCreator
-
binaryNode
public final BinaryNode binaryNode(byte[] data, int offset, int length)
- Specified by:
binaryNode
in interfaceJsonNodeCreator
-
pojoNode
public final ValueNode pojoNode(java.lang.Object pojo)
- Specified by:
pojoNode
in interfaceJsonNodeCreator
-
rawValueNode
public final ValueNode rawValueNode(RawValue value)
Description copied from interface:JsonNodeCreator
Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized. This may be used, for example, to include fully serialized JSON sub-trees. Note that the concept may not work with all backends, and since no translation of any kinds is done it will not work when converting between data formats.- Specified by:
rawValueNode
in interfaceJsonNodeCreator
-
removeAll
public abstract T removeAll()
Method for removing all children container has (if any)- Returns:
- Container node itself (to allow method call chaining)
-
-