org.msgpack.value.impl
Class LongValueImpl

java.lang.Object
  extended by org.msgpack.value.impl.AbstractValueRef
      extended by org.msgpack.value.impl.AbstractValue
          extended by org.msgpack.value.impl.LongValueImpl
All Implemented Interfaces:
IntegerValue, NumberValue, Value, ValueRef

public class LongValueImpl
extends AbstractValue
implements IntegerValue

Created on 5/30/14.


Field Summary
 
Fields inherited from class org.msgpack.value.impl.AbstractValueRef
NUMBER_TYPE_MASK, RAW_TYPE_MASK
 
Constructor Summary
LongValueImpl(long value)
           
 
Method Summary
 void accept(ValueVisitor visitor)
           
 java.math.BigInteger asBigInteger()
          Convert this value into a BigInteger value.
 byte asByte()
          Convert this value into a byte value.
 int asInt()
          Convert this value into an int value.
 IntegerValue asInteger()
           
 long asLong()
          Convert this value into a long value.
 short asShort()
          Convert this value into a short value.
 boolean equals(java.lang.Object o)
           
 ValueType getValueType()
           
 int hashCode()
           
 boolean isValidByte()
          Check whether this value is a valid byte value.
 boolean isValidInt()
          Check whether this value is a valid integer value.
 boolean isValidLong()
          Check whether this value is a valid long value.
 boolean isValidShort()
          Check whether this value is a valid short value.
 boolean isWhole()
          Returns true if this number has no decimal component
 java.math.BigInteger toBigInteger()
          Convert this value into a BigInteger
 byte toByte()
          Convert this value into a byte value.
 double toDouble()
          Convert this value into a double value
 float toFloat()
          Convert this value into a float value
 int toInt()
          Convert this value into an int value.
 long toLong()
          Convert this value into a long value.
 short toShort()
          Convert this value into a short value.
 java.lang.String toString()
           
 IntegerValue toValue()
          Create an immutable value from this reference
 void writeTo(MessagePacker pk)
           
 
Methods inherited from class org.msgpack.value.impl.AbstractValue
isRef
 
Methods inherited from class org.msgpack.value.impl.AbstractValueRef
as, as, asArrayValue, asBinary, asBoolean, asExtended, asFloat, asMapValue, asNil, asNumber, asRaw, asString, getArrayCursor, getMapCursor, isArray, isBinary, isBoolean, isExtended, isFloat, isInteger, isMap, isNil, isNumber, isRaw, isString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.msgpack.value.Value
asArrayValue, asMapValue
 
Methods inherited from interface org.msgpack.value.ValueRef
asBinary, asBoolean, asExtended, asFloat, asNil, asNumber, asRaw, asString, getArrayCursor, getMapCursor, isArray, isBinary, isBoolean, isExtended, isFloat, isInteger, isMap, isNil, isNumber, isRaw, isRef, isString
 

Constructor Detail

LongValueImpl

public LongValueImpl(long value)
Method Detail

getValueType

public ValueType getValueType()
Specified by:
getValueType in interface ValueRef

asInteger

public IntegerValue asInteger()
Specified by:
asInteger in interface ValueRef
Overrides:
asInteger in class AbstractValueRef

toByte

public byte toByte()
Description copied from interface: NumberValue
Convert this value into a byte value. If this value is not within the range of Byte value, it will truncate or round the value.

Specified by:
toByte in interface NumberValue

toShort

public short toShort()
Description copied from interface: NumberValue
Convert this value into a short value. If this value is not within the range of Short value, it will truncate or round the value.

Specified by:
toShort in interface NumberValue

toInt

public int toInt()
Description copied from interface: NumberValue
Convert this value into an int value. If this value is not within the range of Int value, it will truncate or round the value.

Specified by:
toInt in interface NumberValue

toLong

public long toLong()
Description copied from interface: NumberValue
Convert this value into a long value. If this value is not within the range of Long value, it will truncate or round the value.

