Package org.apache.activemq.artemis.json
Interface JsonArray
- All Known Implementing Classes:
JsonArrayImpl
A JsonArray e.g.
[1,5,8]or
[
{"name":"karl", "age": 38},
{"name":"sue", "age": 42},
]
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.activemq.artemis.json.JsonValue
JsonValue.ValueType -
Field Summary
Fields inherited from interface org.apache.activemq.artemis.json.JsonValue
EMPTY_JSON_ARRAY, EMPTY_JSON_OBJECT, FALSE, NULL, TRUE -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBoolean(int index) Returns the native boolean value at the given position.booleangetBoolean(int index, boolean defaultValue) Returns the native boolean value at the given position or the defaultValue if null.intgetInt(int index) Returns the native int value at the given position.intgetInt(int index, int defaultValue) Returns the native int value at the given position or the defaultValue if null.getJsonArray(int index) Returns the JsonArray at the given position.getJsonNumber(int index) Returns the JsonNumber at the given position.getJsonObject(int index) Returns the JsonObject at the given position.getJsonString(int index) Returns the JsonString at the given position.getString(int index) Returns the native String at the given position.Returns the native String at the given position or the defaultValue if null.getValuesAs(Class<T> clazz) Returns the respective JsonValue at the given position.getValuesAs(Function<K, T> func) Returns aListfor the array.booleanisNull(int index) Returns whether the value at the given position isJsonValue.NULL.Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.apache.activemq.artemis.json.JsonValue
asJsonArray, asJsonObject, getValueType, toStringMethods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
Method Details
-
getJsonObject
Returns the JsonObject at the given position.- Returns:
- the JsonObject at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to the JsonObject
-
getJsonArray
Returns the JsonArray at the given position.- Returns:
- the JsonArray at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to the JsonArray
-
getJsonNumber
Returns the JsonNumber at the given position.- Returns:
- the JsonNumber at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to the JsonNumber
-
getJsonString
Returns the JsonString at the given position.- Returns:
- the JsonString at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to the JsonString
-
getValuesAs
Returns the respective JsonValue at the given position.- Returns:
- the respective JsonValue at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to the given slazz
-
getValuesAs
Returns aListfor the array. The value and the type of the elements in the list is specified by thefuncargument.This method can be used to obtain a list of the unwrapped types, such as
It can also be used to obtain a list of simple projections, such asList<String> strings = ary1.getValuesAs(JsonString::getString); List<Integer> ints = ary2.getValuesAs(JsonNumber::intValue);Lsit<Integer> stringsizes = arr.getValueAs((JsonString v) -> v.getString().length();- Type Parameters:
K- The element type (must be a subtype of JsonValue) of this JsonArray.T- The element type of the returned List- Parameters:
func- The function that maps the elements of this JsonArray to the target elements.- Returns:
- A List of the specified values and type
- Throws:
ClassCastException- if theJsonArraycontains a value of wrong type
-
getString
Returns the native String at the given position.- Returns:
- the native String at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to a String
-
getString
Returns the native String at the given position or the defaultValue if null.- Returns:
- the native String at the given position or the defaultValue if null
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to a String
-
getInt
int getInt(int index) Returns the native int value at the given position.- Returns:
- the native int value at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to an intNullPointerException- if an object with the given name doesn't exist
-
getInt
int getInt(int index, int defaultValue) Returns the native int value at the given position or the defaultValue if null.- Returns:
- the native int value at the given position or the defaultValue if null
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to an int
-
getBoolean
boolean getBoolean(int index) Returns the native boolean value at the given position.- Returns:
- the native boolean value at the given position
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to a booleanNullPointerException- if an object with the given name doesn't exist
-
getBoolean
boolean getBoolean(int index, boolean defaultValue) Returns the native boolean value at the given position or the defaultValue if null.- Returns:
- the native boolean value at the given position or the defaultValue if null
- Throws:
IndexOutOfBoundsException- if the index is out of rangeClassCastException- if the value at the specified position is not assignable to a boolean
-
isNull
boolean isNull(int index) Returns whether the value at the given position isJsonValue.NULL.- Returns:
- whether the value at the given position is
JsonValue.NULL - Throws:
IndexOutOfBoundsException- if the index is out of range
-