Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.node

public abstract Class ValueNode

extends BaseJsonNode
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.databind.node.BinaryNode, com.fasterxml.jackson.databind.node.BooleanNode, com.fasterxml.jackson.databind.node.MissingNode, com.fasterxml.jackson.databind.node.NullNode, com.fasterxml.jackson.databind.node.NumericNode, com.fasterxml.jackson.databind.node.POJONode, com.fasterxml.jackson.databind.node.TextNode
Imports
java.io.IOException, java.util.List, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.type.WritableTypeId, com.fasterxml.jackson.databind.JsonNode, .SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer

This intermediate base class is used for all leaf nodes, that is, all non-container (array or object) nodes, except for the "missing node".

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected JsonNode
_at(JsonPointer
Path expression to use
ptr
)

Implements abstract com.fasterxml.jackson.databind.JsonNode._at.

Helper method used by other methods for traversing the next step of given path expression, and returning matching value node if any: if no match, null is returned.
public abstract JsonToken
asToken()

Redeclares com.fasterxml.jackson.core.TreeNode.asToken.

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.
public <T extends JsonNode> T
deepCopy()

Implements abstract com.fasterxml.jackson.databind.JsonNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.
public final ObjectNode
findParent(String
Name of field to look for
fieldName
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findParent.

Method for finding a JSON Object that contains specified field, within this node or its descendants.
public final List<JsonNode>
public final JsonNode
findValue(String
Name of field to look for
fieldName
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findValue.

Method for finding a JSON Object field with specified name in this node or its child nodes, and returning value it has.
public final List<JsonNode>
public final List<String>
public final JsonNode
get(int
Index of the Array node element to access
index
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.get.

Implements com.fasterxml.jackson.core.TreeNode.get.

Method for accessing value of the specified element of an array node.
public final JsonNode
get(String
Name of the field (of Object node) to access
fieldName
)

Overrides com.fasterxml.jackson.databind.JsonNode.get.

Implements com.fasterxml.jackson.core.TreeNode.get.

Method for accessing value of the specified field of an object node.
public final boolean
has(int
Index to check
index
)

Overrides com.fasterxml.jackson.databind.JsonNode.has.

Method that allows checking whether this node is JSON Array node and contains a value for specified index If this is the case (including case of specified indexing having null as value), returns true; otherwise returns false.
public final boolean
has(String
Name of element to check
fieldName
)

Overrides com.fasterxml.jackson.databind.JsonNode.has.

Method that allows checking whether this node is JSON Object node and contains value for specified property.
public final boolean
hasNonNull(int index)

Overrides com.fasterxml.jackson.databind.JsonNode.hasNonNull.

Method that is similar to has(int), but that will return false for explicitly added nulls.
public final boolean
hasNonNull(String fieldName)

Overrides com.fasterxml.jackson.databind.JsonNode.hasNonNull.

Method that is similar to has(String), but that will return false for explicitly added nulls.
public boolean
isEmpty()

Overrides com.fasterxml.jackson.databind.JsonNode.isEmpty.

Convenience method that is functionally same as:
    size() == 0
public final JsonNode
path(int
Index of the Array node element to access
index
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.path.

Implements com.fasterxml.jackson.core.TreeNode.path.

This method is similar to get(int), except that instead of returning null if no such element exists (due to index being out of range, or this node not being an array), a "missing node" (node that returns true for isMissingNode) will be returned.
public final JsonNode
path(String
Name of the field (of Object node) to access
fieldName
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.path.

Implements com.fasterxml.jackson.core.TreeNode.path.

This method is similar to get(String), except that instead of returning null if no such value exists (due to this node not being an object, or object not having value for the specified field), a "missing node" (node that returns true for isMissingNode) will be returned.
public void
serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer)

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serializeWithType.

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.
Inherited from com.fasterxml.jackson.databind.node.BaseJsonNode:
_bigIntFromBigDec_jsonPointerIfValid_reportWrongNodeOperation_reportWrongNodeType_withArray_withObject_withXxxMayReplace_withXxxVerifyReplacefindPathhashCodenumberTyperequiredrequiredserializetoPrettyStringtoStringtraversetraversewithArraywithObjectwriteReplace

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.node.BaseJsonNode.serialVersionUID.

Constructor Detail

ValueNodeback to summary
protected ValueNode()

Method Detail

_atback to summary
protected JsonNode _at(JsonPointer ptr)

Implements abstract com.fasterxml.jackson.databind.JsonNode._at.

Doc from com.fasterxml.jackson.databind.JsonNode._at.

Helper method used by other methods for traversing the next step of given path expression, and returning matching value node if any: if no match, null is returned.

Parameters
ptr:JsonPointer

Path expression to use

Returns:JsonNode

Either matching JsonNode for the first step of path or null if no match (including case that this node is not a container)

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

Redeclares com.fasterxml.jackson.core.TreeNode.asToken.

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.asToken.

Doc from com.fasterxml.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)

Returns:JsonToken

Doc from com.fasterxml.jackson.core.TreeNode.asToken.

JsonToken that is most closely associated with the node type

Annotations
@Override
deepCopyback to summary
public <T extends JsonNode> T deepCopy()

Implements abstract com.fasterxml.jackson.databind.JsonNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

Returns:T

Doc from com.fasterxml.jackson.databind.JsonNode.deepCopy.

Node that is either a copy of this node (and all non-leaf children); or, for immutable leaf nodes, node itself.

Annotations
@SuppressWarnings:unchecked
@Override
findParentback to summary
public final ObjectNode findParent(String fieldName)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findParent.

Doc from com.fasterxml.jackson.databind.JsonNode.findParent.

Method for finding a JSON Object that contains specified field, within this node or its descendants. If no matching field is found in this node or its descendants, returns null.

Parameters
fieldName:String

Name of field to look for

Returns:ObjectNode

Value of first matching node found, if any; null if none

Annotations
@Override
findParentsback to summary
public final List<JsonNode> findParents(String fieldName, List<JsonNode> foundSoFar)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findParents.

Annotations
@Override
findValueback to summary
public final JsonNode findValue(String fieldName)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findValue.

Doc from com.fasterxml.jackson.databind.JsonNode.findValue.

Method for finding a JSON Object field with specified name in this node or its child nodes, and returning value it has. If no matching field is found in this node or its descendants, returns null.

Parameters
fieldName:String

Name of field to look for

Returns:JsonNode

Value of first matching node found, if any; null if none

Annotations
@Override
findValuesback to summary
public final List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findValues.

Annotations
@Override
findValuesAsTextback to summary
public final List<String> findValuesAsText(String fieldName, List<String> foundSoFar)

Implements abstract com.fasterxml.jackson.databind.JsonNode.findValuesAsText.

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

Implements abstract com.fasterxml.jackson.databind.JsonNode.get.

Implements com.fasterxml.jackson.core.TreeNode.get.

Doc from com.fasterxml.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 com.fasterxml.jackson.databind.node.NullNode will be returned, not null.

Parameters
index:int

Doc from com.fasterxml.jackson.core.TreeNode.get.

Index of the Array node element to access

Returns:JsonNode

Node that represent value of the specified element, if this node is an array and has specified element. Null otherwise.

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

Overrides com.fasterxml.jackson.databind.JsonNode.get.

Implements com.fasterxml.jackson.core.TreeNode.get.

Doc from com.fasterxml.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 com.fasterxml.jackson.databind.node.NullNode will be returned, not null.

Parameters
fieldName:String

Doc from com.fasterxml.jackson.core.TreeNode.get.

Name of the field (of Object node) to access

Returns:JsonNode

Node that represent value of the specified field, if this node is an object and has value for the specified field. Null otherwise.

Annotations
@Override
hasback to summary
public final boolean has(int index)

Overrides com.fasterxml.jackson.databind.JsonNode.has.

Doc from com.fasterxml.jackson.databind.JsonNode.has.

Method that allows checking whether this node is JSON Array node and contains a value for specified index If this is the case (including case of specified indexing having null as value), returns true; otherwise returns false.

Note

array element indexes are 0-based.

This method is equivalent to:

   node.get(index) != null

Note

this method will return true for explicitly added null values.

Parameters
index:int

Index to check

Returns:boolean

True if this node is a JSON Object node, and has a property entry with specified name (with any value, including null value)

Annotations
@Override
hasback to summary
public final boolean has(String fieldName)

Overrides com.fasterxml.jackson.databind.JsonNode.has.

Doc from com.fasterxml.jackson.databind.JsonNode.has.

Method that allows checking whether this node is JSON Object node and contains value for specified property. If this is the case (including properties with explicit null values), returns true; otherwise returns false.

This method is equivalent to:

   node.get(fieldName) != null
(since return value of get() is node, not value node contains)

Note

when explicit null values are added, this method will return true for such properties.

Parameters
fieldName:String

Name of element to check

Returns:boolean

True if this node is a JSON Object node, and has a property entry with specified name (with any value, including null value)

Annotations
@Override
hasNonNullback to summary
public final boolean hasNonNull(int index)

Overrides com.fasterxml.jackson.databind.JsonNode.hasNonNull.

Doc from com.fasterxml.jackson.databind.JsonNode.hasNonNull.

Method that is similar to has(int), but that will return false for explicitly added nulls.

This method is equivalent to:

   node.get(index) != null && !node.get(index).isNull()
Annotations
@Override
hasNonNullback to summary
public final boolean hasNonNull(String fieldName)

Overrides com.fasterxml.jackson.databind.JsonNode.hasNonNull.

Doc from com.fasterxml.jackson.databind.JsonNode.hasNonNull.

Method that is similar to has(String), but that will return false for explicitly added nulls.

This method is functionally equivalent to:

   node.get(fieldName) != null && !node.get(fieldName).isNull()
Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides com.fasterxml.jackson.databind.JsonNode.isEmpty.

Doc from com.fasterxml.jackson.databind.JsonNode.isEmpty.

Convenience method that is functionally same as:

    size() == 0
for all node types.
Annotations
@Override
pathback to summary
public final JsonNode path(int index)

Implements abstract com.fasterxml.jackson.databind.JsonNode.path.

Implements com.fasterxml.jackson.core.TreeNode.path.

Doc from com.fasterxml.jackson.databind.JsonNode.path.

This method is similar to get(int), except that instead of returning null if no such element exists (due to index being out of range, or this node not being an array), a "missing node" (node that returns true for isMissingNode) will be returned. This allows for convenient and safe chained access via path calls.

Parameters
index:int

Doc from com.fasterxml.jackson.core.TreeNode.path.

Index of the Array node element to access

Returns:JsonNode

Doc from com.fasterxml.jackson.core.TreeNode.path.

Node that represent value of the specified element, if this node is an array and has specified element; otherwise "missing node" is returned.

Annotations
@Override
pathback to summary
public final JsonNode path(String fieldName)

Implements abstract com.fasterxml.jackson.databind.JsonNode.path.

Implements com.fasterxml.jackson.core.TreeNode.path.

Doc from com.fasterxml.jackson.databind.JsonNode.path.

This method is similar to get(String), except that instead of returning null if no such value exists (due to this node not being an object, or object not having value for the specified field), a "missing node" (node that returns true for isMissingNode) will be returned. This allows for convenient and safe chained access via path calls.

Parameters
fieldName:String

Doc from com.fasterxml.jackson.core.TreeNode.path.

Name of the field (of Object node) to access

Returns:JsonNode

Doc from com.fasterxml.jackson.core.TreeNode.path.

Node that represent value of the specified field, if this node is an object and has value for the specified field; otherwise "missing node" is returned.

Annotations
@Override
serializeWithTypeback to summary
public void serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serializeWithType.

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.serializeWithType.

Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.

Annotations
@Override