Top Description Inners Constructors Methods
com.fasterxml.jackson.jr.stree

public abstract Class JrsValue

extends Object
implements TreeNode
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.TreeNode
Known Direct Subclasses
com.fasterxml.jackson.jr.stree.JrsValue.Scalar, com.fasterxml.jackson.jr.stree.JrsArray, com.fasterxml.jackson.jr.stree.JrsMissing, com.fasterxml.jackson.jr.stree.JrsObject
Imports
java.io.IOException, java.util.Iterator, com.fasterxml.jackson.core.JsonGenerator, .JsonParser, .JsonPointer, .ObjectCodec, .TreeNode, com.fasterxml.jackson.jr.stree.util.JrsTreeTraversingParser

Shared base class for all "simple" node types of Jackson Jr "simple tree" package; implements TreeNode and is usable via matching com.fasterxml.jackson.core.TreeCodec implementation (see JacksonJrsTreeCodec).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
JrsValue.Scalar

Intermediate base class for non-structured types, other than JrsMissing.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract JrsValue
public String
asText()

Method that may be called on scalar value nodes to get a textual representation of contents.

public JrsValue
at(JsonPointer
JsonPointer expression for descendant node to return
ptr
)

Implements com.fasterxml.jackson.core.TreeNode.at.

Method for locating node specified by given JSON pointer instances.

public JrsValue
at(String
Expression to compile as a JsonPointer instance
s
)

Implements com.fasterxml.jackson.core.TreeNode.at.

Convenience method that is functionally equivalent to:

   return at(JsonPointer.valueOf(jsonPointerExpression));
public Iterator<String>
fieldNames()

Implements com.fasterxml.jackson.core.TreeNode.fieldNames.

Method for accessing names of all fields for this node, if (and only if) this node is an Object node.

public abstract JrsValue
get(String
Name of the field (of Object node) to access
s
)

Redeclares com.fasterxml.jackson.core.TreeNode.get.

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

public abstract JrsValue
get(int
Index of the Array node element to access
i
)

Redeclares com.fasterxml.jackson.core.TreeNode.get.

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

public boolean
isArray()

Implements com.fasterxml.jackson.core.TreeNode.isArray.

Method that returns true if this node is an Array node, false otherwise.

public boolean
public boolean
isMissingNode()

Implements com.fasterxml.jackson.core.TreeNode.isMissingNode.

Method that returns true for "virtual" nodes which represent missing entries constructed by path accessor methods when there is no actual node matching given criteria.

public boolean
public boolean
isNumber()

Method that allows checking whether this value is a JSON number (integer or floating-point).

public boolean
isObject()

Implements com.fasterxml.jackson.core.TreeNode.isObject.

Method that returns true if this node is an Object node, false otherwise.

public JsonParser.NumberType
numberType()

Implements com.fasterxml.jackson.core.TreeNode.numberType.

