- java.lang.Object
- 
- org.apache.johnzon.core.JsonPointerImpl
 
- 
- All Implemented Interfaces:
- jakarta.json.JsonPointer
 
 public class JsonPointerImpl extends java.lang.Object implements jakarta.json.JsonPointer
- 
- 
Field SummaryFields Modifier and Type Field Description private static java.util.regex.PatternIS_NUMBERprivate java.lang.StringjsonPointerprivate jakarta.json.spi.JsonProviderproviderprivate java.util.List<java.lang.String>referenceTokens
 - 
Constructor SummaryConstructors Constructor Description JsonPointerImpl(jakarta.json.spi.JsonProvider provider, java.lang.String jsonPointer)Constructs and initializes a JsonPointer.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.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.private jakarta.json.JsonValueaddInternal(jakarta.json.JsonValue jsonValue, jakarta.json.JsonValue newValue, java.util.List<java.lang.String> currentPath, boolean check)private <T extends jakarta.json.JsonStructure>
 TaddInternal(T jsonValue, jakarta.json.JsonValue newValue)private booleancanMatch(java.util.List<java.lang.String> currentPath)booleancontainsValue(jakarta.json.JsonStructure target)booleanequals(java.lang.Object obj)Compares thisJsonPointerwith another object.private intgetArrayIndex(java.lang.String referenceToken, jakarta.json.JsonArray jsonArray, boolean addOperation)(package private) java.lang.StringgetJsonPointer()jakarta.json.JsonValuegetValue(jakarta.json.JsonStructure target)Returns the value at the referenced location in the specifiedtargetprivate jakarta.json.JsonValuegetValue(jakarta.json.JsonValue jsonValue, java.lang.String referenceToken, int currentPosition, int referencePosition)inthashCode()Returns the hash code value for thisJsonPointerobject.private booleanisEmptyJsonPointer()private booleanisPositionToAdd(java.util.List<java.lang.String> currentPath)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 specifiedtargetprivate jakarta.json.JsonValueremove(jakarta.json.JsonValue jsonValue, int currentPosition)jakarta.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.java.lang.StringtoString()private voidvalidateAdd(jakarta.json.JsonValue target)private voidvalidateArrayIndex(java.lang.String referenceToken)private voidvalidateArraySize(java.lang.String referenceToken, jakarta.json.JsonArray jsonArray, int arrayIndex, int arraySize)private voidvalidateJsonPointer(jakarta.json.JsonValue target, int size)private voidvalidateRemove(jakarta.json.JsonValue target)
 
- 
- 
- 
Constructor Detail- 
JsonPointerImplpublic JsonPointerImpl(jakarta.json.spi.JsonProvider provider, java.lang.String jsonPointer)Constructs and initializes a JsonPointer.- Parameters:
- provider- the JSON provider used to create this pointer
- jsonPointer- the JSON Pointer string
- Throws:
- java.lang.NullPointerException- if- jsonPointeris- null
- jakarta.json.JsonException- if- jsonPointeris not a valid JSON Pointer
 
 
- 
 - 
Method Detail- 
equalspublic boolean equals(java.lang.Object obj) Compares thisJsonPointerwith another object.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- obj- the object to compare this- JsonPointeragainst
- Returns:
- true if the given object is a JsonPointerwith the same reference tokens as this one, false otherwise.
 
 - 
hashCodepublic 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.- Overrides:
- hashCodein class- java.lang.Object
- Returns:
- the hash code value for this JsonPointerobject
 
 - 
getValuepublic jakarta.json.JsonValue getValue(jakarta.json.JsonStructure target) Returns the value at the referenced location in the specifiedtarget- Specified by:
- getValuein interface- jakarta.json.JsonPointer
- Parameters:
- target- the target referenced by this- JsonPointer
- Returns:
- the referenced value in the target.
- Throws:
- java.lang.NullPointerException- if- targetis null
- jakarta.json.JsonException- if the referenced value does not exist
 
 - 
containsValuepublic boolean containsValue(jakarta.json.JsonStructure target) - Specified by:
- containsValuein interface- jakarta.json.JsonPointer
 
 - 
addpublic 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 interface- jakarta.json.JsonPointer
- Parameters:
- target- the target referenced by this- JsonPointer
- value- the value to be added
- Returns:
- the transformed targetafter the value is added.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.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 
 - 
