public final class UnsignedInteger extends Object implements Serializable, Comparable<UnsignedInteger>
4294967295
. It is immutable.
Unsigned integers are created by calling any of the static creation methods of this class.
SignedInteger
,
UnsignedByte
,
UnsignedShort
,
UnsignedLong
,
Serialized FormModifier and Type | Field and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
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(org.entityfs.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). |
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
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(org.entityfs.RandomAccess ra) throws org.entityfs.exception.UnexpectedEofException, org.entityfs.support.exception.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.org.entityfs.exception.UnexpectedEofException
- If the end of the file is reached before
four bytes have been read.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public static UnsignedInteger readBigEndian(InputStream is) throws org.entityfs.exception.UnexpectedEofException, org.entityfs.support.exception.WrappedIOException
is
- The stream to read from.org.entityfs.exception.UnexpectedEofException
- If the end of the stream is reached before
four bytes have been read.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public int compareTo(UnsignedInteger i2)
compareTo
in interface Comparable<UnsignedInteger>