|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.at4j.support.lang.UnsignedInteger
public final class UnsignedInteger
This object represents an unsigned integer (four bytes or 32 bits) with a
value between {code 0} and 4294967295
. It is immutable.
Unsigned integers are created by calling any of the static creation methods of this class.
SignedInteger
,
UnsignedByte
,
UnsignedShort
,
UnsignedLong
,
Serialized FormField Summary | |
---|---|
static long |
MAX_VALUE
The maximum value of an unsigned integer (4294967295). |
static int |
MIN_VALUE
The minimum value of an unsigned integer (0). |
static UnsignedInteger |
ONE
The value 1. |
static int |
SIZE
Each unsigned integer is four bytes long. |
static UnsignedInteger |
ZERO
The value 0. |
Method Summary | |
---|---|
int |
compareTo(UnsignedInteger i2)
|
boolean |
equals(Object o)
|
static UnsignedInteger |
fromBigEndianByteArray(byte[] barr)
Create an unsigned integer value from a four bytes long, big-endian byte array. |
static UnsignedInteger |
fromBigEndianByteArray(byte[] barr,
int offset)
Create an unsigned integer value from four bytes read from the given offset position in the supplied byte array. |
static long |
fromBigEndianByteArrayToLong(byte[] barr,
int offset)
Create a long value representing the unsigned integer value in the byte array at the specified offset. |
static long |
fromLittleEndianByteArrayToLong(byte[] barr,
int offset)
Create a long value representing the unsigned integer value in the byte array at the specified offset. |
byte[] |
getBigEndianByteArray()
Get the unsigned integer value as a big-endian, four bytes long byte array. |
int |
hashCode()
|
int |
intValue()
Get the unsigned integer value converted to a signed integer. |
long |
longValue()
Get the unsigned integer value represented as a long . |
static UnsignedInteger |
readBigEndian(InputStream is)
Create an unsigned integer value from four bytes read from the stream. |
static UnsignedInteger |
readBigEndian(RandomAccess ra)
Create an unsigned integer value from four bytes read starting from the current position in the supplied RandomAccess . |
String |
toString()
|
static UnsignedInteger |
valueOf(int value)
Create a new unsigned integer. |
static UnsignedInteger |
valueOf(long value)
Create an unsigned integer from the supplied long value which must be between 0 and 4294967295 (inclusive). |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SIZE
public static final long MAX_VALUE
public static final int MIN_VALUE
public static final UnsignedInteger ZERO
public static final UnsignedInteger ONE
Method Detail |
---|
public static UnsignedInteger valueOf(int value)
2147483648
and 4294967295
(inclusive).
value
- The signed integer value.
public static UnsignedInteger valueOf(long value) throws IllegalArgumentException
0
and 4294967295
(inclusive).
value
- The value.
IllegalArgumentException
- If the supplied value is not in the
permitted range.public long longValue()
long
.
public int intValue()
public byte[] getBigEndianByteArray()
public static UnsignedInteger fromBigEndianByteArray(byte[] barr) throws IllegalArgumentException
barr
- The byte array. It must be four bytes long.
IllegalArgumentException
- If the supplied byte array is not four
bytes long.fromBigEndianByteArray(byte[], int)
,
fromBigEndianByteArrayToLong(byte[], int)
public static UnsignedInteger fromBigEndianByteArray(byte[] barr, int offset) throws ArrayIndexOutOfBoundsException
barr
- The byte array to read from.offset
- The offset in the byte array where the least significant
(first) byte is.
ArrayIndexOutOfBoundsException
- If the supplied array is too short
or if the offset is negative.fromBigEndianByteArray(byte[])
,
fromBigEndianByteArrayToLong(byte[], int)
public static long fromBigEndianByteArrayToLong(byte[] barr, int offset) throws ArrayIndexOutOfBoundsException
barr
- The byte array to read from.offset
- The offset in the byte array where the least significant
(first) byte is.
long
representing the unsigned integer.
ArrayIndexOutOfBoundsException
- If the supplied array is too short
or if the offset is negative.fromBigEndianByteArray(byte[])
,
fromBigEndianByteArray(byte[], int)
,
fromLittleEndianByteArrayToLong(byte[], int)
public static long fromLittleEndianByteArrayToLong(byte[] barr, int offset) throws ArrayIndexOutOfBoundsException
barr
- The byte array to read from.offset
- The offset in the byte array where the most significant
(first) byte is.
long
representing the unsigned integer.
ArrayIndexOutOfBoundsException
- If the supplied array is too short
or if the offset is negative.fromBigEndianByteArrayToLong(byte[], int)
public static UnsignedInteger readBigEndian(RandomAccess ra) throws UnexpectedEofException, WrappedIOException
RandomAccess
. The most
significant byte is the last byte read.
ra
- The RandomAccess
to read from. The current position is
advanced four positions by this method.
UnexpectedEofException
- If the end of the file is reached before
four bytes have been read.
WrappedIOException
- On I/O errors.public static UnsignedInteger readBigEndian(InputStream is) throws UnexpectedEofException, WrappedIOException
is
- The stream to read from.
UnexpectedEofException
- If the end of the stream is reached before
four bytes have been read.
WrappedIOException
- On I/O errors.public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(UnsignedInteger i2)
compareTo
in interface Comparable<UnsignedInteger>
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |