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 ImmutableArrayValueasArrayValue()Returns the value asArrayValue.ImmutableBinaryValueasBinaryValue()Returns the value asBinaryValue.ImmutableBooleanValueasBooleanValue()Returns the value asBooleanValue.byte[]asByteArray()Returns the value asbyte[].java.nio.ByteBufferasByteBuffer()Returns the value asByteBuffer.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.java.lang.StringasString()Returns the value asString.ImmutableStringValueasStringValue()Returns the value asStringValue.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.lang.StringtoJson()Returns json representation of this Value.java.lang.StringtoString()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: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
-
asByteArray
public byte[] asByteArray()
Description copied from interface:RawValueReturns the value asbyte[]. This method copies the byte array.- Specified by:
asByteArrayin interfaceRawValue
-
asByteBuffer
public java.nio.ByteBuffer asByteBuffer()
Description copied from interface:RawValueReturns 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:
asByteBufferin interfaceRawValue
-
asString
public java.lang.String asString()
Description copied from interface:RawValueReturns 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: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()
Description copied from interface:RawValueReturns the value asString. This method replaces an invalid UTF-8 byte sequence withU+FFFD replacement character.
-
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
-
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
-
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
-
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
-
-