If this node is a numeric type (as per JsonToken#isNumeric), returns native type that node uses to store the numeric value; otherwise returns null.

public abstract JrsValue
path(String
Name of the field (of Object node) to access
s
)

Redeclares com.fasterxml.jackson.core.TreeNode.path.

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

public abstract JrsValue
path(int
Index of the Array node element to access
i
)

Redeclares com.fasterxml.jackson.core.TreeNode.path.

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

public JsonParser
traverse()

Implements com.fasterxml.jackson.core.TreeNode.traverse.

Method for constructing a JsonParser instance for iterating over contents of the tree that this node is root of.

public JsonParser
traverse(ObjectCodec
ObjectCodec to associate with parser constructed
codec
)

Implements com.fasterxml.jackson.core.TreeNode.traverse.

Same as traverse(), but additionally passes com.fasterxml.jackson.core.ObjectCodec to use if JsonParser#readValueAs(Class) is used (otherwise caller must call JsonParser#setCodec on response explicitly).

protected abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JrsValueback to summary
public JrsValue()

Method Detail

_atback to summary
protected abstract JrsValue _at(JsonPointer ptr)
asTextback to summary
public String asText()

Method that may be called on scalar value nodes to get a textual representation of contents. Returns `null` for structured values (Arrays, Objects), textual representation for other types.

atback to summary
public JrsValue at(JsonPointer ptr)

Implements com.fasterxml.jackson.core.TreeNode.at.

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

Method for locating node specified by given JSON pointer instances. Method will never return null; if no matching node exists, will return a node for which TreeNode#isMissingNode() returns true.

Parameters
ptr:JsonPointer

JsonPointer expression for descendant node to return

Returns:JrsValue

Node that matches given JSON Pointer, if any: if no match exists, will return a "missing" node (for which TreeNode#isMissingNode() returns true).

Annotations
@Override
atback to summary
public JrsValue at(String s)

Implements com.fasterxml.jackson.core.TreeNode.at.

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

Convenience method that is functionally equivalent to:

   return at(JsonPointer.valueOf(jsonPointerExpression));

Note that if the same expression is used often, it is preferable to construct JsonPointer instance once and reuse it: this method will not perform any caching of compiled expressions.

Parameters
s:String

Expression to compile as a JsonPointer instance

Returns:JrsValue

Node that matches given JSON Pointer, if any: if no match exists, will return a "missing" node (for which TreeNode#isMissingNode() returns true).

Annotations
@Override
fieldNamesback to summary
public Iterator<String> fieldNames()

Implements com.fasterxml.jackson.core.TreeNode.fieldNames.

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

Method for accessing names of all fields for this node, if (and only if) this node is an Object node. Number of field names accessible will be size.

Returns:Iterator<String>

An iterator for traversing names of all fields this Object node has (if Object node); empty Iterator otherwise (never null).

Annotations
@Override
getback to summary
public abstract JrsValue get(String s)

Redeclares com.fasterxml.jackson.core.TreeNode.get.

Doc from com.fasterxml.jackson.core.TreeNode.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

handling of explicit null values may vary between implementations; some trees may retain explicit nulls, others not.

Parameters
s:String

Name of the field (of Object node) to access

Returns:JrsValue

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
getback to summary
public abstract JrsValue get(int i)

Redeclares com.fasterxml.jackson.core.TreeNode.get.

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

Method for accessing value of the specified element of an array node. For other nodes, null is 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.

Parameters
i:int

Index of the Array node element to access

Returns:JrsValue

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

Annotations
@Override
isArrayback to summary
public boolean isArray()

Implements com.fasterxml.jackson.core.TreeNode.isArray.

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

Method that returns true if this node is an Array node, false otherwise. Note that if true is returned, isContainerNode must also return true.

Returns:boolean

True for Array nodes, false for everything else

Annotations
@Override
isEmbeddedValueback to summary
public boolean isEmbeddedValue()
isMissingNodeback to summary
public boolean isMissingNode()

Implements com.fasterxml.jackson.core.TreeNode.isMissingNode.

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

Method that returns true for "virtual" nodes which represent missing entries constructed by path accessor methods when there is no actual node matching given criteria.

Note

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

Returns:boolean

True if this node represents a "missing" node

Annotations
@Override
isNullback to summary
public boolean isNull()
isNumberback to summary
public boolean isNumber()

Method that allows checking whether this value is a JSON number (integer or floating-point).

isObjectback to summary
public boolean isObject()

Implements com.fasterxml.jackson.core.TreeNode.isObject.

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

Method that returns true if this node is an Object node, false otherwise. Note that if true is returned, isContainerNode must also return true.

Returns:boolean

True for Object nodes, false for everything else

Annotations
@Override
numberTypeback to summary
public JsonParser.NumberType numberType()

Implements com.fasterxml.jackson.core.TreeNode.numberType.

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

If this node is a numeric type (as per JsonToken#isNumeric), returns native type that node uses to store the numeric value; otherwise returns null.

Returns:JsonParser.NumberType

Type of number contained, if any; or null if node does not contain numeric value.

Annotations
@Override
pathback to summary
public abstract JrsValue path(String s)

Redeclares com.fasterxml.jackson.core.TreeNode.path.

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

Method for accessing value of the specified field of an object node. For other nodes, a "missing node" (virtual node for which isMissingNode returns true) is returned.

Parameters
s:String

Name of the field (of Object node) to access

Returns:JrsValue

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
pathback to summary
public abstract JrsValue path(int i)

Redeclares com.fasterxml.jackson.core.TreeNode.path.

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

Method for accessing value of the specified element of an array node. For other nodes, a "missing node" (virtual node for which isMissingNode returns true) is 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(), "missing node" is returned; no exception is thrown for any index.

Parameters
i:int

Index of the Array node element to access

Returns:JrsValue

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
traverseback to summary
public JsonParser traverse()

Implements com.fasterxml.jackson.core.TreeNode.traverse.

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

Method for constructing a JsonParser instance for iterating over contents of the tree that this node is root of. Functionally equivalent to first serializing tree using ObjectCodec and then re-parsing but more efficient.

Note

constructed parser instance will NOT initially point to a token, so before passing it to deserializers, it is typically necessary to advance it to the first available token by calling JsonParser#nextToken().

Also note that calling this method will NOT pass ObjectCodec reference, so data-binding callback methods like JsonParser#readValueAs(Class) will not work with calling JsonParser#setCodec). It is often better to call traverse(ObjectCodec) to pass the codec explicitly.

Returns:JsonParser

JsonParser that will stream over contents of this node

Annotations
@Override
traverseback to summary
public JsonParser traverse(ObjectCodec codec)

Implements com.fasterxml.jackson.core.TreeNode.traverse.

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

Same as traverse(), but additionally passes com.fasterxml.jackson.core.ObjectCodec to use if JsonParser#readValueAs(Class) is used (otherwise caller must call JsonParser#setCodec on response explicitly).

Note

constructed parser instance will NOT initially point to a token, so before passing it to deserializers, it is typically necessary to advance it to the first available token by calling JsonParser#nextToken().

Parameters
codec:ObjectCodec

ObjectCodec to associate with parser constructed

Returns:JsonParser

JsonParser that will stream over contents of this node

Annotations
@Override
writeback to summary
protected abstract void write(JsonGenerator g, JacksonJrsTreeCodec codec) throws IOException
com.fasterxml.jackson.jr.stree back to summary

public abstract Class JrsValue.Scalar

extends JrsValue
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.jr.stree.JrsBoolean, com.fasterxml.jackson.jr.stree.JrsEmbeddedObject, com.fasterxml.jackson.jr.stree.JrsNull, com.fasterxml.jackson.jr.stree.JrsNumber, com.fasterxml.jackson.jr.stree.JrsString

Intermediate base class for non-structured types, other than JrsMissing.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected JrsValue
public JrsValue
get(String
Name of the field (of Object node) to access
s
)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.get.

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

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

public JrsValue
get(int
Index of the Array node element to access
i
)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.get.

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

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

public final boolean
isContainerNode()

Implements com.fasterxml.jackson.core.TreeNode.isContainerNode.

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

public final boolean
isValueNode()

Implements com.fasterxml.jackson.core.TreeNode.isValueNode.

Method that returns true for all value nodes: ones that are not containers, and that do not represent "missing" nodes in the path.

public JrsValue
path(String
Name of the field (of Object node) to access
s
)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.path.

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

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

public JrsValue
path(int
Index of the Array node element to access
i
)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.path.

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

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

public int
size()

Implements com.fasterxml.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 fields, and for all other nodes 0.

Inherited from com.fasterxml.jackson.jr.stree.JrsValue:
asTextatatfieldNamesisArrayisEmbeddedValueisMissingNodeisNullisNumberisObjectnumberTypetraversetraversewrite

Constructor Detail

Scalarback to summary
public Scalar()

Method Detail

_atback to summary
protected JrsValue _at(JsonPointer ptr)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue._at.

Annotations
@Override
getback to summary
public JrsValue get(String s)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.get.

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

Doc from com.fasterxml.jackson.core.TreeNode.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

handling of explicit null values may vary between implementations; some trees may retain explicit nulls, others not.

Parameters
s:String

Name of the field (of Object node) to access

Returns:JrsValue

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
getback to summary
public JrsValue get(int i)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.get.

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

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

Method for accessing value of the specified element of an array node. For other nodes, null is 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.

Parameters
i:int

Index of the Array node element to access

Returns:JrsValue

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

Annotations
@Override
isContainerNodeback to summary
public final boolean isContainerNode()

Implements com.fasterxml.jackson.core.TreeNode.isContainerNode.

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

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

Note

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

Returns:boolean

True for Array and Object nodes, false otherwise

Annotations
@Override
isValueNodeback to summary
public final boolean isValueNode()

Implements com.fasterxml.jackson.core.TreeNode.isValueNode.

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

Method that returns true for all value nodes: ones that are not containers, and that do not represent "missing" nodes in the path. Such value nodes represent String, Number, Boolean and null values from JSON.

Note

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

Returns:boolean

True if this node is considered a value node; something that represents either a scalar value or explicit null

Annotations
@Override
pathback to summary
public JrsValue path(String s)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.path.

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

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

Method for accessing value of the specified field of an object node. For other nodes, a "missing node" (virtual node for which isMissingNode returns true) is returned.

Parameters
s:String

Name of the field (of Object node) to access

Returns:JrsValue

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
pathback to summary
public JrsValue path(int i)

Implements abstract com.fasterxml.jackson.jr.stree.JrsValue.path.

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

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

Method for accessing value of the specified element of an array node. For other nodes, a "missing node" (virtual node for which isMissingNode returns true) is 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(), "missing node" is returned; no exception is thrown for any index.

Parameters
i:int

Index of the Array node element to access

Returns:JrsValue

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
sizeback to summary
public int size()

Implements com.fasterxml.jackson.core.TreeNode.size.

Doc from com.fasterxml.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 fields, and for all other nodes 0.

Returns:int

For non-container nodes returns 0; for arrays number of contained elements, and for objects number of fields.

Annotations
@Override