Package org.msgpack.value.impl
Class ImmutableArrayValueImpl
- java.lang.Object
-
- org.msgpack.value.impl.ImmutableArrayValueImpl
-
- All Implemented Interfaces:
java.lang.Iterable<Value>,ArrayValue,ImmutableArrayValue,ImmutableValue,Value
public class ImmutableArrayValueImpl extends java.lang.Object implements ImmutableArrayValue
ImmutableArrayValueImplImplementsImmutableArrayValueusing aValue[]field.- See Also:
IntegerValue
-
-
Constructor Summary
Constructors Constructor Description ImmutableArrayValueImpl(Value[] array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableArrayValueasArrayValue()Returns the value asArrayValue.ImmutableBinaryValueasBinaryValue()Returns the value asBinaryValue.ImmutableBooleanValueasBooleanValue()Returns the value asBooleanValue.ImmutableExtensionValueasExtensionValue()Returns the value asExtensionValue.ImmutableFloatValueasFloatValue()Returns the value asFloatValue.ImmutableIntegerValueasIntegerValue()Returns the value asIntegerValue.ImmutableMapValueasMapValue()Returns the value asMapValue.ImmutableNilValueasNilValue()Returns the value asNilValue.ImmutableNumberValueasNumberValue()Returns the value asNumberValue.ImmutableRawValueasRawValue()Returns the value asRawValue.ImmutableStringValueasStringValue()Returns the value asStringValue.static ImmutableArrayValueempty()booleanequals(java.lang.Object o)Compares this value to the specified object.Valueget(int index)Returns the element at the specified position in this array.ValuegetOrNilValue(int index)Returns the element at the specified position in this array.ValueTypegetValueType()Returns type of this value.inthashCode()ImmutableArrayValueimmutableValue()Returns immutable copy of this value.booleanisArrayValue()Returns true if type of this value is Array.booleanisBinaryValue()Returns true if type of this value is Binary.booleanisBooleanValue()Returns true if type of this value is Boolean.booleanisExtensionValue()Returns true if type of this an Extension.booleanisFloatValue()Returns true if type of this value is Float.booleanisIntegerValue()Returns true if type of this value is Integer.booleanisMapValue()Returns true if type of this value is Map.booleanisNilValue()Returns true if type of this value is Nil.booleanisNumberValue()Returns true if type of this value is Integer or Float.booleanisRawValue()Returns true if type of this value is String or Binary.booleanisStringValue()Returns true if type of this value is String.java.util.Iterator<Value>iterator()Returns an iterator over elements.java.util.List<Value>list()Returns the value asList.intsize()Returns number of elements in this array.java.lang.StringtoJson()Returns json representation of this Value.java.lang.StringtoString()voidwriteTo(MessagePacker pk)Serializes the value using the specifiedMessagePacker-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.msgpack.value.ImmutableValue
asBinaryValue, asBooleanValue, asFloatValue, asIntegerValue, asMapValue, asNilValue, asRawValue, asStringValue
-
Methods inherited from interface org.msgpack.value.Value
asExtensionValue, asNumberValue, isArrayValue, isBinaryValue, isBooleanValue, isExtensionValue, isFloatValue, isIntegerValue, isMapValue, isNilValue, isNumberValue, isRawValue, isStringValue
-
-
-
-
Constructor Detail
-
ImmutableArrayValueImpl
public ImmutableArrayValueImpl(Value[] array)
-
-
Method Detail
-
empty
public static ImmutableArrayValue empty()
-
getValueType
public ValueType getValueType()
Description copied from interface:ValueReturns type of this value. Note that you can't useinstanceofto check type of a value because type of a mutable value is variable.- Specified by:
getValueTypein interfaceValue
-
immutableValue
public ImmutableArrayValue immutableValue()
Description copied from interface:ValueReturns immutable copy of this value. This method simply returnsthiswithout copying the value if this value is already immutable.- Specified by:
immutableValuein interfaceValue
-
asArrayValue
public ImmutableArrayValue asArrayValue()
Description copied from interface:ValueReturns the value asArrayValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((ArrayValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asArrayValuein interfaceImmutableValue- Specified by:
asArrayValuein interfaceValue
-
size
public int size()
Description copied from interface:ArrayValueReturns number of elements in this array.- Specified by:
sizein interfaceArrayValue
-
get
public Value get(int index)
Description copied from interface:ArrayValueReturns the element at the specified position in this array.- Specified by:
getin interfaceArrayValue
-
getOrNilValue
public Value getOrNilValue(int index)
Description copied from interface:ArrayValueReturns the element at the specified position in this array. This method returns an ImmutableNilValue if the index is out of range.- Specified by:
getOrNilValuein interfaceArrayValue
-
iterator
public java.util.Iterator<Value> iterator()
Description copied from interface:ImmutableArrayValueReturns an iterator over elements. Returned Iterator does not supportremove()method since the value is immutable.- Specified by:
iteratorin interfaceArrayValue- Specified by:
iteratorin interfaceImmutableArrayValue- Specified by:
iteratorin interfacejava.lang.Iterable<Value>
-
list
public java.util.List<Value> list()
Description copied from interface:ImmutableArrayValueReturns the value asList. Returned List is immutable. It does not supportput(),clear(), or other methods that modify the value.- Specified by:
listin interfaceArrayValue- Specified by:
listin interfaceImmutableArrayValue
-
writeTo
public void writeTo(MessagePacker pk) throws java.io.IOException
Description copied from interface:ValueSerializes the value using the specifiedMessagePacker- Specified by:
writeToin interfaceValue- Throws:
java.io.IOException- See Also:
MessagePacker
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:ValueCompares this value to the specified object. This method returnstrueif type and value are equivalent. If this value isMapValueorArrayValue, this method check equivalence of elements recursively.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toJson
public java.lang.String toJson()
Description copied from interface:ValueReturns 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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isNilValue
public boolean isNilValue()
Description copied from interface:ValueReturns true if type of this value is Nil. If this method returns true,asNilValuenever throws exceptions. Note that you can't useinstanceofor cast((NilValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isNilValuein interfaceValue
-
isBooleanValue
public boolean isBooleanValue()
Description copied from interface:ValueReturns true if type of this value is Boolean. If this method returns true,asBooleanValuenever throws exceptions. Note that you can't useinstanceofor cast((BooleanValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isBooleanValuein interfaceValue
-
isNumberValue
public boolean isNumberValue()
Description copied from interface:ValueReturns true if type of this value is Integer or Float. If this method returns true,asNumberValuenever throws exceptions. Note that you can't useinstanceofor cast((NumberValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isNumberValuein interfaceValue
-
isIntegerValue
public boolean isIntegerValue()
Description copied from interface:ValueReturns true if type of this value is Integer. If this method returns true,asIntegerValuenever throws exceptions. Note that you can't useinstanceofor cast((IntegerValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isIntegerValuein interfaceValue
-
isFloatValue
public boolean isFloatValue()
Description copied from interface:ValueReturns true if type of this value is Float. If this method returns true,asFloatValuenever throws exceptions. Note that you can't useinstanceofor cast((FloatValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isFloatValuein interfaceValue
-
isRawValue
public boolean isRawValue()
Description copied from interface:ValueReturns true if type of this value is String or Binary. If this method returns true,asRawValuenever throws exceptions. Note that you can't useinstanceofor cast((RawValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isRawValuein interfaceValue
-
isBinaryValue
public boolean isBinaryValue()
Description copied from interface:ValueReturns true if type of this value is Binary. If this method returns true,asBinaryValuenever throws exceptions. Note that you can't useinstanceofor cast((BinaryValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isBinaryValuein interfaceValue
-
isStringValue
public boolean isStringValue()
Description copied from interface:ValueReturns true if type of this value is String. If this method returns true,asStringValuenever throws exceptions. Note that you can't useinstanceofor cast((StringValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isStringValuein interfaceValue
-
isArrayValue
public boolean isArrayValue()
Description copied from interface:ValueReturns true if type of this value is Array. If this method returns true,asArrayValuenever throws exceptions. Note that you can't useinstanceofor cast((ArrayValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isArrayValuein interfaceValue
-
isMapValue
public boolean isMapValue()
Description copied from interface:ValueReturns true if type of this value is Map. If this method returns true,asMapValuenever throws exceptions. Note that you can't useinstanceofor cast((MapValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isMapValuein interfaceValue
-
isExtensionValue
public boolean isExtensionValue()
Description copied from interface:ValueReturns true if type of this an Extension. If this method returns true,asExtensionValuenever throws exceptions. Note that you can't useinstanceofor cast((ExtensionValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
isExtensionValuein interfaceValue
-
asNilValue
public ImmutableNilValue asNilValue()
Description copied from interface:ValueReturns the value asNilValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((NilValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asNilValuein interfaceImmutableValue- Specified by:
asNilValuein interfaceValue
-
asBooleanValue
public ImmutableBooleanValue asBooleanValue()
Description copied from interface:ValueReturns the value asBooleanValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((BooleanValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asBooleanValuein interfaceImmutableValue- Specified by:
asBooleanValuein interfaceValue
-
asNumberValue
public ImmutableNumberValue asNumberValue()
Description copied from interface:ValueReturns the value asNumberValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((NumberValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asNumberValuein interfaceValue
-
asIntegerValue
public ImmutableIntegerValue asIntegerValue()
Description copied from interface:ValueReturns the value asIntegerValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((IntegerValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asIntegerValuein interfaceImmutableValue- Specified by:
asIntegerValuein interfaceValue
-
asFloatValue
public ImmutableFloatValue asFloatValue()
Description copied from interface:ValueReturns the value asFloatValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((FloatValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asFloatValuein interfaceImmutableValue- Specified by:
asFloatValuein interfaceValue
-
asRawValue
public ImmutableRawValue asRawValue()
Description copied from interface:ValueReturns the value asRawValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((RawValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asRawValuein interfaceImmutableValue- Specified by:
asRawValuein interfaceValue
-
asBinaryValue
public ImmutableBinaryValue asBinaryValue()
Description copied from interface:ValueReturns the value asBinaryValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((BinaryValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asBinaryValuein interfaceImmutableValue- Specified by:
asBinaryValuein interfaceValue
-
asStringValue
public ImmutableStringValue asStringValue()
Description copied from interface:ValueReturns the value asStringValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((StringValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asStringValuein interfaceImmutableValue- Specified by:
asStringValuein interfaceValue
-
asMapValue
public ImmutableMapValue asMapValue()
Description copied from interface:ValueReturns the value asMapValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((MapValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asMapValuein interfaceImmutableValue- Specified by:
asMapValuein interfaceValue
-
asExtensionValue
public ImmutableExtensionValue asExtensionValue()
Description copied from interface:ValueReturns the value asExtensionValue. Otherwise throwsMessageTypeCastException. Note that you can't useinstanceofor cast((ExtensionValue) thisValue)to check type of a value because type of a mutable value is variable.- Specified by:
asExtensionValuein interfaceValue
-
-