Class JsonArrayBuilderImpl.JsonArrayImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JsonArray asJsonArray()
      Return the JsonValue as a JsonArray
      JsonValue get​(int index)  
      boolean getBoolean​(int index)
      Returns the boolean value at the specified position.
      boolean getBoolean​(int index, boolean defaultValue)
      Returns the boolean value at the specified position.
      int getInt​(int index)
      A convenience method for getJsonNumber(index).intValue().
      int getInt​(int index, int defaultValue)
      Returns the int value of the JsonNumber at the specified position.
      JsonArray getJsonArray​(int index)
      Returns the array value at the specified position in this array.
      JsonNumber getJsonNumber​(int index)
      Returns the number value at the specified position in this array.
      JsonObject getJsonObject​(int index)
      Returns the object value at the specified position in this array.
      JsonString getJsonString​(int index)
      Returns the string value at ths specified position in this array.
      java.lang.String getString​(int index)
      A convenience method for getJsonString(index).getString().
      java.lang.String getString​(int index, java.lang.String defaultValue)
      Returns the String value of JsonString at the specified position in this JSON array values.
      <T extends JsonValue>
      java.util.List<T>
      getValuesAs​(java.lang.Class<T> clazz)
      Returns a list view of the specified type for the array.
      JsonValue.ValueType getValueType()
      Returns the value type of this JSON value.
      boolean isNull​(int index)
      Returns true if the value at the specified location in this array is JsonValue.NULL.
      int size()  
      java.lang.String toString()
      Returns JSON text for this JSON value.
      • Methods inherited from class java.util.AbstractList

        add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
    • Field Detail

      • valueList

        private final java.util.List<JsonValue> valueList
    • Constructor Detail

    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<JsonValue>
        Specified by:
        size in interface java.util.List<JsonValue>
        Specified by:
        size in class java.util.AbstractCollection<JsonValue>
      • getJsonObject

        public JsonObject getJsonObject​(int index)
        Description copied from interface: JsonArray
        Returns the object value at the specified position in this array. This is a convenience method for (JsonObject)get(index).
        Specified by:
        getJsonObject in interface JsonArray
        Parameters:
        index - index of the value to be returned
        Returns:
        the value at the specified position in this array
      • getJsonArray

        public JsonArray getJsonArray​(int index)
        Description copied from interface: JsonArray
        Returns the array value at the specified position in this array. This is a convenience method for (JsonArray)get(index).
        Specified by:
        getJsonArray in interface JsonArray
        Parameters:
        index - index of the value to be returned
        Returns:
        the value at the specified position in this array
      • getJsonNumber

        public JsonNumber getJsonNumber​(int index)
        Description copied from interface: JsonArray
        Returns the number value at the specified position in this array. This is a convenience method for (JsonNumber)get(index).
        Specified by:
        getJsonNumber in interface JsonArray
        Parameters:
        index - index of the value to be returned
        Returns:
        the value at the specified position in this array
      • getJsonString

        public JsonString getJsonString​(int index)
        Description copied from interface: JsonArray
        Returns the string value at ths specified position in this array. This is a convenience method for (JsonString)get(index).
        Specified by:
        getJsonString in interface JsonArray
        Parameters:
        index - index of the value to be returned
        Returns:
        the value at the specified position in this array
      • getValuesAs

        public <T extends JsonValue> java.util.List<T> getValuesAs​(java.lang.Class<T> clazz)
        Description copied from interface: JsonArray
        Returns a list view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with a ClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns.
        Specified by:
        getValuesAs in interface JsonArray
        Type Parameters:
        T - The type of the List for the array
        Parameters:
        clazz - a JsonValue type
        Returns:
        a list view of the specified type
      • getString

        public java.lang.String getString​(int index)
        Description copied from interface: JsonArray
        A convenience method for getJsonString(index).getString().
        Specified by:
        getString in interface JsonArray
        Parameters:
        index - index of the JsonString value
        Returns:
        the String value at the specified position
      • getString

        public java.lang.String getString​(int index,
                                          java.lang.String defaultValue)
        Description copied from interface: JsonArray
        Returns the String value of JsonString at the specified position in this JSON array values. If JsonString is found, its JsonString.getString() is returned. Otherwise, the specified default value is returned.
        Specified by:
        getString in interface JsonArray
        Parameters:
        index - index of the JsonString value
        defaultValue - the String to return if the JsonValue at the specified position is not a JsonString
        Returns:
        the String value at the specified position in this array, or the specified default value
      • getInt

        public int getInt​(int index)
        Description copied from interface: JsonArray
        A convenience method for getJsonNumber(index).intValue().
        Specified by:
        getInt in interface JsonArray
        Parameters:
        index - index of the JsonNumber value
        Returns:
        the int value at the specified position
      • getInt

        public int getInt​(int index,
                          int defaultValue)
        Description copied from interface: JsonArray
        Returns the int value of the JsonNumber at the specified position. If the value at that position is a JsonNumber, this method returns JsonNumber.intValue(). Otherwise this method returns the specified default value.
        Specified by:
        getInt in interface JsonArray
        Parameters:
        index - index of the JsonNumber value
        defaultValue - the int value to return if the JsonValue at the specified position is not a JsonNumber
        Returns:
        the int value at the specified position in this array, or the specified default value
      • getBoolean

        public boolean getBoolean​(int index)
        Description copied from interface: JsonArray
        Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false.
        Specified by:
        getBoolean in interface JsonArray
        Parameters:
        index - index of the JSON boolean value
        Returns:
        the boolean value at the specified position
      • getBoolean

        public boolean getBoolean​(int index,
                                  boolean defaultValue)
        Description copied from interface: JsonArray
        Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. Otherwise this method returns the specified default value.
        Specified by:
        getBoolean in interface JsonArray
        Parameters:
        index - index of the JSON boolean value
        defaultValue - the boolean value to return if the JsonValue at the specified position is neither TRUE nor FALSE
        Returns:
        the boolean value at the specified position, or the specified default value
      • isNull

        public boolean isNull​(int index)
        Description copied from interface: JsonArray
        Returns true if the value at the specified location in this array is JsonValue.NULL.
        Specified by:
        isNull in interface JsonArray
        Parameters:
        index - index of the JSON null value
        Returns:
        return true if the value at the specified location is JsonValue.NULL, otherwise false
      • get

        public JsonValue get​(int index)
        Specified by:
        get in interface java.util.List<JsonValue>
        Specified by:
        get in class java.util.AbstractList<JsonValue>
      • toString

        public java.lang.String toString()
        Description copied from interface: JsonValue
        Returns JSON text for this JSON value.
        Specified by:
        toString in interface JsonValue
        Overrides:
        toString in class java.util.AbstractCollection<JsonValue>
        Returns:
        JSON text
      • asJsonArray

        public JsonArray asJsonArray()
        Description copied from interface: JsonValue
        Return the JsonValue as a JsonArray
        Specified by:
        asJsonArray in interface JsonValue
        Returns:
        the JsonValue as a JsonArray