public class JsonPointerImpl extends Object implements javax.json.JsonPointer
Modifier and Type | Field and Description |
---|---|
private static Pattern |
IS_NUMBER |
private String |
jsonPointer |
private String |
lastReferenceToken |
private javax.json.spi.JsonProvider |
provider |
private List<String> |
referenceTokens |
Constructor and Description |
---|
JsonPointerImpl(javax.json.spi.JsonProvider provider,
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,
List<String> currentPath) |
private <T extends javax.json.JsonStructure> |
addInternal(T jsonValue,
javax.json.JsonValue newValue) |
boolean |
containsValue(javax.json.JsonStructure target) |
boolean |
equals(Object obj)
Compares this
JsonPointer with another object. |
private int |
getArrayIndex(String referenceToken,
javax.json.JsonArray jsonArray,
boolean addOperation) |
(package private) 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,
String referenceToken,
int currentPosition,
int referencePosition) |
int |
hashCode()
Returns the hash code value for this
JsonPointer object. |
private boolean |
isEmptyJsonPointer() |
private boolean |
isPositionToAdd(List<String> currentPath) |
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,
int referencePosition) |
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 . |
private void |
validateAdd(javax.json.JsonValue target) |
private void |
validateArrayIndex(String referenceToken) |
private void |
validateArraySize(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 String jsonPointer
private final String lastReferenceToken
private static final Pattern IS_NUMBER
public JsonPointerImpl(javax.json.spi.JsonProvider provider, String jsonPointer)
jsonPointer
- the JSON Pointer stringNullPointerException
- if jsonPointer
is null
javax.json.JsonException
- if jsonPointer
is not a valid JSON Pointerpublic boolean equals(Object obj)
JsonPointer
with another object.public int hashCode()
JsonPointer
object.
The hash code of this object is defined by the hash codes of it's reference tokens.public javax.json.JsonValue getValue(javax.json.JsonStructure target)
target
getValue
in interface javax.json.JsonPointer
target
- the target referenced by this JsonPointer
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.JsonPointer
public 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.JsonPointer
target
- the target referenced by this JsonPointer
value
- the value to be addedtarget
after the value is added.NullPointerException
- if target
is null
javax.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 JsonPointer
value
- the value to be addedtarget
after the value is added.NullPointerException
- if target
is null
javax.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 JsonPointer
value
- the value to be addedtarget
after the value is added.NullPointerException
- if target
is null
javax.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.JsonPointer
target
- the target referenced by this JsonPointer
value
- the value to be stored at the referenced locationtarget
after the value is replaced.NullPointerException
- if target
is null
javax.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 JsonPointer
value
- the value to be stored at the referenced locationtarget
after the value is replaced.NullPointerException
- if target
is null
javax.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 JsonPointer
value
- the value to be stored at the referenced locationtarget
after the value is replaced.NullPointerException
- if target
is null
javax.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)
target
remove
in interface javax.json.JsonPointer
target
- the target referenced by this JsonPointer
target
after the value is removed.NullPointerException
- if target
is null
javax.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)
target
target
- the target referenced by this JsonPointer
target
after the value is removed.NullPointerException
- if target
is null
javax.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)
target
target
- the target referenced by this JsonPointer
target
after the value is removed.NullPointerException
- if target
is null
javax.json.JsonException
- if the referenced value does not exist,
or if the reference is the target.remove(JsonStructure)
String getJsonPointer()
private 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, 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, List<String> currentPath)
private javax.json.JsonValue remove(javax.json.JsonValue jsonValue, int currentPosition, int referencePosition)
private int getArrayIndex(String referenceToken, javax.json.JsonArray jsonArray, boolean addOperation)
private void validateJsonPointer(javax.json.JsonValue target, int size) throws NullPointerException, javax.json.JsonException
NullPointerException
javax.json.JsonException
private void validateArrayIndex(String referenceToken) throws javax.json.JsonException
javax.json.JsonException
private void validateArraySize(javax.json.JsonArray jsonArray, int arrayIndex, int arraySize) throws javax.json.JsonException
javax.json.JsonException
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.