Modifier and Type | Method and Description |
---|---|
Node |
addValue(Node container,
Node value)
Adds or replaces a
value in container at the
JSON pointer location. |
Node |
addWithIntermediateValues(Node container,
Node value)
Adds or replaces a
value in container at the
JSON pointer location. |
boolean |
equals(java.lang.Object other) |
java.util.List<java.lang.String> |
getParts()
Gets the parsed parts of the pointer.
|
Node |
getValue(Node container)
Gets a value from a container shape at the pointer location.
|
int |
hashCode() |
static NodePointer |
parse(java.lang.String pointer)
Parses a JSON pointer.
|
java.lang.String |
toString() |
static java.lang.String |
unescape(java.lang.String pointerPart)
Unescapes special JSON pointer cases.
|
public static java.lang.String unescape(java.lang.String pointerPart)
pointerPart
- Pointer to unescape.public static NodePointer parse(java.lang.String pointer)
A JSON pointer that starts with "#/" is treated as "/". JSON pointers must start with "#/" or "/" to be parsed correctly.
pointer
- JSON pointer to parse.java.lang.IllegalArgumentException
- if the pointer does not start with slash (/).public java.util.List<java.lang.String> getParts()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public Node getValue(Node container)
When the pointer is "", then provided value is returned. When
the pointer is "/", a root object key value of "" is returned. When
an invalid property or array index is accessed, a NullNode
is returned. "-" can be used to access the last element of an array.
Any error like accessing an object key from an array or attempting
to access an invalid array index will return a NullNode
.
container
- Node value container to extract a value from.NullNode
if not found.public Node addValue(Node container, Node value)
value
in container
at the
JSON pointer location.
When the JSON pointer is "", the entire document is replaced with the
given value
. "-" can be used to access the last element of an array
or to add an element to the end of an array. Any error like adding
an object key to an array or attempting to access an invalid array
segment will log a warning and return the given value as-is.
container
- Node to update.value
- Value to update or replace.container
with the updated value.public Node addWithIntermediateValues(Node container, Node value)
value
in container
at the
JSON pointer location.
When the JSON pointer is "", the entire document is replaced with the
given value
. "-" can be used to access the last element of an array
or to add an element to the end of an array. Unlike addValue(Node, Node)
,
attempting to add a property to a non-existent object will create a
new object and continue adding to the created result.
container
- Node to update.value
- Value to update or replace.container
with the updated value.