org.at4j.support.lang
Class SignedLong

java.lang.Object
  extended by org.at4j.support.lang.SignedLong
All Implemented Interfaces:
Comparable<SignedLong>

public class SignedLong
extends Object
implements Comparable<SignedLong>

This class represents a signed long value (i.e. a plain long value). If the Long class had not been declared final, this class would probably have extended it.

Signed long objects are created by calling any of the static creation methods on this class.

Instances of this class are immutable.

Since:
1.0
Author:
Karl Gustafsson
See Also:
UnsignedLong, SignedInteger

Field Summary
static SignedLong ONE
          This constant represents the value 1.
static SignedLong ZERO
          This constant represents the value 0.
 
Method Summary
 int compareTo(SignedLong l2)
           
 boolean equals(Object o)
           
static SignedLong fromBigEndianByteArray(byte[] barr)
          Create a signed long value from an eight bytes long big-endian byte array.
static SignedLong fromLittleEndianByteArray(byte[] barr)
          Create a signed long value from an eight bytes long little-endian byte array.
 byte[] getBigEndianByteArray()
          Get the signed long value represented as a big-endian byte array (eight bytes long).
 byte[] getLittleEndianByteArray()
          Get the signed long value represented as a little-endian byte array (eight bytes long).
 int hashCode()
           
 long longValue()
          Get the signed long value.
 String toString()
           
static SignedLong valueOf(long value)
          Create a new signed long value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final SignedLong ZERO
This constant represents the value 0.


ONE

public static final SignedLong ONE
This constant represents the value 1.

Method Detail

valueOf

public static SignedLong valueOf(long value)
Create a new signed long value.

Parameters:
value - The long value.
Returns:
The signed long value.

longValue

public long longValue()
Get the signed long value.

Returns:
The signed long value.

getBigEndianByteArray

public byte[] getBigEndianByteArray()
Get the signed long value represented as a big-endian byte array (eight bytes long).

Returns:
The long value represented as a big-endian byte array.
See Also:
fromBigEndianByteArray(byte[]), getLittleEndianByteArray()

fromBigEndianByteArray

public static SignedLong fromBigEndianByteArray(byte[] barr)
                                         throws IllegalArgumentException
Create a signed long value from an eight bytes long big-endian byte array.

Parameters:
barr - The byte array. It must be eight bytes long.
Returns:
The signed long value.
Throws:
IllegalArgumentException - If the byte array is not eight bytes long.
See Also:
getBigEndianByteArray(), fromLittleEndianByteArray(byte[])

getLittleEndianByteArray

public byte[] getLittleEndianByteArray()
Get the signed long value represented as a little-endian byte array (eight bytes long).

Returns:
The long value represented as a little-endian byte array.
See Also:
getBigEndianByteArray(), fromBigEndianByteArray(byte[])

fromLittleEndianByteArray

public static SignedLong fromLittleEndianByteArray(byte[] barr)
                                            throws IllegalArgumentException
Create a signed long value from an eight bytes long little-endian byte array.

Parameters:
barr - The byte array. It must be eight bytes long.
Returns:
The signed long value.
Throws:
IllegalArgumentException - If the byte array is not eight bytes long.
See Also:
getLittleEndianByteArray(), fromBigEndianByteArray(byte[])

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(SignedLong l2)
Specified by:
compareTo in interface Comparable<SignedLong>

toString

public String toString()
Overrides:
toString in class Object