Top Description Fields Constructors Methods
tools.jackson.databind.node

public abstract Class ContainerNode<T extends ContainerNode<T>>

extends BaseJsonNode
implements JsonNodeCreator
Class Inheritance
All Implemented Interfaces
tools.jackson.databind.node.JsonNodeCreator
Known Direct Subclasses
tools.jackson.databind.node.ObjectNode, tools.jackson.databind.node.ArrayNode
Imports
java.math.BigDecimal, .BigInteger, java.util.function.Predicate, java.util.stream.Stream, tools.jackson.core.*, tools.jackson.databind.JsonNode, tools.jackson.databind.util.RawValue

This intermediate base class is used for all container nodes, specifically, array and object nodes.

Field Summary

Modifier and TypeField and Description
protected final JsonNodeFactory
_nodeFactory

We will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.

private static final long
Inherited from tools.jackson.databind.node.BaseJsonNode:
OPT_FALSEOPT_TRUE

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
protected abstract ObjectNode
_withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex)

Overrides tools.jackson.databind.node.BaseJsonNode._withObject.

public final ArrayNode
arrayNode()

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method that constructs and returns an empty ArrayNode Construction is done using registered JsonNodeFactory.

public final ArrayNode
arrayNode(int
the initial capacity of the ArrayNode
capacity
)

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method that constructs and returns an ArrayNode with an initial capacity Construction is done using registered JsonNodeFactory

public abstract JsonToken
asToken()

Redeclares tools.jackson.core.TreeNode.asToken.

Implements abstract tools.jackson.databind.node.BaseJsonNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.

public final BinaryNode
public final BinaryNode
binaryNode(byte[] data, int offset, int length)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

public final BooleanNode
public abstract JsonNode
get(int index)

Redeclares tools.jackson.core.TreeNode.get.

Implements abstract tools.jackson.databind.JsonNode.get.

Method for accessing value of the specified element of an array node.

public abstract JsonNode
get(String fieldName)

Redeclares tools.jackson.core.TreeNode.get.

Overrides tools.jackson.databind.JsonNode.get.

Method for accessing value of the specified field of an object node.

public boolean
isContainer()

Overrides tools.jackson.databind.JsonNode.isContainer.

Implements tools.jackson.core.TreeNode.isContainer.

Method that returns true for container nodes: Arrays and Objects.

public JsonNode
public final NullNode
public final NumericNode
public final NumericNode
public final NumericNode
public final NumericNode
public final NumericNode
public final NumericNode
public final ValueNode
public final ValueNode
public final ValueNode
public final ValueNode
public final ValueNode
public final ValueNode
public final ValueNode
public final ValueNode
public final ObjectNode
objectNode()

Implements tools.jackson.databind.node.JsonNodeCreator.objectNode.

Factory method that constructs and returns an empty ObjectNode Construction is done using registered JsonNodeFactory.

public final ValueNode
public final ValueNode
rawValueNode(RawValue value)

Implements tools.jackson.databind.node.JsonNodeCreator.rawValueNode.

Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized.

public abstract T

Returns:

Container node itself (to allow method call chaining)
removeAll
()

Method for removing all children container has (if any)

public abstract T

Returns:

Container node itself (to allow method call chaining)
removeIf
(Predicate<? super JsonNode>
Predicate to use for matching: anything matching will be removed
predicate
)

Method for removing matching those children (value) nodes container has that match given predicate.

public T

Returns:

Container node itself (to allow method call chaining)
removeNulls
()

Method for removing null children (value) nodes container has (that is, children for which isNull() returns true).

public abstract int
size()

Redeclares tools.jackson.core.TreeNode.size.

Overrides tools.jackson.databind.JsonNode.size.

Method that returns number of child nodes this node contains: for Array nodes, number of child elements, for Object nodes, number of properties, and for all other nodes 0.

public final StringNode
public abstract Stream<JsonNode>
valueStream()

