Package org.msgpack.value.impl
Class AbstractImmutableRawValue
- java.lang.Object
-
- org.msgpack.value.impl.AbstractImmutableRawValue
-
- All Implemented Interfaces:
ImmutableRawValue
,ImmutableValue
,RawValue
,Value
- Direct Known Subclasses:
ImmutableBinaryValueImpl
,ImmutableStringValueImpl
public abstract class AbstractImmutableRawValue extends java.lang.Object implements ImmutableRawValue
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
data
-
Constructor Summary
Constructors Constructor Description AbstractImmutableRawValue(byte[] data)
AbstractImmutableRawValue(java.lang.String string)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableArrayValue
asArrayValue()
Returns the value asArrayValue
.ImmutableBinaryValue
asBinaryValue()
Returns the value asBinaryValue
.ImmutableBooleanValue
asBooleanValue()
Returns the value asBooleanValue
.byte[]
asByteArray()
Returns the value asbyte[]
.java.nio.ByteBuffer
asByteBuffer()
Returns the value asByteBuffer
.ImmutableExtensionValue
asExtensionValue()
Returns the value asExtensionValue
.ImmutableFloatValue
asFloatValue()
Returns the value asFloatValue
.ImmutableIntegerValue
asIntegerValue()
Returns the value asIntegerValue
.ImmutableMapValue
asMapValue()
Returns the value asMapValue
.ImmutableNilValue
asNilValue()
Returns the value asNilValue
.ImmutableNumberValue
asNumberValue()
Returns the value asNumberValue
.ImmutableRawValue
asRawValue()
Returns the value asRawValue
.java.lang.String
asString()
Returns the value asString
.ImmutableStringValue
asStringValue()
Returns the value asStringValue
.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.java.lang.String
toJson()
Returns json representation of this Value.java.lang.String
toString()
Returns the value asString
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.msgpack.value.ImmutableValue
asArrayValue, asBinaryValue, asBooleanValue, asFloatValue, asIntegerValue, asMapValue, asNilValue, asStringValue
-
Methods inherited from interface org.msgpack.value.Value
asExtensionValue, asNumberValue, equals, getValueType, immutableValue, isArrayValue, isBinaryValue, isBooleanValue, isExtensionValue, isFloatValue, isIntegerValue, isMapValue, isNilValue, isNumberValue, isRawValue, isStringValue, writeTo
-
-
-
-
Method Detail
-
asRawValue
public ImmutableRawValue 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 interfaceImmutableValue
- Specified by:
asRawValue
in interfaceValue
-
asByteArray
public byte[] asByteArray()
Description copied from interface:RawValue
Returns the value asbyte[]
. This method copies the byte array.- Specified by:
asByteArray
in interfaceRawValue
-
asByteBuffer
public java.nio.ByteBuffer asByteBuffer()
Description copied from interface:RawValue
Returns the value asByteBuffer
. Returned ByteBuffer is read-only. See alsoByteBuffer.asReadOnlyBuffer()
. This method doesn't copy the byte array as much as possible.- Specified by:
asByteBuffer
in interfaceRawValue
-
asString
public java.lang.String asString()
Description copied from interface:RawValue
Returns the value asString
. This method throws an exception if the value includes invalid UTF-8 byte sequence.
-
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()
Description copied from interface:RawValue
Returns the value asString
. This method replaces an invalid UTF-8 byte sequence withU+FFFD replacement character
.
-
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 ImmutableNilValue 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 interfaceImmutableValue
- Specified by:
asNilValue
in interfaceValue
-
asBooleanValue
public ImmutableBooleanValue 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 interfaceImmutableValue
- Specified by:
asBooleanValue
in interfaceValue
-
asNumberValue
public ImmutableNumberValue 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 ImmutableIntegerValue 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 interfaceImmutableValue
- Specified by:
asIntegerValue
in interfaceValue
-
asFloatValue
public ImmutableFloatValue 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 interfaceImmutableValue
- Specified by:
asFloatValue
in interfaceValue
-
asBinaryValue
public ImmutableBinaryValue 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 interfaceImmutableValue
- Specified by:
asBinaryValue
in interfaceValue
-
asStringValue
public ImmutableStringValue 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 interfaceImmutableValue
- Specified by:
asStringValue
in interfaceValue
-
asArrayValue
public ImmutableArrayValue 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 interfaceImmutableValue
- Specified by:
asArrayValue
in interfaceValue
-
asMapValue
public ImmutableMapValue 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 interfaceImmutableValue
- Specified by:
asMapValue
in interfaceValue
-
asExtensionValue
public ImmutableExtensionValue 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
-
-