Package org.glassfish.json
Class JsonArrayBuilderImpl
- java.lang.Object
-
- org.glassfish.json.JsonArrayBuilderImpl
-
- All Implemented Interfaces:
JsonArrayBuilder
class JsonArrayBuilderImpl extends java.lang.Object implements JsonArrayBuilder
JsonArrayBuilder implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JsonArrayBuilderImpl.JsonArrayImpl
-
Field Summary
Fields Modifier and Type Field Description private BufferPool
bufferPool
private java.util.ArrayList<JsonValue>
valueList
-
Constructor Summary
Constructors Constructor Description JsonArrayBuilderImpl(java.util.Collection<?> collection, BufferPool bufferPool)
JsonArrayBuilderImpl(JsonArray array, BufferPool bufferPool)
JsonArrayBuilderImpl(BufferPool bufferPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonArrayBuilder
add(boolean value)
Adds aJsonValue.TRUE
orJsonValue.FALSE
value to the array.JsonArrayBuilder
add(double value)
Adds a value to the array as aJsonNumber
.JsonArrayBuilder
add(int value)
Adds a value to the array as aJsonNumber
.JsonArrayBuilder
add(int index, boolean value)
Adds aJsonValue.TRUE
orJsonValue.FALSE
value to the array at the specified position.JsonArrayBuilder
add(int index, double value)
Adds a value to the array as aJsonNumber
at the specified position.JsonArrayBuilder
add(int index, int value)
Adds a value to the array as aJsonNumber
at the specified position.JsonArrayBuilder
add(int index, long value)
Adds a value to the array as aJsonNumber
at the specified position.JsonArrayBuilder
add(int index, java.lang.String value)
Adds a value to the array as aJsonString
at the specified position.JsonArrayBuilder
add(int index, java.math.BigDecimal value)
Adds a value to the array as aJsonNumber
at the specified position.JsonArrayBuilder
add(int index, java.math.BigInteger value)
Adds a value to the array as aJsonNumber
at the specified position.JsonArrayBuilder
add(int index, JsonArrayBuilder builder)
Adds aJsonArray
from an array builder to the array at the specified position.JsonArrayBuilder
add(int index, JsonObjectBuilder builder)
Adds aJsonObject
from an object builder to the array at the specified position.JsonArrayBuilder
add(int index, JsonValue value)
Inserts a value to the array at the specified position.JsonArrayBuilder
add(long value)
Adds a value to the array as aJsonNumber
.JsonArrayBuilder
add(java.lang.String value)
Adds a value to the array as aJsonString
.JsonArrayBuilder
add(java.math.BigDecimal value)
Adds a value to the array as aJsonNumber
.JsonArrayBuilder
add(java.math.BigInteger value)
Adds a value to the array as aJsonNumber
.JsonArrayBuilder
add(JsonArrayBuilder builder)
Adds aJsonArray
from an array builder to the array.JsonArrayBuilder
add(JsonObjectBuilder builder)
Adds aJsonObject
from an object builder to the array.JsonArrayBuilder
add(JsonValue value)
Adds a value to the array.JsonArrayBuilder
addAll(JsonArrayBuilder builder)
Adds all elements of the array in the specified array builder to the array.JsonArrayBuilder
addNull()
Adds aJsonValue.NULL
value to the array.JsonArrayBuilder
addNull(int index)
Adds aJsonValue.NULL
value to the array at the specified position.private void
addValueList(int index, JsonValue value)
private void
addValueList(JsonValue value)
JsonArray
build()
Returns the current array.private void
populate(java.util.Collection<?> collection)
JsonArrayBuilder
remove(int index)
Remove the value in the array at the specified position.JsonArrayBuilder
set(int index, boolean value)
Replaces a value in the array with aJsonValue.TRUE
orJsonValue.FALSE
value at the specified position.JsonArrayBuilder
set(int index, double value)
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.JsonArrayBuilder
set(int index, int value)
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.JsonArrayBuilder
set(int index, long value)
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.JsonArrayBuilder
set(int index, java.lang.String value)
Replaces a value in the array with the specified value as aJsonString
at the specified position.JsonArrayBuilder
set(int index, java.math.BigDecimal value)
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.JsonArrayBuilder
set(int index, java.math.BigInteger value)
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.JsonArrayBuilder
set(int index, JsonArrayBuilder builder)
Replaces a value in the array with the specified value as aJsonArray
from an array builder at the specified position.JsonArrayBuilder
set(int index, JsonObjectBuilder builder)
Replaces a value in the array with the specified value as aJsonObject
from an object builder at the specified position.JsonArrayBuilder
set(int index, JsonValue value)
Replaces a value in the array with the specified value at the specified position.JsonArrayBuilder
setNull(int index)
Replaces a value in the array with aJsonValue.NULL
value at the specified position.private void
setValueList(int index, JsonValue value)
private void
validateValue(java.lang.Object value)
-
-
-
Field Detail
-
valueList
private java.util.ArrayList<JsonValue> valueList
-
bufferPool
private final BufferPool bufferPool
-
-
Constructor Detail
-
JsonArrayBuilderImpl
JsonArrayBuilderImpl(BufferPool bufferPool)
-
JsonArrayBuilderImpl
JsonArrayBuilderImpl(JsonArray array, BufferPool bufferPool)
-
JsonArrayBuilderImpl
JsonArrayBuilderImpl(java.util.Collection<?> collection, BufferPool bufferPool)
-
-
Method Detail
-
add
public JsonArrayBuilder add(JsonValue value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the JSON value- Returns:
- this array builder
-
add
public JsonArrayBuilder add(java.lang.String value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonString
.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the string value- Returns:
- this array builder
-
add
public JsonArrayBuilder add(java.math.BigDecimal value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(java.math.BigInteger value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(long value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(double value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(boolean value)
Description copied from interface:JsonArrayBuilder
Adds aJsonValue.TRUE
orJsonValue.FALSE
value to the array.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
value
- the boolean value- Returns:
- this array builder
-
addNull
public JsonArrayBuilder addNull()
Description copied from interface:JsonArrayBuilder
Adds aJsonValue.NULL
value to the array.- Specified by:
addNull
in interfaceJsonArrayBuilder
- Returns:
- this array builder
-
add
public JsonArrayBuilder add(JsonObjectBuilder builder)
Description copied from interface:JsonArrayBuilder
Adds aJsonObject
from an object builder to the array.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
builder
- the object builder- Returns:
- this array builder
-
add
public JsonArrayBuilder add(JsonArrayBuilder builder)
Description copied from interface:JsonArrayBuilder
Adds aJsonArray
from an array builder to the array.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
builder
- the array builder- Returns:
- this array builder
-
addAll
public JsonArrayBuilder addAll(JsonArrayBuilder builder)
Description copied from interface:JsonArrayBuilder
Adds all elements of the array in the specified array builder to the array.- Specified by:
addAll
in interfaceJsonArrayBuilder
- Parameters:
builder
- the array builder- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, JsonValue value)
Description copied from interface:JsonArrayBuilder
Inserts a value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the JSON value- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, java.lang.String value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonString
at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the string value- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, java.math.BigDecimal value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int index, java.math.BigInteger value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int index, int value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int index, long value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int index, double value)
Description copied from interface:JsonArrayBuilder
Adds a value to the array as aJsonNumber
at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int index, boolean value)
Description copied from interface:JsonArrayBuilder
Adds aJsonValue.TRUE
orJsonValue.FALSE
value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the boolean value- Returns:
- this array builder
-
addNull
public JsonArrayBuilder addNull(int index)
Description copied from interface:JsonArrayBuilder
Adds aJsonValue.NULL
value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
addNull
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the array- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, JsonObjectBuilder builder)
Description copied from interface:JsonArrayBuilder
Adds aJsonObject
from an object builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arraybuilder
- the object builder- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, JsonArrayBuilder builder)
Description copied from interface:JsonArrayBuilder
Adds aJsonArray
from an array builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.- Specified by:
add
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arraybuilder
- the array builder- Returns:
- this array builder
-
set
public JsonArrayBuilder set(int index, JsonValue value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the JSON value- Returns:
- this array builder
-
set
public JsonArrayBuilder set(int index, java.lang.String value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonString
at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the string value- Returns:
- this array builder
-
set
public JsonArrayBuilder set(int index, java.math.BigDecimal value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
set
public JsonArrayBuilder set(int index, java.math.BigInteger value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
set
public JsonArrayBuilder set(int index, int value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
set
public JsonArrayBuilder set(int index, long value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
set
public JsonArrayBuilder set(int index, double value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonNumber
at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
set
public JsonArrayBuilder set(int index, boolean value)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with aJsonValue.TRUE
orJsonValue.FALSE
value at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arrayvalue
- the boolean value- Returns:
- this array builder
-
setNull
public JsonArrayBuilder setNull(int index)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with aJsonValue.NULL
value at the specified position.- Specified by:
setNull
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the array- Returns:
- this array builder
-
set
public JsonArrayBuilder set(int index, JsonObjectBuilder builder)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonObject
from an object builder at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arraybuilder
- the object builder- Returns:
- this array builder
-
set
public JsonArrayBuilder set(int index, JsonArrayBuilder builder)
Description copied from interface:JsonArrayBuilder
Replaces a value in the array with the specified value as aJsonArray
from an array builder at the specified position.- Specified by:
set
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the arraybuilder
- the array builder- Returns:
- this array builder
-
remove
public JsonArrayBuilder remove(int index)
Description copied from interface:JsonArrayBuilder
Remove the value in the array at the specified position. Shift any subsequent values to the left (subtracts one from their indices.- Specified by:
remove
in interfaceJsonArrayBuilder
- Parameters:
index
- the position in the array- Returns:
- this array builder
-
build
public JsonArray build()
Description copied from interface:JsonArrayBuilder
Returns the current array.- Specified by:
build
in interfaceJsonArrayBuilder
- Returns:
- the current JSON array
-
populate
private void populate(java.util.Collection<?> collection)
-
addValueList
private void addValueList(JsonValue value)
-
addValueList
private void addValueList(int index, JsonValue value)
-
setValueList
private void setValueList(int index, JsonValue value)
-
validateValue
private void validateValue(java.lang.Object value)
-
-