Package org.glassfish.json
Class NodeReference.ArrayReference
- java.lang.Object
-
- org.glassfish.json.NodeReference
-
- org.glassfish.json.NodeReference.ArrayReference
-
- Enclosing class:
- NodeReference
static class NodeReference.ArrayReference extends NodeReference
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.glassfish.json.NodeReference
NodeReference.ArrayReference, NodeReference.ObjectReference, NodeReference.RootReference
-
-
Constructor Summary
Constructors Constructor Description ArrayReference(JsonArray array, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArray
add(JsonValue value)
Add or replace a value at the referenced location.boolean
contains()
Returntrue
if a reference points to a valid value,false
otherwise.JsonValue
get()
Get the value at the referenced location.JsonArray
remove()
Remove the name/value pair from the JSON object, or the value in a JSON array, as specified by the referenceJsonArray
replace(JsonValue value)
Replace the referenced value with the specified value.-
Methods inherited from class org.glassfish.json.NodeReference
of, of, of
-
-
-
-
Field Detail
-
array
private final JsonArray array
-
index
private final int index
-
-
Constructor Detail
-
ArrayReference
ArrayReference(JsonArray array, int index)
-
-
Method Detail
-
contains
public boolean contains()
Description copied from class:NodeReference
Returntrue
if a reference points to a valid value,false
otherwise.- Specified by:
contains
in classNodeReference
- Returns:
true
if a reference points to a value
-
get
public JsonValue get()
Description copied from class:NodeReference
Get the value at the referenced location.- Specified by:
get
in classNodeReference
- Returns:
- the JSON value referenced
-
add
public JsonArray add(JsonValue value)
Description copied from class:NodeReference
Add or replace a value at the referenced location. If the reference is the root of a JSON tree, the added value must be a JSON object or array, which becomes the referenced JSON value. If the reference is an index of a JSON array, the value is inserted into the array at the index. If the index is -1, the value is appended to the array. If the reference is a name of a JSON object, the name/value pair is added to the object, replacing any pair with the same name.- Specified by:
add
in classNodeReference
- Parameters:
value
- the value to be added- Returns:
- the JsonStructure after the operation
-
remove
public JsonArray remove()
Description copied from class:NodeReference
Remove the name/value pair from the JSON object, or the value in a JSON array, as specified by the reference- Specified by:
remove
in classNodeReference
- Returns:
- the JsonStructure after the operation
-
replace
public JsonArray replace(JsonValue value)
Description copied from class:NodeReference
Replace the referenced value with the specified value.- Specified by:
replace
in classNodeReference
- Parameters:
value
- the JSON value to be stored at the referenced location- Returns:
- the JsonStructure after the operation
-
-