public abstract class ValueNode extends BaseJsonNode
JsonNode.OverwriteMode
JsonSerializable.Base
Modifier | Constructor and Description |
---|---|
protected |
ValueNode() |
Modifier and Type | Method and Description |
---|---|
protected JsonNode |
_at(com.fasterxml.jackson.core.JsonPointer ptr)
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. |
abstract com.fasterxml.jackson.core.JsonToken |
asToken()
Method that can be used for efficient type detection
when using stream abstraction for traversing nodes.
|
<T extends JsonNode> |
deepCopy()
All current value nodes are immutable, so we can just return
them as is.
|
ObjectNode |
findParent(String fieldName)
Method for finding a JSON Object that contains specified field,
within this node or its descendants.
|
List<JsonNode> |
findParents(String fieldName,
List<JsonNode> foundSoFar) |
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.
|
List<JsonNode> |
findValues(String fieldName,
List<JsonNode> foundSoFar) |
List<String> |
findValuesAsText(String fieldName,
List<String> foundSoFar) |
JsonNode |
get(int index)
Method for accessing value of the specified element of
an array node.
|
JsonNode |
get(String fieldName)
Method for accessing value of the specified field of
an object node.
|
boolean |
has(int index)
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.
|
boolean |
has(String fieldName)
Method that allows checking whether this node is JSON Object node
and contains value for specified property.
|
boolean |
hasNonNull(int index)
Method that is similar to
JsonNode.has(int) , but that will
return false for explicitly added nulls. |
boolean |
hasNonNull(String fieldName)
Method that is similar to
JsonNode.has(String) , but that will
return false for explicitly added nulls. |
boolean |
isEmpty()
Convenience method that is functionally same as:
|
JsonNode |
path(int index)
This method is similar to
JsonNode.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
JsonNode.isMissingNode() ) will be returned. |
JsonNode |
path(String fieldName)
This method is similar to
JsonNode.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
JsonNode.isMissingNode() ) will be returned. |
void |
serializeWithType(com.fasterxml.jackson.core.JsonGenerator g,
SerializerProvider provider,
TypeSerializer typeSer)
Type information is needed, even if JsonNode instances are "plain" JSON,
since they may be mixed with other types.
|
_jsonPointerIfValid, _reportWrongNodeOperation, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, findPath, hashCode, numberType, required, required, serialize, toPrettyString, toString, traverse, traverse, withArray, withObject
_reportRequiredViolation, _this, asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, asText, asText, at, at, bigIntegerValue, binaryValue, booleanValue, canConvertToExactIntegral, canConvertToInt, canConvertToLong, decimalValue, doubleValue, elements, equals, equals, fieldNames, fields, findParents, findValues, findValuesAsText, floatValue, getNodeType, intValue, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isShort, isTextual, isValueNode, iterator, longValue, numberValue, require, requiredAt, requiredAt, requireNonNull, shortValue, size, textValue, with, withArray, withArray, withArray, withObject, withObject, withObject
isEmpty
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected JsonNode _at(com.fasterxml.jackson.core.JsonPointer ptr)
JsonNode
null
is returned.public <T extends JsonNode> T deepCopy()
public abstract com.fasterxml.jackson.core.JsonToken asToken()
BaseJsonNode
JsonToken
that equivalent
stream event would produce (for most nodes there is just
one token but for structured/container types multiple)asToken
in interface com.fasterxml.jackson.core.TreeNode
asToken
in class BaseJsonNode
public void serializeWithType(com.fasterxml.jackson.core.JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException
BaseJsonNode
serializeWithType
in interface JsonSerializable
serializeWithType
in class BaseJsonNode
IOException
public boolean isEmpty()
JsonNode
size() == 0for all node types.
public final 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 final JsonNode path(int index)
JsonNode
JsonNode.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
JsonNode.isMissingNode()
) will be returned. This allows for
convenient and safe chained access via path calls.public final boolean has(int index)
JsonNode
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.
public final boolean hasNonNull(int index)
JsonNode
JsonNode.has(int)
, but that will
return false
for explicitly added nulls.
This method is equivalent to:
node.get(index) != null && !node.get(index).isNull()
hasNonNull
in class JsonNode
public final 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 JsonNode path(String fieldName)
JsonNode
JsonNode.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
JsonNode.isMissingNode()
) will be returned. This allows for
convenient and safe chained access via path calls.public final boolean has(String fieldName)
JsonNode
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.
public final boolean hasNonNull(String fieldName)
JsonNode
JsonNode.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()
hasNonNull
in class JsonNode
public final JsonNode findValue(String fieldName)
JsonNode
public final ObjectNode findParent(String fieldName)
JsonNode
findParent
in class JsonNode
fieldName
- Name of field to look forpublic final List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
findValues
in class JsonNode
public final List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
findValuesAsText
in class JsonNode
Copyright © 2008–2022 FasterXML. All rights reserved.