com.ericsson.otp.erlang
Class OtpErlangLong

java.lang.Object
  |
  +--com.ericsson.otp.erlang.OtpErlangObject
        |
        +--com.ericsson.otp.erlang.OtpErlangLong
Direct Known Subclasses:
OtpErlangByte, OtpErlangChar, OtpErlangInt, OtpErlangShort, OtpErlangUInt, OtpErlangUShort

public class OtpErlangLong
extends OtpErlangObject
implements java.io.Serializable, java.lang.Cloneable

Provides a Java representation of Erlang integral types. Erlang does not distinguish between different integral types, however this class and its subclasses OtpErlangByte, OtpErlangChar, OtpErlangInt, and OtpErlangShort attempt to map the Erlang types onto the various Java integral types. Two additional classes, OtpErlangUInt and OtpErlangUShort are provided for Corba compatibility. See the documentation for IC for more information.

See Also:
Serialized Form

Constructor Summary
OtpErlangLong(long l)
          Create an Erlang integer from the given value.
OtpErlangLong(OtpInputStream buf)
          Create an Erlang integer from a stream containing an integer encoded in Erlang external format.
 
Method Summary
 byte byteValue()
          Get this number as a byte.
 char charValue()
          Get this number as a char.
 void encode(OtpOutputStream buf)
          Convert this number to the equivalent Erlang external representation.
 boolean equals(java.lang.Object o)
          Determine if two numbers are equal.
 int intValue()
          Get this number as an int.
 long longValue()
          Get this number as a long.
 short shortValue()
          Get this number as a short.
 java.lang.String toString()
          Get the string representation of this number.
 int uIntValue()
          Get this number as a non-negative int.
 short uShortValue()
          Get this number as a non-negative short.
 
Methods inherited from class com.ericsson.otp.erlang.OtpErlangObject
clone, decode
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OtpErlangLong

public OtpErlangLong(long l)
Create an Erlang integer from the given value.
Parameters:
l - the long value to use.

OtpErlangLong

public OtpErlangLong(OtpInputStream buf)
              throws OtpErlangDecodeException
Create an Erlang integer from a stream containing an integer encoded in Erlang external format.
Parameters:
buf - the stream containing the encoded value.
Throws:
OtpErlangDecodeException - if the buffer does not contain a valid external representation of an Erlang integer.
Method Detail

longValue

public long longValue()
Get this number as a long.
Returns:
the value of this number, as a long.

intValue

public int intValue()
             throws OtpErlangRangeException
Get this number as an int.
Returns:
the value of this number, as an int.
Throws:
OtpErlangRangeException - if the value is too large to be represented as an int.

uIntValue

public int uIntValue()
              throws OtpErlangRangeException
Get this number as a non-negative int.
Returns:
the value of this number, as an int.
Throws:
OtpErlangRangeException - if the value is too large to be represented as an int, or if the value is negative.

shortValue

public short shortValue()
                 throws OtpErlangRangeException
Get this number as a short.
Returns:
the value of this number, as a short.
Throws:
OtpErlangRangeException - if the value is too large to be represented as a short.

uShortValue

public short uShortValue()
                  throws OtpErlangRangeException
Get this number as a non-negative short.
Returns:
the value of this number, as a short.
Throws:
OtpErlangRangeException - if the value is too large to be represented as a short, or if the value is negative.

charValue

public char charValue()
               throws OtpErlangRangeException
Get this number as a char.
Returns:
the char value of this number.
Throws:
OtpErlangRangeException - if the value is too large to be represented as a char.

byteValue

public byte byteValue()
               throws OtpErlangRangeException
Get this number as a byte.
Returns:
the byte value of this number.
Throws:
OtpErlangRangeException - if the value is too large to be represented as a byte.

toString

public java.lang.String toString()
Get the string representation of this number.
Overrides:
toString in class OtpErlangObject
Returns:
the string representation of this number.

encode

public void encode(OtpOutputStream buf)
Convert this number to the equivalent Erlang external representation.
Overrides:
encode in class OtpErlangObject
Parameters:
buf - an output stream to which the encoded number should be written.

equals

public boolean equals(java.lang.Object o)
Determine if two numbers are equal. Numbers are equal if they contain the same value.
Overrides:
equals in class OtpErlangObject
Parameters:
o - the number to compare to.
Returns:
true if the numbers have the same value.