Package org.msgpack.value
Class Variable
- java.lang.Object
-
- org.msgpack.value.Variable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Variable.Type
-
Constructor Summary
Constructors Constructor Description Variable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayValue
asArrayValue()
Returns the value asArrayValue
.BinaryValue
asBinaryValue()
Returns the value asBinaryValue
.BooleanValue
asBooleanValue()
Returns the value asBooleanValue
.ExtensionValue
asExtensionValue()
Returns the value asExtensionValue
.FloatValue
asFloatValue()
Returns the value asFloatValue
.IntegerValue
asIntegerValue()
Returns the value asIntegerValue
.MapValue
asMapValue()
Returns the value asMapValue
.NilValue
asNilValue()
Returns the value asNilValue
.NumberValue
asNumberValue()
Returns the value asNumberValue
.RawValue
asRawValue()
Returns the value asRawValue
.StringValue
asStringValue()
Returns the value asStringValue
.boolean
equals(java.lang.Object o)
Compares this value to the specified object.ValueType
getValueType()
Returns type of this value.int
hashCode()
ImmutableValue
immutableValue()
Returns immutable copy of this value.boolean
isArrayValue()
Returns true if type of this value is Array.boolean
isBinaryValue()
Returns true if type of this value is Binary.boolean
isBooleanValue()
Returns true if type of this value is Boolean.boolean
isExtensionValue()
Returns true if type of this an Extension.boolean
isFloatValue()
Returns true if type of this value is Float.boolean
isIntegerValue()
Returns true if type of this value is Integer.boolean
isMapValue()
Returns true if type of this value is Map.boolean
isNilValue()
Returns true if type of this value is Nil.boolean
isNumberValue()
Returns true if type of this value is Integer or Float.boolean
isRawValue()
Returns true if type of this value is String or Binary.boolean
isStringValue()
Returns true if type of this value is String.Variable
setArrayValue(java.util.List<Value> v)
Variable
setBinaryValue(byte[] v)
Variable
setBooleanValue(boolean v)
Variable
setExtensionValue(byte type, byte[] data)
Variable
setFloatValue(double v)
Variable
setFloatValue(float v)
Variable
setIntegerValue(long v)
Variable
setIntegerValue(java.math.BigInteger v)
Variable
setMapValue(java.util.Map<Value,Value> v)
Variable
setNilValue()
Variable
setStringValue(byte[] v)
Variable
setStringValue(java.lang.String v)
java.lang.String
toJson()
Returns json representation of this Value.java.lang.String
toString()
void
writeTo(MessagePacker pk)
Serializes the value using the specifiedMessagePacker
-
-
-
Method Detail
-
setNilValue
public Variable setNilValue()
-
setBooleanValue
public Variable setBooleanValue(boolean v)
-
setIntegerValue
public Variable setIntegerValue(long v)
-
setIntegerValue
public Variable setIntegerValue(java.math.BigInteger v)
-
setFloatValue
public Variable setFloatValue(double v)
-
setFloatValue
public Variable setFloatValue(float v)
-
setBinaryValue
public Variable setBinaryValue(byte[] v)
-
setStringValue
public Variable setStringValue(java.lang.String v)
-
setStringValue
public Variable setStringValue(byte[] v)
-
setExtensionValue
public Variable setExtensionValue(byte type, byte[] data)
-
immutableValue
public ImmutableValue immutableValue()
Description copied from interface:Value
Returns immutable copy of this value. This method simply returnsthis
without copying the value if this value is already immutable.- Specified by:
immutableValue
in interfaceValue
-
writeTo
public void writeTo(MessagePacker pk) throws java.io.IOException
Description copied from interface:Value
Serializes the value using the specifiedMessagePacker
- Specified by:
writeTo
in interfaceValue
- Throws:
java.io.IOException
- See Also:
MessagePacker
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:Value
Compares this value to the specified object. This method returnstrue
if type and value are equivalent. If this value isMapValue
orArrayValue
, this method check equivalence of elements recursively.
-
toJson
public java.lang.String toJson()
Description copied from interface:Value
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getValueType
public ValueType getValueType()
Description copied from interface:Value
Returns type of this value. Note that you can't useinstanceof
to check type of a value because type of a mutable value is variable.- Specified by:
getValueType
in interfaceValue
-
isNilValue
public boolean isNilValue()
Description copied from interface:Value
Returns true if type of this value is Nil. If this method returns true,asNilValue
never throws exceptions. Note that you can't useinstanceof
or cast((NilValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isNilValue
in interfaceValue
-
isBooleanValue
public boolean isBooleanValue()
Description copied from interface:Value
Returns true if type of this value is Boolean. If this method returns true,asBooleanValue
never throws exceptions. Note that you can't useinstanceof
or cast((BooleanValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isBooleanValue
in interfaceValue
-
isNumberValue
public boolean isNumberValue()
Description copied from interface:Value
Returns true if type of this value is Integer or Float. If this method returns true,asNumberValue
never throws exceptions. Note that you can't useinstanceof
or cast((NumberValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isNumberValue
in interfaceValue
-
isIntegerValue
public boolean isIntegerValue()
Description copied from interface:Value
Returns true if type of this value is Integer. If this method returns true,asIntegerValue
never throws exceptions. Note that you can't useinstanceof
or cast((IntegerValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isIntegerValue
in interfaceValue
-
isFloatValue
public boolean isFloatValue()
Description copied from interface:Value
Returns true if type of this value is Float. If this method returns true,asFloatValue
never throws exceptions. Note that you can't useinstanceof
or cast((FloatValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isFloatValue
in interfaceValue
-
isRawValue
public boolean isRawValue()
Description copied from interface:Value
Returns true if type of this value is String or Binary. If this method returns true,asRawValue
never throws exceptions. Note that you can't useinstanceof
or cast((RawValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isRawValue
in interfaceValue
-
isBinaryValue
public boolean isBinaryValue()
Description copied from interface:Value
Returns true if type of this value is Binary. If this method returns true,asBinaryValue
never throws exceptions. Note that you can't useinstanceof
or cast((BinaryValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isBinaryValue
in interfaceValue
-
isStringValue
public boolean isStringValue()
Description copied from interface:Value
Returns true if type of this value is String. If this method returns true,asStringValue
never throws exceptions. Note that you can't useinstanceof
or cast((StringValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isStringValue
in interfaceValue
-
isArrayValue
public boolean isArrayValue()
Description copied from interface:Value
Returns true if type of this value is Array. If this method returns true,asArrayValue
never throws exceptions. Note that you can't useinstanceof
or cast((ArrayValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isArrayValue
in interfaceValue
-
isMapValue
public boolean isMapValue()
Description copied from interface:Value
Returns true if type of this value is Map. If this method returns true,asMapValue
never throws exceptions. Note that you can't useinstanceof
or cast((MapValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isMapValue
in interfaceValue
-
isExtensionValue
public boolean isExtensionValue()
Description copied from interface:Value
Returns true if type of this an Extension. If this method returns true,asExtensionValue
never throws exceptions. Note that you can't useinstanceof
or cast((ExtensionValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
isExtensionValue
in interfaceValue
-
asNilValue
public NilValue asNilValue()
Description copied from interface:Value
Returns the value asNilValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((NilValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asNilValue
in interfaceValue
-
asBooleanValue
public BooleanValue asBooleanValue()
Description copied from interface:Value
Returns the value asBooleanValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((BooleanValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asBooleanValue
in interfaceValue
-
asNumberValue
public NumberValue asNumberValue()
Description copied from interface:Value
Returns the value asNumberValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((NumberValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asNumberValue
in interfaceValue
-
asIntegerValue
public IntegerValue asIntegerValue()
Description copied from interface:Value
Returns the value asIntegerValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((IntegerValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asIntegerValue
in interfaceValue
-
asFloatValue
public FloatValue asFloatValue()
Description copied from interface:Value
Returns the value asFloatValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((FloatValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asFloatValue
in interfaceValue
-
asRawValue
public RawValue asRawValue()
Description copied from interface:Value
Returns the value asRawValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((RawValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asRawValue
in interfaceValue
-
asBinaryValue
public BinaryValue asBinaryValue()
Description copied from interface:Value
Returns the value asBinaryValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((BinaryValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asBinaryValue
in interfaceValue
-
asStringValue
public StringValue asStringValue()
Description copied from interface:Value
Returns the value asStringValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((StringValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asStringValue
in interfaceValue
-
asArrayValue
public ArrayValue asArrayValue()
Description copied from interface:Value
Returns the value asArrayValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((ArrayValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asArrayValue
in interfaceValue
-
asMapValue
public MapValue asMapValue()
Description copied from interface:Value
Returns the value asMapValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((MapValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asMapValue
in interfaceValue
-
asExtensionValue
public ExtensionValue asExtensionValue()
Description copied from interface:Value
Returns the value asExtensionValue
. Otherwise throwsMessageTypeCastException
. Note that you can't useinstanceof
or cast((ExtensionValue) thisValue)
to check type of a value because type of a mutable value is variable.- Specified by:
asExtensionValue
in interfaceValue
-
-