TreeNode#at).
It may be used in future for filtering of streaming JSON content
as well (not implemented yet for 2.3).
Note that the implementation was largely rewritten for Jackson 2.14 to reduce memory usage by sharing backing "full path" representation for nested instances.
Instances are fully immutable and can be cached, shared between threads.
| Modifier and Type | Class and Description |
|---|---|
| private static class | JsonPointer.PointerParent
Helper class used to replace call stack when parsing JsonPointer expressions. |
| private static class | JsonPointer.PointerSegment
Helper class used to contain a single segment when constructing JsonPointer from context. |
| pack-priv static class | JsonPointer.Serialization
This must only exist to allow both final properties and implementation of Externalizable/Serializable for JsonPointer. |
| Modifier and Type | Field and Description |
|---|---|
| protected final String | |
| protected final int | |
| protected int | |
| protected volatile JsonPointer | _head
Reference from currently matching segment (if any) to node before leaf. |
| protected final int | |
| protected final String | |
| protected final JsonPointer | _nextSegment
Reference to rest of the pointer beyond currently matching segment (if any); null if this pointer refers to the matching segment. |
| protected static final JsonPointer | |
| public static final char | SEPARATOR
Character used to separate segments. |
| private static final long |
| Access | Constructor and Description |
|---|---|
| protected | JsonPointer()
Constructor used for creating "empty" instance, used to represent state that matches current node. |
| protected | |
| protected | JsonPointer(String fullString, int fullStringOffset, String segment, int matchIndex, JsonPointer next)
|
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| private static void | |
| private static JsonPointer | _buildPath(final String fullPath, int fullPathOffset, String segment, JsonPointer.
|
| private final boolean | |
| protected JsonPointer | |
| protected JsonPointer | |
| protected static int | Returns: Offset at which slash was encountered, if any, or -1 if expression ended without seeing unescaped slashFull input for the tail being parsed input, int Offset of the first character of segment (one
after slash) firstCharOffset, int Offset to character after tilde i, StringBuilder StringBuilder into which unquoted segment is added sb)Method called to extract the next segment of the path, in case where we seem to have encountered a (tilde-)escaped character within segment. |
| private static final int | |
| protected static JsonPointer | |
| public JsonPointer | Returns: Either `this` instance, `tail`, or a newly created combination, as per description above.JsonPointer instance to append to this one, to create a new pointer instanceMutant factory method that will return
|
| public JsonPointer | Returns: Newly created combination, as per description above.new segment element index index)ATTENTION! |
| public JsonPointer | Returns: Either `this` instance, or a newly created combination, as per description above.new segment property name property)ATTENTION! |
| public static JsonPointer | Returns: CompiledJsonPointer path expressionPointer expression to compile expr)Factory method that parses given input and construct matching pointer
instance, if it represents a valid JSON Pointer: if not, a
|
| public static JsonPointer | |
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public static JsonPointer | Returns: JsonPointer path to location of given contextContext to build pointer expression for context, boolean Whether to include number offset for virtual "root context"
or not. includeRoot)Factory method that will construct a pointer instance that describes
path to location given |
| public int | |
| public String | |
| public int | |
| public JsonPointer | Returns: Pointer expression that contains same segments as this one, except for the last segment.Accessor for getting a pointer instance that is identical to this instance except that the last segment has been dropped. |
| public JsonPointer | Returns: the leaf of current JSON Pointer expression: leaf is the last non-null segment of current JSON Pointer.
|
| public int | Returns: Length of String representation of this pointer instanceFunctionally same as:
|
| public JsonPointer | Returns: Remaining path after matching specified index, if there is match;null otherwiseIndex of Array element to match index)Method that may be called to check whether the pointer head (first segment)
matches specified Array index and if so, return
|
| public boolean | |
| public boolean | Returns: True if the pointer head matches specified Array indexIndex of Array element to match index)Method that may be called to see if the pointer would match Array element (of a JSON Array) with given index. |
| public boolean | Returns: True if the pointer head matches specified property nameName of Object property to match name)Method that may be called to see if the pointer head (first segment) would match property (of a JSON Object) with given name. |
| public JsonPointer | Returns: Remaining path after matching specified property, if there is match;null otherwiseName of Object property to match name)Method that may be called to check whether the pointer head (first segment)
matches specified Object property (by name) and if so, return
|
| public boolean | Returns: True if the root selector matches element index (that is, could match an element of JSON Array node)
|
| public boolean | Returns: True if the root selector matches property name (that is, could match field value of JSON Object node)
|
| public JsonPointer | Returns: Tail of this pointer, if it has any;null if this pointer only
has the current segmentAccessor for getting a "sub-pointer" (or sub-path), instance where current segment has been removed and pointer includes rest of the segments. |
| public String | |
| public static JsonPointer | Returns: CompiledJsonPointer path expressionPointer expression to compile expr)Alias for |
| private Object |
| _asString | back to summary |
|---|---|
| protected final String _asString We will retain representation of the pointer, as a String,
so that Note starting with 2.14, there is no accompanying
| |
| _asStringOffset | back to summary |
|---|---|
protected final int _asStringOffset
| |
| _hashCode | back to summary |
|---|---|
| protected int _hashCode Lazily-calculated hash code: need to retain hash code now that we can no
longer rely on
| |
| _head | back to summary |
|---|---|
| protected volatile JsonPointer _head Reference from currently matching segment (if any) to node before leaf. Lazily constructed if/as needed. Note we'll use `volatile` here assuming that this is unlikely to become a performance bottleneck. If it becomes one we can probably just drop it and things still should work (despite warnings as per JMM regarding visibility (and lack thereof) of unguarded changes).
| |
| _matchingElementIndex | back to summary |
|---|---|
| protected final int _matchingElementIndex | |
| _matchingPropertyName | back to summary |
|---|---|
| protected final String _matchingPropertyName | |
| _nextSegment | back to summary |
|---|---|
| protected final JsonPointer _nextSegment Reference to rest of the pointer beyond currently matching segment (if any); null if this pointer refers to the matching segment. | |
| EMPTY | back to summary |
|---|---|
| protected static final JsonPointer EMPTY Marker instance used to represent segment that matches current
node or position (that is, returns true for
| |
| SEPARATOR | back to summary |
|---|---|
| public static final char SEPARATOR Character used to separate segments.
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| JsonPointer | back to summary |
|---|---|
| protected JsonPointer() Constructor used for creating "empty" instance, used to represent state that matches current node. | |
| JsonPointer | back to summary |
|---|---|
| protected JsonPointer(String fullString, int fullStringOffset, String segment, JsonPointer next) | |
| JsonPointer | back to summary |
|---|---|
| protected JsonPointer(String fullString, int fullStringOffset, String segment, int matchIndex, JsonPointer next) | |
| _appendEscape | back to summary |
|---|---|
| private static void _appendEscape(StringBuilder sb, char c) | |
| _appendEscaped | back to summary |
|---|---|
| private static void _appendEscaped(StringBuilder sb, String segment) | |
| _buildPath | back to summary |
|---|---|
| private static JsonPointer _buildPath(final String fullPath, int fullPathOffset, String segment, JsonPointer. | |
| _compare | back to summary |
|---|---|
| private final boolean _compare(String str1, int offset1, String str2, int offset2) | |
| _constructHead | back to summary |
|---|---|
| protected JsonPointer _constructHead() | |
| _constructHead | back to summary |
|---|---|
| protected JsonPointer _constructHead(int suffixLength, JsonPointer last) | |
| _extractEscapedSegment | back to summary |
|---|---|
| protected static int _extractEscapedSegment(String input, int firstCharOffset, int i, StringBuilder sb) Method called to extract the next segment of the path, in case where we seem to have encountered a (tilde-)escaped character within segment.
| |
| _parseIndex | back to summary |
|---|---|
| private static final int _parseIndex(String str) | |
| _parseTail | back to summary |
|---|---|
| protected static JsonPointer _parseTail(final String fullPath) | |
| append | back to summary |
|---|---|
| public JsonPointer append(JsonPointer tail) Mutant factory method that will return
| |
| appendIndex | back to summary |
|---|---|
| public JsonPointer appendIndex(int index) ATTENTION!
| |
| appendProperty | back to summary |
|---|---|
| public JsonPointer appendProperty(String property) ATTENTION!
| |
| compile | back to summary |
|---|---|
| public static JsonPointer compile(String expr) throws IllegalArgumentException Factory method that parses given input and construct matching pointer
instance, if it represents a valid JSON Pointer: if not, a
| |
| empty | back to summary |
|---|---|
| public static JsonPointer empty() Accessor for an "empty" expression, that is, one you can get by
calling Note this is different from expression for
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| forPath | back to summary |
|---|---|
| public static JsonPointer forPath(JsonStreamContext context, boolean includeRoot) Factory method that will construct a pointer instance that describes
path to location given
| |
| getMatchingIndex | back to summary |
|---|---|
| public int getMatchingIndex() | |
| getMatchingProperty | back to summary |
|---|---|
| public String getMatchingProperty() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| head | back to summary |
|---|---|
| public JsonPointer head() Accessor for getting a pointer instance that is identical to this
instance except that the last segment has been dropped.
For example, for JSON Pointer "/root/branch/leaf", this method would
return pointer "/root/branch" (compared to
Note that whereas
| |
| last | back to summary |
|---|---|
public JsonPointer last()
| |
| length | back to summary |
|---|---|
| public int length() Functionally same as:
| |
| matchElement | back to summary |
|---|---|
| public JsonPointer matchElement(int index) Method that may be called to check whether the pointer head (first segment)
matches specified Array index and if so, return
| |
| matches | back to summary |
|---|---|
| public boolean matches() | |
| matchesElement | back to summary |
|---|---|
| public boolean matchesElement(int index) Method that may be called to see if the pointer would match Array element (of a JSON Array) with given index.
| |
| matchesProperty | back to summary |
|---|---|
| public boolean matchesProperty(String name) Method that may be called to see if the pointer head (first segment) would match property (of a JSON Object) with given name.
| |
| matchProperty | back to summary |
|---|---|
| public JsonPointer matchProperty(String name) Method that may be called to check whether the pointer head (first segment)
matches specified Object property (by name) and if so, return
| |
| mayMatchElement | back to summary |
|---|---|
public boolean mayMatchElement()
| |
| mayMatchProperty | back to summary |
|---|---|
public boolean mayMatchProperty()
| |
| tail | back to summary |
|---|---|
| public JsonPointer tail() Accessor for getting a "sub-pointer" (or sub-path), instance where current segment
has been removed and pointer includes rest of the segments.
For example, for JSON Pointer "/root/branch/leaf", this method would
return pointer "/branch/leaf".
For matching state (last segment), will return Note that this is a very cheap method to call as it simply returns "next" segment (which has been constructed when pointer instance was constructed).
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| valueOf | back to summary |
|---|---|
| public static JsonPointer valueOf(String expr) Alias for
| |
| writeReplace | back to summary |
|---|---|
| private Object writeReplace() | |
| Modifier and Type | Field and Description |
|---|---|
| public final int | |
| public final JsonPointer. | |
| public final String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| fullPathOffset | back to summary |
|---|---|
| public final int fullPathOffset | |
| parent | back to summary |
|---|---|
| public final JsonPointer. | |
| segment | back to summary |
|---|---|
| public final String segment | |
| PointerParent | back to summary |
|---|---|
| pack-priv PointerParent(JsonPointer. | |
| Modifier and Type | Field and Description |
|---|---|
| public final int | |
| public final JsonPointer. | |
| public int | |
| public JsonPointer. | |
| public final String |
| Access | Constructor and Description |
|---|---|
| public |
| index | back to summary |
|---|---|
| public final int index | |
| next | back to summary |
|---|---|
| public final JsonPointer. | |
| pathOffset | back to summary |
|---|---|
| public int pathOffset | |
| prev | back to summary |
|---|---|
| public JsonPointer. | |
| property | back to summary |
|---|---|
| public final String property | |
| PointerSegment | back to summary |
|---|---|
| public PointerSegment(JsonPointer. | |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. |
| private Object | |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. |
| _fullPath | back to summary |
|---|---|
| private String _fullPath | |
| Serialization | back to summary |
|---|---|
| public Serialization() | |
| Serialization | back to summary |
|---|---|
| pack-priv Serialization(String fullPath) | |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() throws ObjectStreamException | |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |