public final class JsonArray extends AbstractList<JsonValue> implements JsonValue
JsonValue.EntityTypemodCount| Modifier and Type | Method and Description |
|---|---|
JsonArray |
asJsonArray()
Returns this value as
JsonArray. |
boolean |
equals(Object otherObject)
Compares the specified object with this JSON array for equality.
|
JsonValue |
get(int index)
Returns the JSON value at the specified position in this array.
|
JsonValue.EntityType |
getEntityType()
Returns
JsonValue.EntityType.ARRAY, which is the entity type of JsonArray. |
int |
hashCode()
Returns the hash code value for this JSON array.
|
static JsonArray |
of()
Returns a JSON array containing zero JSON values.
|
static JsonArray |
of(JsonValue... values)
Returns a JSON array containing an arbitrary number of JSON values.
|
static JsonArray |
ofList(List<? extends JsonValue> values)
Returns a JSON array containing an arbitrary number of JSON values.
|
static JsonArray |
ofUnsafe(JsonValue... array)
Returns a JSON array containing the specified array as its internal representation.
|
int |
presumeReferenceSizeInBytes()
Returns the approximate size of this JSON array in bytes presumed to occupy in
Page as a reference. |
int |
size()
Returns the number of JSON values in this array.
|
String |
toJson()
Returns the stringified JSON representation of this JSON array.
|
Value |
toMsgpack()
Deprecated.
Do not use this method. It is to be removed at some point after Embulk v1.0.0.
It is here only to ensure a migration period from MessagePack-based JSON values to new
JSON values of
JsonValue. |
String |
toString()
Returns the string representation of this JSON array.
|
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitasJsonBoolean, asJsonDouble, asJsonLong, asJsonNull, asJsonObject, asJsonString, fromMsgpack, isJsonArray, isJsonBoolean, isJsonDouble, isJsonLong, isJsonNull, isJsonObject, isJsonStringaddAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic static JsonArray of()
public static JsonArray of(JsonValue... values)
values - the JSON values to be contained in the JSON array, not nullNullPointerException - if the array, or any value is nullpublic static JsonArray ofList(List<? extends JsonValue> values)
values - the JSON values to be contained in the JSON array, not nullNullPointerException - if the list, or any value is nullpublic static JsonArray ofUnsafe(JsonValue... array)
This method is not safe. If the specified array is modified after creating a JsonArray
instance with this method, the created JsonArray instance can unintentionally behave differently.
It has no null checks. If the specified array is null, or contains null,
the created JsonArray can behave unexpectedly.
array - the array of JSON values to be the internal representation as-is in the new JsonArraypublic JsonValue.EntityType getEntityType()
JsonValue.EntityType.ARRAY, which is the entity type of JsonArray.getEntityType in interface JsonValueJsonValue.EntityType.ARRAY, which is the entity type of JsonArraypublic JsonArray asJsonArray()
JsonArray.asJsonArray in interface JsonValueJsonArraypublic int presumeReferenceSizeInBytes()
Page as a reference.
This approximate size is used only as a threshold whether PageBuilder is flushed, or not.
It is not accurate, it does not need to be accurate, and it is impossible in general to tell an accurate size that
a Java object occupies in the Java heap. But, a reasonable approximate would help to keep Page
performant in the Java heap.
It is better to flush more frequently for bigger JSON value objects, less often for smaller JSON value objects, but no infinite accumulation even for empty JSON value objects.
presumeReferenceSizeInBytes in interface JsonValuePage as a referencepublic int size()
size in interface Collection<JsonValue>size in interface List<JsonValue>size in class AbstractCollection<JsonValue>public JsonValue get(int index)
get in interface List<JsonValue>get in class AbstractList<JsonValue>index - index of the JSON value to returnIndexOutOfBoundsException - If the index is out of range (index < 0 || index >= size())public String toJson()
@Deprecated public Value toMsgpack()
JsonValue.toMsgpack in interface JsonValuepublic String toString()
toString in class AbstractCollection<JsonValue>public boolean equals(Object otherObject)
Note that it can return true only when JsonArray is given. It checks the equality as a JSON array.
It does not return true for a general List even though the given list contains the same elements.
equals in interface Collection<JsonValue>equals in interface List<JsonValue>equals in class AbstractList<JsonValue>true if the specified object is equal to this JSON arraypublic int hashCode()
hashCode in interface Collection<JsonValue>hashCode in interface List<JsonValue>hashCode in class AbstractList<JsonValue>