addpublic 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 this- JsonPointer
- value- the value to be added
- Returns:
- the transformed targetafter the value is added.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.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(JsonStructure, JsonValue)
 
 - 
addpublic 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 this- JsonPointer
- value- the value to be added
- Returns:
- the transformed targetafter the value is added.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.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(JsonStructure, JsonValue)
 
 - 
replacepublic 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 interface- jakarta.json.JsonPointer
- Parameters:
- target- the target referenced by this- JsonPointer
- value- the value to be stored at the referenced location
- Returns:
- the transformed targetafter the value is replaced.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
 
 - 
replacepublic 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 this- JsonPointer
- value- the value to be stored at the referenced location
- Returns:
- the transformed targetafter the value is replaced.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
- See Also:
- replace(JsonStructure, JsonValue)
 
 - 
replacepublic 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 this- JsonPointer
- value- the value to be stored at the referenced location
- Returns:
- the transformed targetafter the value is replaced.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
- See Also:
- replace(JsonStructure, JsonValue)
 
 - 
removepublic jakarta.json.JsonStructure remove(jakarta.json.JsonStructure target) Removes the value at the reference location in the specifiedtarget- Specified by:
- removein interface- jakarta.json.JsonPointer
- Parameters:
- target- the target referenced by this- JsonPointer
- Returns:
- the transformed targetafter the value is removed.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
 
 - 
removepublic jakarta.json.JsonObject remove(jakarta.json.JsonObject target) Removes the value at the reference location in the specifiedtarget- Parameters:
- target- the target referenced by this- JsonPointer
- Returns:
- the transformed targetafter the value is removed.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
- See Also:
- remove(JsonStructure)
 
 - 
removepublic jakarta.json.JsonArray remove(jakarta.json.JsonArray target) Removes the value at the reference location in the specifiedtarget- Parameters:
- target- the target referenced by this- JsonPointer
- Returns:
- the transformed targetafter the value is removed.
- Throws:
- java.lang.NullPointerException- if- targetis- null
- jakarta.json.JsonException- if the referenced value does not exist, or if the reference is the target.
- See Also:
- remove(JsonStructure)
 
 - 
getJsonPointerjava.lang.String getJsonPointer() 
 - 
toStringpublic java.lang.String toString() - Specified by:
- toStringin interface- jakarta.json.JsonPointer
- Overrides:
- toStringin class- java.lang.Object
 
 - 
validateAddprivate void validateAdd(jakarta.json.JsonValue target) 
 - 
validateRemoveprivate void validateRemove(jakarta.json.JsonValue target) 
 - 
isEmptyJsonPointerprivate boolean isEmptyJsonPointer() 
 - 
getValueprivate jakarta.json.JsonValue getValue(jakarta.json.JsonValue jsonValue, java.lang.String referenceToken, int currentPosition, int referencePosition)
 - 
addInternalprivate <T extends jakarta.json.JsonStructure> T addInternal(T jsonValue, jakarta.json.JsonValue newValue)
 - 
addInternalprivate jakarta.json.JsonValue addInternal(jakarta.json.JsonValue jsonValue, jakarta.json.JsonValue newValue, java.util.List<java.lang.String> currentPath, boolean check)
 - 
isPositionToAddprivate boolean isPositionToAdd(java.util.List<java.lang.String> currentPath) 
 - 
canMatchprivate boolean canMatch(java.util.List<java.lang.String> currentPath) 
 - 
removeprivate jakarta.json.JsonValue remove(jakarta.json.JsonValue jsonValue, int currentPosition)
 - 
getArrayIndexprivate int getArrayIndex(java.lang.String referenceToken, jakarta.json.JsonArray jsonArray, boolean addOperation)
 - 
validateJsonPointerprivate void validateJsonPointer(jakarta.json.JsonValue target, int size) throws java.lang.NullPointerException, jakarta.json.JsonException- Throws:
- java.lang.NullPointerException
- jakarta.json.JsonException
 
 - 
validateArrayIndexprivate void validateArrayIndex(java.lang.String referenceToken) throws jakarta.json.JsonException- Throws:
- jakarta.json.JsonException
 
 - 
validateArraySizeprivate void validateArraySize(java.lang.String referenceToken, jakarta.json.JsonArray jsonArray, int arrayIndex, int arraySize) throws jakarta.json.JsonException- Throws:
- jakarta.json.JsonException
 
 
- 
 
-