public class MutableJsonPointer extends Object
// From a string. MutableJsonPointer pointer = new MutableJsonPointer("/a/b"); // Append one by one. MutableJsonPointer pointer = new MutableJsonPointer().append("a").append("b"); // Modify. MutableJsonPointer pointer = new MutableJsonPointer("/a/c").remove().append("b"); // Get reference tokens. List<String> tokens = new MutableJsonPointer("/a/b").getReferenceTokens(); // Create a JsonPointer instance from a MutableJsonPointer instance. JsonPointer pointer = Json.createPointer(new MutableJsonPointer("/a/b").toString());
| Constructor and Description |
|---|
MutableJsonPointer()
The default constructor.
|
MutableJsonPointer(MutableJsonPointer pointer)
A copy constructor.
|
MutableJsonPointer(String pointer)
A constructor that receives a JSON pointer.
|
| Modifier and Type | Method and Description |
|---|---|
MutableJsonPointer |
append(int arrayIndex)
Append a reference token.
|
MutableJsonPointer |
append(String referenceToken)
Append a reference token.
|
MutableJsonPointer |
append(String referenceToken,
boolean doEscape)
Append a reference token.
|
static String |
escape(String input)
Escape special characters in the given string according to the rules
defined in the Section 3.
|
List<String> |
getReferenceTokens()
Get the list of reference tokens.
|
MutableJsonPointer |
remove()
Remove the last reference token from the end.
|
String |
toString() |
static String |
unescape(String input)
Unescape special sequences in the given string according to the rules
defined in the Section 4.
|
public MutableJsonPointer()
public MutableJsonPointer(MutableJsonPointer pointer)
pointer - A MutableJsonPointer instance from which reference
tokens are copied.public MutableJsonPointer(String pointer)
pointer - A JSON pointer. Both null and an empty string are
accepted. They represent the whole JSON document. In other
cases, pointer must start with "/".IllegalArgumentException - pointer does not start with "/" although
it is neither null nor an empty string.public MutableJsonPointer append(String referenceToken, boolean doEscape)
referenceToken - A reference token to append.doEscape - true to make this method escape special characters in
referenceToken before the reference token is appended.
The escape(String) method is used for the escape
processing.this object.public MutableJsonPointer append(String referenceToken)
This method is an alias of append(referenceToken, true). Special characters in
referenceToken are escaped.
referenceToken - A reference token to append.this object.public MutableJsonPointer append(int arrayIndex)
arrayIndex - A reference token.this object.IllegalArgumentException - arrayIndex is less than 0.public MutableJsonPointer remove()
Even if this method is called more times than the number of reference tokens held by this instance, no exception is thrown.
this object.public List<String> getReferenceTokens()
public static String escape(String input)
To be concrete, all "~" are converted to "~0" and
then all "/" are converted to "~1".
input - A string that may contain special characters
("~" and "/").null, null is returned.public static String unescape(String input)
To be concrete, all "~1" are converted to "/" and
then all "~0" are converted to "~".
input - A string that may contain special sequences ("~0" and
"~1").null, null is returned.Copyright © 2022. All rights reserved.