Overrides tools.jackson.databind.JsonNode.valueStream.

Returns a stream of all value nodes of this Node, iff this node is an ArrayNode or ObjectNode.

Inherited from tools.jackson.databind.node.BaseJsonNode:
_asBoolean_asString_jsonPointerIfValid_reportBigDecimalCoercionNaNFail_reportBigIntegerCoercionFractionFail_reportBigIntegerCoercionNaNFail_reportCoercionFail_reportDoubleCoercionRangeFail_reportFloatCoercionRangeFail_reportIntCoercionFractionFail_reportIntCoercionNaNFail_reportIntCoercionRangeFail_reportLongCoercionFractionFail_reportLongCoercionNaNFail_reportLongCoercionRangeFail_reportShortCoercionFractionFail_reportShortCoercionRangeFail_reportWrongNodeType_valueDesc_withArray_withXxxMayReplace_withXxxVerifyReplaceasBigIntegerasBigIntegerasBigIntegerOptasBooleanasBooleanasBooleanOptasDecimalasDecimalasDecimalOptasDoubleasDoubleasDoubleOptasFloatasFloatasFloatOptasIntasIntasIntOptasLongasLongasLongOptasShortasShortasShortOptasStringasStringasStringOptbigIntegerValuebigIntegerValuebigIntegerValueOptbinaryValuebooleanValuebooleanValuebooleanValueOptdecimalValuedecimalValuedecimalValueOptdoubleValuedoubleValuedoubleValueOptfindPathfloatValuefloatValuefloatValueOpthashCodeintValueintValueintValueOptisEmbeddedValueisMissingNodelongValuelongValuelongValueOptnumberTypenumberValuerequiredrequiredserializeserializeWithTypeshortValueshortValueshortValueOptstringValuestringValuestringValueOpttoPrettyStringtoStringtraversewithArraywithObjectwriteReplace

Field Detail

_nodeFactoryback to summary
protected final JsonNodeFactory _nodeFactory

We will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides tools.jackson.databind.node.BaseJsonNode.serialVersionUID.

Constructor Detail

ContainerNodeback to summary
protected ContainerNode(JsonNodeFactory nc)
ContainerNodeback to summary
protected ContainerNode()

Method Detail

_withObjectback to summary
protected abstract ObjectNode _withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex)

Overrides tools.jackson.databind.node.BaseJsonNode._withObject.

Annotations
@Override
arrayNodeback to summary
public final ArrayNode arrayNode()

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method that constructs and returns an empty ArrayNode Construction is done using registered JsonNodeFactory.

Annotations
@Override
arrayNodeback to summary
public final ArrayNode arrayNode(int capacity)

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method that constructs and returns an ArrayNode with an initial capacity Construction is done using registered JsonNodeFactory

Parameters
capacity:int

the initial capacity of the ArrayNode

Annotations
@Override
asTokenback to summary
public abstract JsonToken asToken()

Redeclares tools.jackson.core.TreeNode.asToken.

Implements abstract tools.jackson.databind.node.BaseJsonNode.asToken.

Doc from tools.jackson.databind.node.BaseJsonNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)

Annotations
@Override
binaryNodeback to summary
public final BinaryNode binaryNode(byte[] data)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

Annotations
@Override
binaryNodeback to summary
public final BinaryNode binaryNode(byte[] data, int offset, int length)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

Annotations
@Override
booleanNodeback to summary
public final BooleanNode booleanNode(boolean v)

Implements tools.jackson.databind.node.JsonNodeCreator.booleanNode.

Annotations
@Override
getback to summary
public abstract JsonNode get(int index)

Redeclares tools.jackson.core.TreeNode.get.

Implements abstract tools.jackson.databind.JsonNode.get.

Doc from tools.jackson.databind.JsonNode.get.

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!), a tools.jackson.databind.node.NullNode will be returned, not null.

