Module tools.jackson.databind
Package tools.jackson.databind.node
Class ContainerNode<T extends ContainerNode<T>>
java.lang.Object
tools.jackson.databind.JacksonSerializable.Base
tools.jackson.databind.JsonNode
tools.jackson.databind.node.BaseJsonNode
tools.jackson.databind.node.ContainerNode<T>
- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,TreeNode,JacksonSerializable,JsonNodeCreator
- 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteModeNested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final JsonNodeFactoryWe will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.Fields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ObjectNode_withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex) final ArrayNodeFactory method that constructs and returns an emptyArrayNodeConstruction is done using registeredJsonNodeFactory.final ArrayNodearrayNode(int capacity) Factory method that constructs and returns anArrayNodewith an initial capacity Construction is done using registeredJsonNodeFactoryabstract JsonTokenasToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.final BinaryNodebinaryNode(byte[] data) final BinaryNodebinaryNode(byte[] data, int offset, int length) final BooleanNodebooleanNode(boolean v) abstract JsonNodeget(int index) Method for accessing value of the specified element of an array node.abstract JsonNodeMethod for accessing value of the specified field of an object node.booleanfinal NullNodenullNode()final NumericNodenumberNode(byte v) final NumericNodenumberNode(double v) final NumericNodenumberNode(float v) final NumericNodenumberNode(int v) final NumericNodenumberNode(long v) final NumericNodenumberNode(short v) final ValueNodenumberNode(Byte v) final ValueNodenumberNode(Double v) final ValueNodenumberNode(Float v) final ValueNodefinal ValueNodenumberNode(Long v) final ValueNodenumberNode(Short v) final ValueNodefinal ValueNodefinal ObjectNodeFactory method that constructs and returns an emptyObjectNodeConstruction is done using registeredJsonNodeFactory.final ValueNodefinal ValueNoderawValueNode(RawValue value) Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized.abstract TMethod for removing all children container has (if any)abstract TMethod for removing matching those children (value) nodes container has that match given predicate.Method for removingnullchildren (value) nodes container has (that is, children for whichisNull()returns true).abstract intsize()final StringNodestringNode(String text) Returns a stream of all value nodes of this Node, iff this node is anArrayNodeorObjectNode.Methods inherited from class 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, _withXxxVerifyReplace, asBigInteger, asBigInteger, asBigIntegerOpt, asBoolean, asBoolean, asBooleanOpt, asDecimal, asDecimal, asDecimalOpt, asDouble, asDouble, asDoubleOpt, asFloat, asFloat, asFloatOpt, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, asString, asString, asStringOpt, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, binaryValue, booleanValue, booleanValue, booleanValueOpt, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, floatValue, floatValueOpt, hashCode, intValue, intValue, intValueOpt, isEmbeddedValue, isMissingNode, longValue, longValue, longValueOpt, numberType, numberValue, required, required, serialize, serializeWithType, shortValue, shortValue, shortValueOpt, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_at, _reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, deepCopy, equals, equals, findParent, findParents, findParents, findValue, findValues, findValues, findValuesAsString, findValuesAsString, forEachEntry, getNodeType, has, has, hasNonNull, hasNonNull, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isDouble, isEmpty, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, optional, optional, path, path, properties, propertyNames, propertyStream, require, requiredAt, requiredAt, requireNonNull, spliterator, textValue, values, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectPropertyMethods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmptyMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface tools.jackson.databind.node.JsonNodeCreator
textNode
-
Field Details
-
_nodeFactory
We will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.
-
-
Constructor Details
-
ContainerNode
-
ContainerNode
protected ContainerNode()
-
-
Method Details
-
isContainer
public boolean isContainer()- Specified by:
isContainerin interfaceTreeNode- Overrides:
isContainerin classJsonNode
-
asToken
Description copied from class:BaseJsonNodeMethod that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonTokenthat equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)- Specified by:
asTokenin interfaceTreeNode- Specified by:
asTokenin classBaseJsonNode
-
size
public abstract int size() -
get
Description copied from class:JsonNodeMethod 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!), aNullNodewill be returned, not null. -
get
Description copied from class:JsonNodeMethod 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!), aNullNodewill be returned, not null. -
valueStream
Description copied from class:JsonNodeReturns a stream of all value nodes of this Node, iff this node is anArrayNodeorObjectNode. In case ofObjectnode, property names (keys) are not included, only values. For other types of nodes, returns empty stream.- Overrides:
valueStreamin classJsonNode
-
_withObject
protected abstract ObjectNode _withObject(JsonPointer origPtr, JsonPointer currentPtr, JsonNode.OverwriteMode overwriteMode, boolean preferIndex) - Overrides:
_withObjectin classBaseJsonNode
-
booleanNode
- Specified by:
booleanNodein interfaceJsonNodeCreator
-
missingNode
- Specified by:
missingNodein interfaceJsonNodeCreator
-
nullNode
- Specified by:
nullNodein interfaceJsonNodeCreator
-
arrayNode
Factory method that constructs and returns an emptyArrayNodeConstruction is done using registeredJsonNodeFactory.- Specified by:
arrayNodein interfaceJsonNodeCreator
-
arrayNode
Factory method that constructs and returns anArrayNodewith an initial capacity Construction is done using registeredJsonNodeFactory- Specified by:
arrayNodein interfaceJsonNodeCreator- Parameters:
capacity- the initial capacity of the ArrayNode
-
objectNode
Factory method that constructs and returns an emptyObjectNodeConstruction is done using registeredJsonNodeFactory.- Specified by:
objectNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
numberNode
- Specified by:
numberNodein interfaceJsonNodeCreator
-
stringNode
- Specified by:
stringNodein interfaceJsonNodeCreator
-
binaryNode
- Specified by:
binaryNodein interfaceJsonNodeCreator
-
binaryNode
- Specified by:
binaryNodein interfaceJsonNodeCreator
-
pojoNode
- Specified by:
pojoNodein interfaceJsonNodeCreator
-
rawValueNode
Description copied from interface:JsonNodeCreatorFactory 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:
rawValueNodein interfaceJsonNodeCreator
-
removeAll
Method for removing all children container has (if any)- Returns:
- Container node itself (to allow method call chaining)
-
removeIf
Method for removing matching those children (value) nodes container has that match given predicate.- Parameters:
predicate- Predicate to use for matching: anything matching will be removed- Returns:
- Container node itself (to allow method call chaining)
- Since:
- 2.19
-
removeNulls
Method for removingnullchildren (value) nodes container has (that is, children for whichisNull()returns true). Short-cut for:removeIf(JsonNode::isNull);- Returns:
- Container node itself (to allow method call chaining)
- Since:
- 2.19
-