Package org.apache.johnzon.core
Class JsonPointerImpl
java.lang.Object
org.apache.johnzon.core.JsonPointerImpl
- All Implemented Interfaces:
jakarta.json.JsonPointer
-
Constructor Summary
ConstructorsConstructorDescriptionJsonPointerImpl(jakarta.json.spi.JsonProvider provider, String jsonPointer) Constructs and initializes a JsonPointer. -
Method Summary
Modifier and TypeMethodDescriptionjakarta.json.JsonArrayadd(jakarta.json.JsonArray target, jakarta.json.JsonValue value) Adds or replaces a value at the referenced location in the specifiedtargetwith the specifiedvalue.jakarta.json.JsonObjectadd(jakarta.json.JsonObject target, jakarta.json.JsonValue value) Adds or replaces a value at the referenced location in the specifiedtargetwith the specifiedvalue.jakarta.json.JsonStructureadd(jakarta.json.JsonStructure target, jakarta.json.JsonValue value) Adds or replaces a value at the referenced location in the specifiedtargetwith the specifiedvalue.booleancontainsValue(jakarta.json.JsonStructure target) booleanCompares thisJsonPointerwith another object.jakarta.json.JsonValuegetValue(jakarta.json.JsonStructure target) Returns the value at the referenced location in the specifiedtargetinthashCode()Returns the hash code value for thisJsonPointerobject.jakarta.json.JsonArrayremove(jakarta.json.JsonArray target) Removes the value at the reference location in the specifiedtargetjakarta.json.JsonObjectremove(jakarta.json.JsonObject target) Removes the value at the reference location in the specifiedtargetjakarta.json.JsonStructureremove(jakarta.json.JsonStructure target) Removes the value at the reference location in the specifiedtargetjakarta.json.JsonArrayreplace(jakarta.json.JsonArray target, jakarta.json.JsonValue value) Replaces the value at the referenced location in the specifiedjakarta.json.JsonObjectreplace(jakarta.json.JsonObject target, jakarta.json.JsonValue value) Replaces the value at the referenced location in the specifiedjakarta.json.JsonStructurereplace(jakarta.json.JsonStructure target, jakarta.json.JsonValue value) Replaces the value at the referenced location in the specifiedtargetwith the specifiedvalue.toString()
-
Constructor Details
-
JsonPointerImpl
Constructs and initializes a JsonPointer.- Parameters:
provider- the JSON provider used to create this pointerjsonPointer- the JSON Pointer string- Throws:
NullPointerException- ifjsonPointerisnulljakarta.json.JsonException- ifjsonPointeris not a valid JSON Pointer
-
-
Method Details
-
equals
Compares thisJsonPointerwith another object. -
hashCode
public int hashCode()Returns the hash code value for thisJsonPointerobject. The hash code of this object is defined by the hash codes of it's reference tokens. -
getValue
public jakarta.json.JsonValue getValue(jakarta.json.JsonStructure target) Returns the value at the referenced location in the specifiedtarget- Specified by:
getValuein interfacejakarta.json.JsonPointer- Parameters:
target- the target referenced by thisJsonPointer- Returns:
- the referenced value in the target.
- Throws:
NullPointerException- iftargetis nulljakarta.json.JsonException- if the referenced value does not exist
-
containsValue
public boolean containsValue(jakarta.json.JsonStructure target) - Specified by:
containsValuein interfacejakarta.json.JsonPointer
-
add
public jakarta.json.JsonStructure add(jakarta.json.JsonStructure target, jakarta.json.JsonValue value) Adds or replaces a value at the referenced location in the specifiedtargetwith the specifiedvalue.- If the reference is the target (empty JSON Pointer string),
the specified
value, which must be the same type as specifiedtarget, is returned. - If the reference is an array element, the specified
valueis 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. - If the reference is a name/value pair of a
JsonObject, and the referenced value exists, the value is replaced by the specifiedvalue. If the value does not exist, a new name/value pair is added to the object.
- Specified by:
addin interfacejakarta.json.JsonPointer- Parameters:
target- the target referenced by thisJsonPointervalue- the value to be added- Returns:
- the transformed
targetafter the value is added. - Throws:
NullPointerException- iftargetisnulljakarta.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.
- If the reference is the target (empty JSON Pointer string),
the specified
-
add
public jakarta.json.JsonObject add(jakarta.json.JsonObject target, jakarta.json.JsonValue value) Adds or replaces a value at the referenced location in the specifiedtargetwith the specifiedvalue.- Parameters:
target- the target referenced by thisJsonPointervalue- the value to be added- Returns:
- the transformed
targetafter the value is added. - Throws:
NullPointerException- iftargetisnulljakarta.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.- See Also:
-
add
public jakarta.json.JsonArray add(jakarta.json.JsonArray target, jakarta.json.JsonValue value) Adds or replaces a value at the referenced location in the specifiedtargetwith the specifiedvalue.- Parameters:
target- the target referenced by thisJsonPointervalue- the value to be added- Returns:
- the transformed
targetafter the value is added. - Throws:
NullPointerException- iftargetisnulljakarta.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.- See Also:
-
replace
public jakarta.json.JsonStructure replace(jakarta.json.JsonStructure target, jakarta.json.JsonValue value) Replaces the value at the referenced location in the specifiedtargetwith the specifiedvalue.- Specified by:
replacein interfacejakarta.json.JsonPointer- Parameters:
target- the target referenced by thisJsonPointervalue- the value to be stored at the referenced location- Returns:
- the transformed
targetafter the value is replaced. - Throws:
NullPointerException- iftargetisnulljakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
-
replace
public jakarta.json.JsonObject replace(jakarta.json.JsonObject target, jakarta.json.JsonValue value) Replaces the value at the referenced location in the specified- Parameters:
target- the target referenced by thisJsonPointervalue- the value to be stored at the referenced location- Returns:
- the transformed
targetafter the value is replaced. - Throws:
NullPointerException- iftargetisnulljakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.- See Also:
-
replace
public jakarta.json.JsonArray replace(jakarta.json.JsonArray target, jakarta.json.JsonValue value) Replaces the value at the referenced location in the specified- Parameters:
target- the target referenced by thisJsonPointervalue- the value to be stored at the referenced location- Returns:
- the transformed
targetafter the value is replaced. - Throws:
NullPointerException- iftargetisnulljakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.- See Also:
-
remove
public jakarta.json.JsonStructure remove(jakarta.json.JsonStructure target) Removes the value at the reference location in the specifiedtarget- Specified by:
removein interfacejakarta.json.JsonPointer- Parameters:
target- the target referenced by thisJsonPointer- Returns:
- the transformed
targetafter the value is removed. - Throws:
NullPointerException- iftargetisnulljakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
-
remove
public jakarta.json.JsonObject remove(jakarta.json.JsonObject target) Removes the value at the reference location in the specifiedtarget- Parameters:
target- the target referenced by thisJsonPointer- Returns:
- the transformed
targetafter the value is removed. - Throws:
NullPointerException- iftargetisnulljakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.- See Also:
-
remove
public jakarta.json.JsonArray remove(jakarta.json.JsonArray target) Removes the value at the reference location in the specifiedtarget- Parameters:
target- the target referenced by thisJsonPointer- Returns:
- the transformed
targetafter the value is removed. - Throws:
NullPointerException- iftargetisnulljakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.- See Also:
-
toString
-