T - the type of the tree@ThreadSafe public abstract class TreePointer<T extends com.fasterxml.jackson.core.TreeNode> extends Object implements Iterable<TokenResolver<T>>
TreeNode
Note that all pointers are absolute: they start from the root of the tree. This is to mirror the behaviour of JSON Pointer proper.
The class does not decode a JSON Pointer representation itself; however it provides all the necessary methods for implementations to achieve this.
This class has two traversal methods: get(TreeNode) and path(TreeNode). The difference between both is that path() may
return another node than null if the tree representation has such
a node. This is the case, for instance, for JsonNode, which has a
MissingNode.
At the core, this class is essentially a(n ordered!) List of
TokenResolvers (which is iterable via the class itself).
Note that this class' hashCode(), equals(Object) and
toString() are final.
| Modifier and Type | Field and Description |
|---|---|
protected static MessageBundle |
BUNDLE |
protected List<TokenResolver<T>> |
tokenResolvers
The list of token resolvers
|
| Modifier | Constructor and Description |
|---|---|
protected |
TreePointer(List<TokenResolver<T>> tokenResolvers)
Alternate constructor
|
protected |
TreePointer(T missing,
List<TokenResolver<T>> tokenResolvers)
Main protected constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
T |
get(T node)
Traverse a node and return the result
|
int |
hashCode() |
boolean |
isEmpty()
Tell whether this pointer is empty
|
Iterator<TokenResolver<T>> |
iterator() |
T |
path(T node)
Traverse a node and return the result
|
protected static List<ReferenceToken> |
tokensFromInput(String input)
Decode an input into a list of reference tokens
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected static final MessageBundle BUNDLE
protected final List<TokenResolver<T extends com.fasterxml.jackson.core.TreeNode>> tokenResolvers
protected TreePointer(T missing, List<TokenResolver<T>> tokenResolvers)
This constructor makes an immutable copy of the list it receives as an argument.
missing - the representation of a missing node (may be null)tokenResolvers - the list of reference token resolversprotected TreePointer(List<TokenResolver<T>> tokenResolvers)
This is the same as calling TreePointer(TreeNode, List) with
null as the missing node.
tokenResolvers - the list of token resolverspublic final T get(T node)
Note that this method shortcuts: it stops at the first node it cannot traverse.
node - the node to traversenull if not foundpublic final T path(T node)
This is like get(TreeNode), but it will return the missing
node if traversal fails.
node - the node to traverseTreePointer(TreeNode, List)public final boolean isEmpty()
public final Iterator<TokenResolver<T>> iterator()
iterator in interface Iterable<TokenResolver<T extends com.fasterxml.jackson.core.TreeNode>>protected static List<ReferenceToken> tokensFromInput(String input) throws JsonPointerException
input - the inputJsonPointerException - input is not a valid JSON PointerNullPointerException - input is null