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 classJsonArrayBuilderImpl.JsonArrayImpl
-
Field Summary
Fields Modifier and Type Field Description private BufferPoolbufferPoolprivate 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 JsonArrayBuilderadd(boolean value)Adds aJsonValue.TRUEorJsonValue.FALSEvalue to the array.JsonArrayBuilderadd(double value)Adds a value to the array as aJsonNumber.JsonArrayBuilderadd(int value)Adds a value to the array as aJsonNumber.JsonArrayBuilderadd(int index, boolean value)Adds aJsonValue.TRUEorJsonValue.FALSEvalue to the array at the specified position.JsonArrayBuilderadd(int index, double value)Adds a value to the array as aJsonNumberat the specified position.JsonArrayBuilderadd(int index, int value)Adds a value to the array as aJsonNumberat the specified position.JsonArrayBuilderadd(int index, long value)Adds a value to the array as aJsonNumberat the specified position.JsonArrayBuilderadd(int index, java.lang.String value)Adds a value to the array as aJsonStringat the specified position.JsonArrayBuilderadd(int index, java.math.BigDecimal value)Adds a value to the array as aJsonNumberat the specified position.JsonArrayBuilderadd(int index, java.math.BigInteger value)Adds a value to the array as aJsonNumberat the specified position.JsonArrayBuilderadd(int index, JsonArrayBuilder builder)Adds aJsonArrayfrom an array builder to the array at the specified position.JsonArrayBuilderadd(int index, JsonObjectBuilder builder)Adds aJsonObjectfrom an object builder to the array at the specified position.JsonArrayBuilderadd(int index, JsonValue value)Inserts a value to the array at the specified position.JsonArrayBuilderadd(long value)Adds a value to the array as aJsonNumber.JsonArrayBuilderadd(java.lang.String value)Adds a value to the array as aJsonString.JsonArrayBuilderadd(java.math.BigDecimal value)Adds a value to the array as aJsonNumber.JsonArrayBuilderadd(java.math.BigInteger value)Adds a value to the array as aJsonNumber.JsonArrayBuilderadd(JsonArrayBuilder builder)Adds aJsonArrayfrom an array builder to the array.JsonArrayBuilderadd(JsonObjectBuilder builder)Adds aJsonObjectfrom an object builder to the array.JsonArrayBuilderadd(JsonValue value)Adds a value to the array.JsonArrayBuilderaddAll(JsonArrayBuilder builder)Adds all elements of the array in the specified array builder to the array.JsonArrayBuilderaddNull()Adds aJsonValue.NULLvalue to the array.JsonArrayBuilderaddNull(int index)Adds aJsonValue.NULLvalue to the array at the specified position.private voidaddValueList(int index, JsonValue value)private voidaddValueList(JsonValue value)JsonArraybuild()Returns the current array.private voidpopulate(java.util.Collection<?> collection)JsonArrayBuilderremove(int index)Remove the value in the array at the specified position.JsonArrayBuilderset(int index, boolean value)Replaces a value in the array with aJsonValue.TRUEorJsonValue.FALSEvalue at the specified position.JsonArrayBuilderset(int index, double value)Replaces a value in the array with the specified value as aJsonNumberat the specified position.JsonArrayBuilderset(int index, int value)Replaces a value in the array with the specified value as aJsonNumberat the specified position.JsonArrayBuilderset(int index, long value)Replaces a value in the array with the specified value as aJsonNumberat the specified position.JsonArrayBuilderset(int index, java.lang.String value)Replaces a value in the array with the specified value as aJsonStringat the specified position.JsonArrayBuilderset(int index, java.math.BigDecimal value)Replaces a value in the array with the specified value as aJsonNumberat the specified position.JsonArrayBuilderset(int index, java.math.BigInteger value)Replaces a value in the array with the specified value as aJsonNumberat the specified position.JsonArrayBuilderset(int index, JsonArrayBuilder builder)Replaces a value in the array with the specified value as aJsonArrayfrom an array builder at the specified position.JsonArrayBuilderset(int index, JsonObjectBuilder builder)Replaces a value in the array with the specified value as aJsonObjectfrom an object builder at the specified position.JsonArrayBuilderset(int index, JsonValue value)Replaces a value in the array with the specified value at the specified position.JsonArrayBuildersetNull(int index)Replaces a value in the array with aJsonValue.NULLvalue at the specified position.private voidsetValueList(int index, JsonValue value)private voidvalidateValue(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:JsonArrayBuilderAdds a value to the array.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the JSON value- Returns:
- this array builder
-
add
public JsonArrayBuilder add(java.lang.String value)
Description copied from interface:JsonArrayBuilderAdds a value to the array as aJsonString.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the string value- Returns:
- this array builder
-
add
public JsonArrayBuilder add(java.math.BigDecimal value)
Description copied from interface:JsonArrayBuilderAdds a value to the array as aJsonNumber.- Specified by:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonNumber.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(int value)
Description copied from interface:JsonArrayBuilderAdds a value to the array as aJsonNumber.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(long value)
Description copied from interface:JsonArrayBuilderAdds a value to the array as aJsonNumber.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(double value)
Description copied from interface:JsonArrayBuilderAdds a value to the array as aJsonNumber.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the number value- Returns:
- this array builder
- See Also:
JsonNumber
-
add
public JsonArrayBuilder add(boolean value)
Description copied from interface:JsonArrayBuilderAdds aJsonValue.TRUEorJsonValue.FALSEvalue to the array.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
value- the boolean value- Returns:
- this array builder
-
addNull
public JsonArrayBuilder addNull()
Description copied from interface:JsonArrayBuilderAdds aJsonValue.NULLvalue to the array.- Specified by:
addNullin interfaceJsonArrayBuilder- Returns:
- this array builder
-
add
public JsonArrayBuilder add(JsonObjectBuilder builder)
Description copied from interface:JsonArrayBuilderAdds aJsonObjectfrom an object builder to the array.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
builder- the object builder- Returns:
- this array builder
-
add
public JsonArrayBuilder add(JsonArrayBuilder builder)
Description copied from interface:JsonArrayBuilderAdds aJsonArrayfrom an array builder to the array.- Specified by:
addin interfaceJsonArrayBuilder- Parameters:
builder- the array builder- Returns:
- this array builder
-
addAll
public JsonArrayBuilder addAll(JsonArrayBuilder builder)
Description copied from interface:JsonArrayBuilderAdds all elements of the array in the specified array builder to the array.- Specified by:
addAllin interfaceJsonArrayBuilder- Parameters:
builder- the array builder- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, JsonValue value)
Description copied from interface:JsonArrayBuilderInserts 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:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonStringat 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:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonNumberat 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:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonNumberat 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:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonNumberat 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:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonNumberat 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:
addin 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:JsonArrayBuilderAdds a value to the array as aJsonNumberat 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:
addin 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:JsonArrayBuilderAdds aJsonValue.TRUEorJsonValue.FALSEvalue 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:
addin 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:JsonArrayBuilderAdds aJsonValue.NULLvalue 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:
addNullin interfaceJsonArrayBuilder- Parameters:
index- the position in the array- Returns:
- this array builder
-
add
public JsonArrayBuilder add(int index, JsonObjectBuilder builder)
Description copied from interface:JsonArrayBuilderAdds aJsonObjectfrom 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:
addin 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:JsonArrayBuilderAdds aJsonArrayfrom 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:
addin 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:JsonArrayBuilderReplaces a value in the array with the specified value at the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonStringat the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonNumberat the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonNumberat the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonNumberat the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonNumberat the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonNumberat the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with aJsonValue.TRUEorJsonValue.FALSEvalue at the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with aJsonValue.NULLvalue at the specified position.- Specified by:
setNullin interfaceJsonArrayBuilder- Parameters:
index- the position in the array- Returns:
- this array builder
-
set
public JsonArrayBuilder set(int index, JsonObjectBuilder builder)
Description copied from interface:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonObjectfrom an object builder at the specified position.- Specified by:
setin 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:JsonArrayBuilderReplaces a value in the array with the specified value as aJsonArrayfrom an array builder at the specified position.- Specified by:
setin 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:JsonArrayBuilderRemove the value in the array at the specified position. Shift any subsequent values to the left (subtracts one from their indices.- Specified by:
removein interfaceJsonArrayBuilder- Parameters:
index- the position in the array- Returns:
- this array builder
-
build
public JsonArray build()
Description copied from interface:JsonArrayBuilderReturns the current array.- Specified by:
buildin 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)
-
-