Package org.msgpack.value.impl
Class ImmutableBigIntegerValueImpl
- java.lang.Object
-
- org.msgpack.value.impl.ImmutableBigIntegerValueImpl
-
- All Implemented Interfaces:
ImmutableIntegerValue,ImmutableNumberValue,ImmutableValue,IntegerValue,NumberValue,Value
public class ImmutableBigIntegerValueImpl extends java.lang.Object implements ImmutableIntegerValue
ImmutableBigIntegerValueImplImplementsImmutableBigIntegerValueusing aBigIntegerfield.- See Also:
IntegerValue
-
-
Constructor Summary
Constructors Constructor Description ImmutableBigIntegerValueImpl(java.math.BigInteger value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableArrayValueasArrayValue()Returns the value asArrayValue.java.math.BigIntegerasBigInteger()Returns the value as aBigInteger.ImmutableBinaryValueasBinaryValue()Returns the value asBinaryValue.ImmutableBooleanValueasBooleanValue()Returns the value asBooleanValue.byteasByte()Returns the value as abyte, otherwise throws an exception.ImmutableExtensionValueasExtensionValue()Returns the value asExtensionValue.ImmutableFloatValueasFloatValue()Returns the value asFloatValue.intasInt()Returns the value as anint, otherwise throws an exception.ImmutableIntegerValueasIntegerValue()Returns the value asIntegerValue.longasLong()Returns the value as along, otherwise throws an exception.ImmutableMapValueasMapValue()Returns the value asMapValue.ImmutableNilValueasNilValue()Returns the value asNilValue.ImmutableNumberValueasNumberValue()Returns the value asNumberValue.ImmutableRawValueasRawValue()Returns the value asRawValue.shortasShort()Returns the value as ashort, otherwise throws an exception.ImmutableStringValueasStringValue()Returns the value asStringValue.booleanequals(java.lang.Object o)Compares this value to the specified object.ValueTypegetValueType()Returns type of this value.inthashCode()ImmutableIntegerValueimmutableValue()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.booleanisInByteRange()Returns true if the value is in the range of [-27 to 27-1].booleanisInIntRange()Returns true if the value is in the range of [-231 to 231-1]booleanisInLongRange()Returns true if the value is in the range of [-263 to 263-1]booleanisInShortRange()Returns true if the value is in the range of [-215 to 215-1]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.MessageFormatmostSuccinctMessageFormat()Returns the most succinct MessageFormat type to represent this integer value.static MessageFormatmostSuccinctMessageFormat(IntegerValue v)java.math.BigIntegertoBigInteger()Represent this value as a BigInteger, which may involve rounding or truncation of the original value.bytetoByte()Represent this value as a byte value, which may involve rounding or truncation of the original value.doubletoDouble()Represent this value as a 64-bit double value, which may involve rounding or truncation of the original value.floattoFloat()Represent this value as a 32-bit float value, which may involve rounding or truncation of the original value.inttoInt()Represent this value as an int value, which may involve rounding or truncation of the original value.java.lang.StringtoJson()Returns json representation of this Value.longtoLong()Represent this value as a long value, which may involve rounding or truncation of the original value.shorttoShort()Represent this value as a short value, which may involve rounding or truncation of the original 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
asArrayValue, asBinaryValue, asBooleanValue, asFloatValue, asMapValue, asNilValue, asRawValue, asStringValue
-
Methods inherited from interface org.msgpack.value.Value
asExtensionValue, isArrayValue, isBinaryValue, isBooleanValue, isExtensionValue, isFloatValue, isIntegerValue, isMapValue, isNilValue, isNumberValue, isRawValue, isStringValue
-
-
-
-
Method Detail
-
mostSuccinctMessageFormat
public static MessageFormat mostSuccinctMessageFormat(IntegerValue v)
-
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 ImmutableIntegerValue 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
-
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
-
toByte
public byte toByte()
Description copied from interface:NumberValueRepresent this value as a byte value, which may involve rounding or truncation of the original value. the value.- Specified by:
toBytein interfaceNumberValue
-
toShort
public short toShort()
Description copied from interface:NumberValueRepresent this value as a short value, which may involve rounding or truncation of the original value.- Specified by:
toShortin interfaceNumberValue
-
toInt
public int toInt()
Description copied from interface:NumberValueRepresent this value as an int value, which may involve rounding or truncation of the original value. value.- Specified by:
toIntin interfaceNumberValue
-
toLong
public long toLong()
Description copied from interface:NumberValueRepresent this value as a long value, which may involve rounding or truncation of the original value.- Specified by:
toLongin interfaceNumberValue
-
toBigInteger
public java.math.BigInteger toBigInteger()
Description copied from interface:NumberValueRepresent this value as a BigInteger, which may involve rounding or truncation of the original value.- Specified by:
toBigIntegerin interfaceNumberValue
-
toFloat
public float toFloat()
Description copied from interface:NumberValueRepresent this value as a 32-bit float value, which may involve rounding or truncation of the original value.- Specified by:
toFloatin interfaceNumberValue
-
toDouble
public double toDouble()
Description copied from interface:NumberValueRepresent this value as a 64-bit double value, which may involve rounding or truncation of the original value.- Specified by:
toDoublein interfaceNumberValue
-
isInByteRange
public boolean isInByteRange()
Description copied from interface:IntegerValueReturns true if the value is in the range of [-27 to 27-1].- Specified by:
isInByteRangein interfaceIntegerValue
-
isInShortRange
public boolean isInShortRange()
Description copied from interface:IntegerValueReturns true if the value is in the range of [-215 to 215-1]- Specified by:
isInShortRangein interfaceIntegerValue
-
isInIntRange
public boolean isInIntRange()
Description copied from interface:IntegerValueReturns true if the value is in the range of [-231 to 231-1]- Specified by:
isInIntRangein interfaceIntegerValue
-
isInLongRange
public boolean isInLongRange()
Description copied from interface:IntegerValueReturns true if the value is in the range of [-263 to 263-1]- Specified by:
isInLongRangein interfaceIntegerValue
-
mostSuccinctMessageFormat
public MessageFormat mostSuccinctMessageFormat()
Description copied from interface:IntegerValueReturns the most succinct MessageFormat type to represent this integer value.- Specified by:
mostSuccinctMessageFormatin interfaceIntegerValue- Returns:
- the smallest integer type of MessageFormat that is big enough to store the value.
-
asByte
public byte asByte()
Description copied from interface:IntegerValueReturns the value as abyte, otherwise throws an exception.- Specified by:
asBytein interfaceIntegerValue
-
asShort
public short asShort()
Description copied from interface:IntegerValueReturns the value as ashort, otherwise throws an exception.- Specified by:
asShortin interfaceIntegerValue
-
asInt
public int asInt()
Description copied from interface:IntegerValueReturns the value as anint, otherwise throws an exception.- Specified by:
asIntin interfaceIntegerValue
-
asLong
public long asLong()
Description copied from interface:IntegerValueReturns the value as along, otherwise throws an exception.- Specified by:
asLongin interfaceIntegerValue
-
asBigInteger
public java.math.BigInteger asBigInteger()
Description copied from interface:IntegerValueReturns the value as aBigInteger.- Specified by:
asBigIntegerin interfaceIntegerValue
-
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
-
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
-
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
-
-