Annotations
@Override
getback to summary
public abstract JsonNode get(String fieldName)

Redeclares tools.jackson.core.TreeNode.get.

Overrides tools.jackson.databind.JsonNode.get.

Doc from tools.jackson.databind.JsonNode.get.

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!), a tools.jackson.databind.node.NullNode will be returned, not null.

Annotations
@Override
isContainerback to summary
public boolean isContainer()

Overrides tools.jackson.databind.JsonNode.isContainer.

Implements tools.jackson.core.TreeNode.isContainer.

Doc from tools.jackson.core.TreeNode.isContainer.

Method that returns true for container nodes: Arrays and Objects.

Note

one and only one of methods isValueNode, isContainer() and isMissingNode ever returns true for any given node.

Annotations
@Override
missingNodeback to summary
public JsonNode missingNode()

Implements tools.jackson.databind.node.JsonNodeCreator.missingNode.

Annotations
@Override
nullNodeback to summary
public final NullNode nullNode()

Implements tools.jackson.databind.node.JsonNodeCreator.nullNode.

Annotations
@Override
numberNodeback to summary
public final NumericNode numberNode(byte v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final NumericNode numberNode(short v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final NumericNode numberNode(int v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final NumericNode numberNode(long v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final NumericNode numberNode(float v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final NumericNode numberNode(double v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(BigInteger v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(BigDecimal v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(Byte v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(Short v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(Integer v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(Long v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(Float v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
numberNodeback to summary
public final ValueNode numberNode(Double v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Annotations
@Override
objectNodeback to summary
public final ObjectNode objectNode()

Implements tools.jackson.databind.node.JsonNodeCreator.objectNode.

Factory method that constructs and returns an empty ObjectNode Construction is done using registered JsonNodeFactory.

Annotations
@Override
pojoNodeback to summary
public final ValueNode pojoNode(Object pojo)

Implements tools.jackson.databind.node.JsonNodeCreator.pojoNode.

Annotations
@Override
rawValueNodeback to summary
public final ValueNode rawValueNode(RawValue value)

Implements tools.jackson.databind.node.JsonNodeCreator.rawValueNode.

Doc from tools.jackson.databind.node.JsonNodeCreator.rawValueNode.

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.

Annotations
@Override
removeAllback to summary
public abstract T removeAll()

Method for removing all children container has (if any)

Returns:T

Container node itself (to allow method call chaining)

removeIfback to summary
public abstract T removeIf(Predicate<? super JsonNode> predicate)

Method for removing matching those children (value) nodes container has that match given predicate.

Parameters
predicate:Predicate<? super JsonNode>

Predicate to use for matching: anything matching will be removed

Returns:T

Container node itself (to allow method call chaining)

Since
2.19
removeNullsback to summary
public T removeNulls()

Method for removing null children (value) nodes container has (that is, children for which isNull() returns true). Short-cut for:

     removeIf(JsonNode::isNull);
Returns:T

Container node itself (to allow method call chaining)

Since
2.19
sizeback to summary
public abstract int size()

Redeclares tools.jackson.core.TreeNode.size.

Overrides tools.jackson.databind.JsonNode.size.

Doc from tools.jackson.core.TreeNode.size.

Method that returns number of child nodes this node contains: for Array nodes, number of child elements, for Object nodes, number of properties, and for all other nodes 0.

Annotations
@Override
stringNodeback to summary
public final StringNode stringNode(String text)

Implements tools.jackson.databind.node.JsonNodeCreator.stringNode.

Annotations
@Override
valueStreamback to summary
public abstract Stream<JsonNode> valueStream()

Overrides tools.jackson.databind.JsonNode.valueStream.

Doc from tools.jackson.databind.JsonNode.valueStream.

Returns a stream of all value nodes of this Node, iff this node is an ArrayNode or ObjectNode. In case of Object node, property names (keys) are not included, only values. For other types of nodes, returns empty stream.

Annotations
@Override