Package org.msgpack.value.impl
Class ImmutableStringValueImpl
- java.lang.Object
-
- org.msgpack.value.impl.AbstractImmutableRawValue
-
- org.msgpack.value.impl.ImmutableStringValueImpl
-
- All Implemented Interfaces:
ImmutableRawValue
,ImmutableStringValue
,ImmutableValue
,RawValue
,StringValue
,Value
public class ImmutableStringValueImpl extends AbstractImmutableRawValue implements ImmutableStringValue
ImmutableStringValueImpl
ImplementsImmutableStringValue
using abyte[]
field. This implementation caches result oftoString()
andasString()
using a privateString
field.- See Also:
StringValue
-
-
Field Summary
-
Fields inherited from class org.msgpack.value.impl.AbstractImmutableRawValue
data
-
-
Constructor Summary
Constructors Constructor Description ImmutableStringValueImpl(byte[] data)
ImmutableStringValueImpl(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
.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
.ImmutableStringValue
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()
ImmutableStringValue
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.void
writeTo(MessagePacker pk)
Serializes the value using the specifiedMessagePacker
-
Methods inherited from class org.msgpack.value.impl.AbstractImmutableRawValue
asByteArray, asByteBuffer, asRawValue, asString, toJson, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.msgpack.value.ImmutableValue
asArrayValue, asBinaryValue, asBooleanValue, asFloatValue, asIntegerValue, asMapValue, asNilValue, asRawValue
-
Methods inherited from interface org.msgpack.value.RawValue
asByteArray, asByteBuffer, asString, toString
-
Methods inherited from interface org.msgpack.value.Value
asExtensionValue, asNumberValue, isArrayValue, isBinaryValue, isBooleanValue, isExtensionValue, isFloatValue, isIntegerValue, isMapValue, isNilValue, isNumberValue, isRawValue, isStringValue, toJson
-
-
-
-
Method Detail
-
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
-
immutableValue
public ImmutableStringValue 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
-
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
-
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
-
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.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
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
-
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
-
-