org.at4j.support.lang
Class SignedInteger

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

public class SignedInteger
extends Object
implements Comparable<SignedInteger>

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

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

Instances of this class are immutable.

Since:
1.1.1
Author:
Karl Gustafsson
See Also:
UnsignedInteger, SignedLong

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

Field Detail

ZERO

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


ONE

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

Method Detail

valueOf

public static SignedInteger valueOf(int value)
Create a new signed integer value.

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

intValue

public long intValue()
Get the signed integer value.

Returns:
The signed integer value.

getBigEndianByteArray

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

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

fromBigEndianByteArray

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

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

getLittleEndianByteArray

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

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

fromLittleEndianByteArray

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

Parameters:
barr - The byte array. It must be four bytes long.
Returns:
The signed integer value.
Throws:
IllegalArgumentException - If the byte array is not four 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(SignedInteger l2)
Specified by:
compareTo in interface Comparable<SignedInteger>

toString

public String toString()
Overrides:
toString in class Object