Package 

Class ImmutableArrayValueImpl

  • All Implemented Interfaces:
    com.batch.android.msgpack.value.ArrayValue , com.batch.android.msgpack.value.ImmutableArrayValue , com.batch.android.msgpack.value.ImmutableValue , com.batch.android.msgpack.value.Value , java.lang.Iterable

    
    public class ImmutableArrayValueImpl
    extends AbstractImmutableValue implements ImmutableArrayValue
                        

    {@code ImmutableArrayValueImpl} Implements {@code ImmutableArrayValue} using a {@code Value[]} field.

    • Method Summary

      Modifier and Type Method Description
      static ImmutableArrayValue empty()
      ValueType getValueType() Returns type of this value.
      ImmutableArrayValue immutableValue() Returns immutable copy of this value.
      ImmutableArrayValue asArrayValue() Returns the value as {@code ArrayValue}.
      int size() Returns number of elements in this array.
      Value get(int index) Returns the element at the specified position in this array.
      Value getOrNilValue(int index) Returns the element at the specified position in this array.This method returns an ImmutableNilValue if the index is out of range.
      Iterator<Value> iterator() Returns an iterator over elements.
      List<Value> list() Returns the value as {@code List}.Returned List is immutable.
      void writeTo(MessagePacker pk) Serializes the value using the specified {@code MessagePacker}
      boolean equals(Object o)
      int hashCode()
      String toJson() Returns json representation of this Value.
      String toString()
      • Methods inherited from class com.batch.android.msgpack.value.impl.AbstractImmutableValue

        asBinaryValue, asBooleanValue, asExtensionValue, asFloatValue, asIntegerValue, asMapValue, asNilValue, asNumberValue, asRawValue, asStringValue, isArrayValue, isBinaryValue, isBooleanValue, isExtensionValue, isFloatValue, isIntegerValue, isMapValue, isNilValue, isNumberValue, isRawValue, isStringValue
      • Methods inherited from class com.batch.android.msgpack.value.Value

        asArrayValue, asBinaryValue, asBooleanValue, asExtensionValue, asFloatValue, asIntegerValue, asMapValue, asNilValue, asNumberValue, asRawValue, asStringValue, equals, immutableValue
      • Methods inherited from class java.lang.Iterable

        forEach, iterator, spliterator
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImmutableArrayValueImpl

        ImmutableArrayValueImpl(Array<Value> array)
    • Method Detail

      • getValueType

         ValueType getValueType()

        Returns type of this value.

        Note that you can't use instanceof to check type of a value because type of a mutable value is variable.

      • immutableValue

         ImmutableArrayValue immutableValue()

        Returns immutable copy of this value.

        This method simply returns this without copying the value if this value is already immutable.

      • asArrayValue

         ImmutableArrayValue asArrayValue()

        Returns the value as {@code ArrayValue}. Otherwise throws {@code MessageTypeCastException}.

        Note that you can't use instanceof or cast ((ArrayValue) thisValue) to check type of a value because type of a mutable value is variable.

      • size

         int size()

        Returns number of elements in this array.

      • get

         Value get(int index)

        Returns the element at the specified position in this array.

      • getOrNilValue

         Value getOrNilValue(int index)

        Returns the element at the specified position in this array.This method returns an ImmutableNilValue if the index is out of range.

      • iterator

         Iterator<Value> iterator()

        Returns an iterator over elements.Returned Iterator does not support {@code remove()} method since the value is immutable.

      • list

         List<Value> list()

        Returns the value as {@code List}.Returned List is immutable. It does not support {@code put()}, {@code clear()}, or other methods that modify the value.

      • writeTo

         void writeTo(MessagePacker pk)

        Serializes the value using the specified {@code MessagePacker}

      • toJson

         String toJson()

        Returns json representation of this Value.

        Following behavior is not configurable at this release and they might be changed at future releases:

        • if a key of MapValue is not string, the key is converted to a string using toString method.
        • NaN and Infinity of DoubleValue are converted to null.
        • ExtensionValue is converted to a 2-element array where first element is a number and second element is the data encoded in hex.
        • BinaryValue is converted to a string using UTF-8 encoding. Invalid byte sequence is replaced with U+FFFD replacement character.
        • Invalid UTF-8 byte sequences in StringValue is replaced with U+FFFD replacement character