Specified by:
toLong in interface NumberValue

toBigInteger

public java.math.BigInteger toBigInteger()
Description copied from interface: NumberValue
Convert this value into a BigInteger

Specified by:
toBigInteger in interface NumberValue

toFloat

public float toFloat()
Description copied from interface: NumberValue
Convert this value into a float value

Specified by:
toFloat in interface NumberValue

toDouble

public double toDouble()
Description copied from interface: NumberValue
Convert this value into a double value

Specified by:
toDouble in interface NumberValue

asByte

public byte asByte()
            throws MessageIntegerOverflowException
Description copied from interface: NumberValue
Convert this value into a byte value. If this value is not within the range of Byte value, it throws an exception.

Specified by:
asByte in interface NumberValue
Returns:
Throws:
MessageIntegerOverflowException

asShort

public short asShort()
              throws MessageIntegerOverflowException
Description copied from interface: NumberValue
Convert this value into a short value. If this value is not within the range of Short value, it throws an exception.

Specified by:
asShort in interface NumberValue
Returns:
Throws:
MessageIntegerOverflowException

asInt

public int asInt()
          throws MessageIntegerOverflowException
Description copied from interface: NumberValue
Convert this value into an int value. If this value is not within the range of Integer value, it throws an exception.

Specified by:
asInt in interface NumberValue
Returns:
Throws:
MessageIntegerOverflowException

asLong

public long asLong()
            throws MessageIntegerOverflowException
Description copied from interface: NumberValue
Convert this value into a long value. If this value is not within the range of Long value, it throws an exception.

Specified by:
asLong in interface NumberValue
Returns:
Throws:
MessageIntegerOverflowException

asBigInteger

public java.math.BigInteger asBigInteger()
                                  throws MessageIntegerOverflowException
Description copied from interface: NumberValue
Convert this value into a BigInteger value.

Specified by:
asBigInteger in interface NumberValue
Returns:
Throws:
MessageIntegerOverflowException

isValidByte

public boolean isValidByte()
Description copied from interface: NumberValue
Check whether this value is a valid byte value.

Specified by:
isValidByte in interface NumberValue
Returns:
true if this value has no fractional part, and is within the range of Byte.MIN_VALUE and Byte.MAX_VALUE; otherwise returns false

isValidShort

public boolean isValidShort()
Description copied from interface: NumberValue
Check whether this value is a valid short value.

Specified by:
isValidShort in interface NumberValue
Returns:
true if this value has no fractional part, and is within the range of Short.MIN_VALUE and Short.MAX_VALUE; otherwise returns false

isValidInt

public boolean isValidInt()
Description copied from interface: NumberValue
Check whether this value is a valid integer value.

Specified by:
isValidInt in interface NumberValue
Returns:
true if this value has no fractional part, and is within the range of Integer.MIN_VALUE and Integer.MAX_VALUE; otherwise returns false

isValidLong

public boolean isValidLong()
Description copied from interface: NumberValue
Check whether this value is a valid long value.

Specified by:
isValidLong in interface NumberValue
Returns:
true if this value has no fractional part, and is within the range of Long.MIN_VALUE and Long.MAX_VALUE; otherwise returns false

isWhole

public boolean isWhole()
Description copied from interface: NumberValue
Returns true if this number has no decimal component

Specified by:
isWhole in interface NumberValue
Returns:
true if this number has no decimal component, otherwise false (float, double values);

writeTo

public void writeTo(MessagePacker pk)
             throws java.io.IOException
Specified by:
writeTo in interface ValueRef
Throws:
java.io.IOException

accept

public void accept(ValueVisitor visitor)
Specified by:
accept in interface ValueRef

toValue

public IntegerValue toValue()
Description copied from interface: ValueRef
Create an immutable value from this reference

Specified by:
toValue in interface IntegerValue
Specified by:
toValue in interface ValueRef
Returns:

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object