public class JsonPointerImpl
extends java.lang.Object
implements javax.json.JsonPointer
| Modifier and Type | Field and Description |
|---|---|
private static java.util.regex.Pattern |
IS_NUMBER |
private java.lang.String |
jsonPointer |
private javax.json.spi.JsonProvider |
provider |
private java.util.List<java.lang.String> |
referenceTokens |
| Constructor and Description |
|---|
JsonPointerImpl(javax.json.spi.JsonProvider provider,
java.lang.String jsonPointer)
Constructs and initializes a JsonPointer.
|
| Modifier and Type | Method and Description |
|---|---|
javax.json.JsonArray |
add(javax.json.JsonArray target,
javax.json.JsonValue value)
Adds or replaces a value at the referenced location in the specified
target with the specified value. |
javax.json.JsonObject |
add(javax.json.JsonObject target,
javax.json.JsonValue value)
Adds or replaces a value at the referenced location in the specified
target with the specified value. |
javax.json.JsonStructure |
add(javax.json.JsonStructure target,
javax.json.JsonValue value)
Adds or replaces a value at the referenced location in the specified
target with the specified value. |
private javax.json.JsonValue |
addInternal(javax.json.JsonValue jsonValue,
javax.json.JsonValue newValue,
java.util.List<java.lang.String> currentPath,
boolean check) |
private <T extends javax.json.JsonStructure> |
addInternal(T jsonValue,
javax.json.JsonValue newValue) |
private boolean |
canMatch(java.util.List<java.lang.String> currentPath) |
boolean |
containsValue(javax.json.JsonStructure target) |
boolean |
equals(java.lang.Object obj)
Compares this
JsonPointer with another object. |
private int |
getArrayIndex(java.lang.String referenceToken,
javax.json.JsonArray jsonArray,
boolean addOperation) |
(package private) java.lang.String |
getJsonPointer() |
javax.json.JsonValue |
getValue(javax.json.JsonStructure target)
Returns the value at the referenced location in the specified
target |
private javax.json.JsonValue |
getValue(javax.json.JsonValue jsonValue,
java.lang.String referenceToken,
int currentPosition,
int referencePosition) |
int |
hashCode()
Returns the hash code value for this
JsonPointer object. |
private boolean |
isEmptyJsonPointer() |
private boolean |
isPositionToAdd(java.util.List<java.lang.String> currentPath) |
protected int |
minusShift()
This method can be overridden in sub classes.
|
javax.json.JsonArray |
remove(javax.json.JsonArray target)
Removes the value at the reference location in the specified
target |
javax.json.JsonObject |
remove(javax.json.JsonObject target)
Removes the value at the reference location in the specified
target |
javax.json.JsonStructure |
remove(javax.json.JsonStructure target)
Removes the value at the reference location in the specified
target |
private javax.json.JsonValue |
remove(javax.json.JsonValue jsonValue,
int currentPosition) |
javax.json.JsonArray |
replace(javax.json.JsonArray target,
javax.json.JsonValue value)
Replaces the value at the referenced location in the specified
|
javax.json.JsonObject |
replace(javax.json.JsonObject target,
javax.json.JsonValue value)
Replaces the value at the referenced location in the specified
|
javax.json.JsonStructure |
replace(javax.json.JsonStructure target,
javax.json.JsonValue value)
Replaces the value at the referenced location in the specified
target with the specified value. |
java.lang.String |
toString() |
private void |
validateAdd(javax.json.JsonValue target) |
private void |
validateArrayIndex(java.lang.String referenceToken) |
private void |
validateArraySize(java.lang.String referenceToken,
javax.json.JsonArray jsonArray,
int arrayIndex,
int arraySize) |
private void |
validateJsonPointer(javax.json.JsonValue target,
int size) |
private void |
validateRemove(javax.json.JsonValue target) |
private final javax.json.spi.JsonProvider provider
private final java.lang.String jsonPointer
private final java.util.List<java.lang.String> referenceTokens
private static final java.util.regex.Pattern IS_NUMBER
public JsonPointerImpl(javax.json.spi.JsonProvider provider,
java.lang.String jsonPointer)
provider - the JSON provider used to create this pointerjsonPointer - the JSON Pointer stringjava.lang.NullPointerException - if jsonPointer is nulljavax.json.JsonException - if jsonPointer is not a valid JSON Pointerpublic boolean equals(java.lang.Object obj)
JsonPointer with another object.equals in class java.lang.Objectobj - the object to compare this JsonPointer againstJsonPointer with the same
reference tokens as this one, false otherwise.public int hashCode()
JsonPointer object.
The hash code of this object is defined by the hash codes of it's reference tokens.hashCode in class java.lang.ObjectJsonPointer objectpublic javax.json.JsonValue getValue(javax.json.JsonStructure target)
targetgetValue in interface javax.json.JsonPointertarget - the target referenced by this JsonPointerjava.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not existpublic boolean containsValue(javax.json.JsonStructure target)
containsValue in interface javax.json.JsonPointerpublic javax.json.JsonStructure add(javax.json.JsonStructure target,
javax.json.JsonValue value)
target with the specified value.
value, which must be the same type as
specified target, is returned.value is inserted
into the array, at the referenced index. The value currently at that location, and
any subsequent values, are shifted to the right (adds one to the indices).
Index starts with 0. If the reference is specified with a "-", or if the
index is equal to the size of the array, the value is appended to the array.JsonObject, and the
referenced value exists, the value is replaced by the specified value.
If the value does not exist, a new name/value pair is added to the object.add in interface javax.json.JsonPointertarget - the target referenced by this JsonPointervalue - the value to be addedtarget after the value is added.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the reference is an array element and
the index is out of range (index < 0 || index > array size),
or if the pointer contains references to non-existing objects or arrays.public javax.json.JsonObject add(javax.json.JsonObject target,
javax.json.JsonValue value)
target with the specified value.target - the target referenced by this JsonPointervalue - the value to be addedtarget after the value is added.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the reference is an array element and
the index is out of range (index < 0 || index > array size),
or if the pointer contains references to non-existing objects or arrays.add(JsonStructure, JsonValue)public javax.json.JsonArray add(javax.json.JsonArray target,
javax.json.JsonValue value)
target with the specified value.target - the target referenced by this JsonPointervalue - the value to be addedtarget after the value is added.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the reference is an array element and
the index is out of range (index < 0 || index > array size),
or if the pointer contains references to non-existing objects or arrays.add(JsonStructure, JsonValue)public javax.json.JsonStructure replace(javax.json.JsonStructure target,
javax.json.JsonValue value)
target with the specified value.replace in interface javax.json.JsonPointertarget - the target referenced by this JsonPointervalue - the value to be stored at the referenced locationtarget after the value is replaced.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not exist,
or if the reference is the target.public javax.json.JsonObject replace(javax.json.JsonObject target,
javax.json.JsonValue value)
target - the target referenced by this JsonPointervalue - the value to be stored at the referenced locationtarget after the value is replaced.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not exist,
or if the reference is the target.replace(JsonStructure, JsonValue)public javax.json.JsonArray replace(javax.json.JsonArray target,
javax.json.JsonValue value)
target - the target referenced by this JsonPointervalue - the value to be stored at the referenced locationtarget after the value is replaced.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not exist,
or if the reference is the target.replace(JsonStructure, JsonValue)public javax.json.JsonStructure remove(javax.json.JsonStructure target)
targetremove in interface javax.json.JsonPointertarget - the target referenced by this JsonPointertarget after the value is removed.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not exist,
or if the reference is the target.public javax.json.JsonObject remove(javax.json.JsonObject target)
targettarget - the target referenced by this JsonPointertarget after the value is removed.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not exist,
or if the reference is the target.remove(JsonStructure)public javax.json.JsonArray remove(javax.json.JsonArray target)
targettarget - the target referenced by this JsonPointertarget after the value is removed.java.lang.NullPointerException - if target is nulljavax.json.JsonException - if the referenced value does not exist,
or if the reference is the target.remove(JsonStructure)java.lang.String getJsonPointer()
public java.lang.String toString()
toString in class java.lang.Objectprivate void validateAdd(javax.json.JsonValue target)
private void validateRemove(javax.json.JsonValue target)
private boolean isEmptyJsonPointer()
private javax.json.JsonValue getValue(javax.json.JsonValue jsonValue,
java.lang.String referenceToken,
int currentPosition,
int referencePosition)
private <T extends javax.json.JsonStructure> T addInternal(T jsonValue,
javax.json.JsonValue newValue)
private javax.json.JsonValue addInternal(javax.json.JsonValue jsonValue,
javax.json.JsonValue newValue,
java.util.List<java.lang.String> currentPath,
boolean check)
private boolean isPositionToAdd(java.util.List<java.lang.String> currentPath)
private boolean canMatch(java.util.List<java.lang.String> currentPath)
private javax.json.JsonValue remove(javax.json.JsonValue jsonValue,
int currentPosition)
private int getArrayIndex(java.lang.String referenceToken,
javax.json.JsonArray jsonArray,
boolean addOperation)
protected int minusShift()
private void validateJsonPointer(javax.json.JsonValue target,
int size)
throws java.lang.NullPointerException,
javax.json.JsonException
java.lang.NullPointerExceptionjavax.json.JsonExceptionprivate void validateArrayIndex(java.lang.String referenceToken)
throws javax.json.JsonException
javax.json.JsonExceptionprivate void validateArraySize(java.lang.String referenceToken,
javax.json.JsonArray jsonArray,
int arrayIndex,
int arraySize)
throws javax.json.JsonException
javax.json.JsonExceptionCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.