Class JSONArrayImpl
- All Implemented Interfaces:
Iterable<JSONValue>, Formattable, JSONArray, JSONValue
The implementation for the interface
JSONArray.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: JSONArrayImpl.java 1195 2026-04-15 21:33:40Z tquadrat $
- Since:
- 0.25.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.jsonbuilder.internal.JSONArrayImpl"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JSONBuilderImplThe reference to theJSONBuilderthat was used to create thisJSONObject, and that is used to create the members.The elements for thisJSONArrayinstance. -
Constructor Summary
ConstructorsConstructorDescriptionJSONArrayImpl(JSONArrayImpl other) {summary Creates a new instance ofJSONArrayImplfrom the given other array.}JSONArrayImpl(JSONBuilderImpl builder) Creates a new instance ofJSONArrayImpl. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(double value) Appends the given value as a new element to the end of this array.final voidadd(float value) Appends the given value as a new element to the end of this array.final voidadd(int value) Appends the given value as a new element to the end of this array.final voidadd(int index, double value) Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.final voidadd(int index, float value) Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidadd(int index, int value) Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidadd(int index, long value) Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidInserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidInserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidInserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidInserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidInserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidadd(int index, BigDecimal value) Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidadd(int index, BigInteger value) Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final voidInserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.final <T extends Dimension>
voidadd(int index, DimensionedValue<T> value, T targetUnit) Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.final voidadd(long value) Appends the given value as a new element to the end of this array.final voidAppends the given value as a new element to the end of this array.final voidAppends the given value as a new element to the end of this array.final voidAppends the given value as a new element to the end of this array.final voidAppends the given value as a new element to the end of this array.final voidAppends the given value as a new element to the end of this array.final voidadd(BigDecimal value) Appends the given value as a new element to the end of this array.final voidadd(BigInteger value) Appends the given value as a new element to the end of this array.final voidAppends the given value as a new element to the end of this array.final <T extends Dimension>
voidadd(DimensionedValue<T> value, T targetUnit) Appends the given value as a new element to the end of this array.final booleanAppends the given array to this one.final JSONArrayaddArray()Adds a new empty instance ofJSONArrayto this array and returns that.addArray(int index) Adds a new empty instance ofJSONArrayto this array at the given index and returns that.Adds a new empty instance ofJSONObjectto this array and returns that.addObject(int index) Adds a new empty instance ofJSONObjectto this array at the given index and returns that.final booleanvoidfinal JSONValueget(int index) Returns the value of the element at the specied index in this array.final inthashCode()final booleanisEmpty()Checks whether this array has elements.iterator()final voidremove(int index) Removes the element with the specified index from this array.final voidRemoves the first occurrence of the specified element from this array, if it is present.voidset(int index, double value) Sets the value of the element with the specified index to the JSON representation of the specifieddoublevalue.voidset(int index, float value) Sets the value of the element with the specified index to the JSON representation of the specifiedfloatvalue.voidset(int index, int value) Sets the value of the element with the specified index to the JSON representation of the specifiedintvalue.voidset(int index, long value) Sets the value of the element with the specified index to the JSON representation of the specifiedlongvalue.voidSets the value of the element with the specified index to the JSON representation of the specifiedDoublevalue.voidSets the value of the element with the specified index to the JSON representation of the specifiedFloatvalue.voidSets the value of the element with the specified index to the JSON representation of the specifiedIntegervalue.voidSets the value of the element with the specified index to the JSON representation of the specifiedLongvalue.voidSets the value of the element with the specified index to the JSON representation of the specifiedStringvalue.final voidset(int index, BigDecimal value) Sets the value of the element with the specified index to the JSON representation of the specifiedBigDecimalvalue.voidset(int index, BigInteger value) Sets the value of the element with the specified index to the JSON representation of the specifiedBigIntegervalue.final voidSets the value of the element with the specified index to the givenJSONValueinstance.<T extends Dimension>
voidset(int index, DimensionedValue<T> value, T targetUnit) Sets the value of the element with the specified index to the JSON representation of the specifiedDimensionedValuevalue.final JSONArraysetArray(int index) Sets a new empty instance ofJSONArrayto this array at the given index and returns that.final JSONObjectsetObject(int index) Sets a new empty instance ofJSONObjectto this array at the given index and returns that.final intsize()Returns the number of elements for this array.final StringtoString()Methods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface JSONArray
add, add, getArray, getBigDecimal, getBigInteger, getBoolean, getDouble, getFloat, getInt, getLong, getObject, getString, set
-
Field Details
-
m_Builder
The reference to theJSONBuilderthat was used to create thisJSONObject, and that is used to create the members. -
m_Elements
The elements for thisJSONArrayinstance.
-
-
Constructor Details
-
JSONArrayImpl
Creates a new instance ofJSONArrayImpl.- Parameters:
builder- The reference to theJSONBuilder.
-
JSONArrayImpl
{summary Creates a new instance of
JSONArrayImplfrom the given other array.}The new array is a deep copy of the given instance.
- Parameters:
other- The other JSON array.
-
-
Method Details
-
add
Appends the given value as a new element to the end of this array.
-
add
Appends the given value as a new element to the end of this array.
-
add
Appends the given value as a new element to the end of this array.
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
public final <T extends Dimension> void add(int index, DimensionedValue<T> value, T targetUnit) throws IndexOutOfBoundsException Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Type Parameters:
T- The type of the dimension for the value.- Parameters:
index- The index.value- The value.targetUnit- The dimension for the output.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.- See Also:
-
add
Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
add
Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
If
indexis equals to the size of the array, the element is appended to the end of the array.- Specified by:
addin interfaceJSONArray- Parameters:
index- The index.value- The value to add.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
addAll
-
addArray
-
addArray
Adds a new empty instance of
JSONArrayto this array at the given index and returns that.- Specified by:
addArrayin interfaceJSONArray- Parameters:
index- The index.- Returns:
- The freshly created
JSONArray. - Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
addObject
Adds a new empty instance of
JSONObjectto this array and returns that. -
addObject
Adds a new empty instance of
JSONObjectto this array at the given index and returns that.- Specified by:
addObjectin interfaceJSONArray- Parameters:
index- The index.- Returns:
- The freshly created
JSONObject. - Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than the size of the array.
-
equals
-
formatTo
-
get
Returns the value of the element at the specied index in this array.
- Specified by:
getin interfaceJSONArray- Parameters:
index- The index of the element whose value is to be returned.- Returns:
- The element; will never be
null. - Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
hashCode
-
isEmpty
-
iterator
-
remove
Removes the element with the specified index from this array.
- Specified by:
removein interfaceJSONArray- Parameters:
index- The index of the element to remove.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
remove
Removes the first occurrence of the specified element from this array, if it is present. If this list does not contain the element, it remains unchanged.
More formally, this method removes the element with the lowest index
isuch thatObjects.equals(o, get(i))(if such an element exists).- Specified by:
removein interfaceJSONArray- Parameters:
element- The element to remove.- Throws:
IndexOutOfBoundsException
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
BigDecimalvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
BigIntegervalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
public <T extends Dimension> void set(int index, DimensionedValue<T> value, T targetUnit) throws IndexOutOfBoundsException Sets the value of the element with the specified index to the JSON representation of the specified
DimensionedValuevalue.- Specified by:
setin interfaceJSONArray- Type Parameters:
T- The type of the dimension for the value.- Parameters:
index- The index.value- The value.targetUnit- The dimension for the output.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.- See Also:
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
doublevalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
Doublevalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
floatvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
Floatvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
intvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
Integervalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the given
JSONValueinstance.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
longvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
Longvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
set
Sets the value of the element with the specified index to the JSON representation of the specified
Stringvalue.- Specified by:
setin interfaceJSONArray- Parameters:
index- The index of the element to replace.value- The value to set to the member.- Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
setArray
Sets a new empty instance of
JSONArrayto this array at the given index and returns that.- Specified by:
setArrayin interfaceJSONArray- Parameters:
index- The index.- Returns:
- The freshly created
JSONArray. - Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
setObject
Sets a new empty instance of
JSONObjectto this array at the given index and returns that.- Specified by:
setObjectin interfaceJSONArray- Parameters:
index- The index.- Returns:
- The freshly created
JSONObject. - Throws:
IndexOutOfBoundsException- The index is less than 0 or greater than or equal to the size of the array.
-
size
-
toString
-
