public final class UnsignedLong extends Object implements Serializable, Comparable<UnsignedLong>
18446744073709551615
. It is immutable.
Unsigned longs are created by calling any of the static creation methods of this class.
SignedLong
,
UnsignedByte
,
UnsignedShort
,
UnsignedInteger
,
Serialized FormModifier and Type | Field and Description |
---|---|
static BigInteger |
MAX_VALUE
The maximum allowed value (18446744073709551615).
|
static BigInteger |
MIN_VALUE
The minimum allowed value (0).
|
static UnsignedLong |
ONE
The value one.
|
static UnsignedLong |
ZERO
The value zero.
|
Modifier and Type | Method and Description |
---|---|
BigInteger |
bigIntValue()
Get the unsigned long value as a
BigInteger . |
int |
compareTo(UnsignedLong l2) |
boolean |
equals(Object o) |
static UnsignedLong |
fromBigEndianByteArray(byte[] barr)
Create an unsigned long value from a eight bytes long, big-endian byte
array.
|
static UnsignedLong |
fromBigEndianByteArray(byte[] barr,
int offset)
Create an unsigned long value from eight bytes read from the given offset
position in the supplied byte array.
|
byte[] |
getBigEndianByteArray()
Get the unsigned long value as a big-endian, eight bytes long byte array.
|
int |
hashCode() |
long |
longValue()
Return the value as a signed long.
|
static UnsignedLong |
readBigEndian(InputStream is)
Create an unsigned long value from eight bytes read from the stream.
|
static UnsignedLong |
readBigEndian(org.entityfs.RandomAccess ra)
Create an unsigned long value from eight bytes read starting from the
current position in the supplied
RandomAccess . |
String |
toString() |
static UnsignedLong |
valueOf(BigInteger value)
Create an unsigned long value from the supplied
BigInteger value
which must be in the range 0 to 18446744073709551615
(inclusive) |
static UnsignedLong |
valueOf(long value)
Create an unsigned long.
|
public static final BigInteger MIN_VALUE
public static final BigInteger MAX_VALUE
public static final UnsignedLong ZERO
public static final UnsignedLong ONE
public static UnsignedLong valueOf(long value)
9223372036854775808
and 18446744073709551615
(inclusive).value
- The value.public static UnsignedLong valueOf(BigInteger value) throws IllegalArgumentException
BigInteger
value
which must be in the range 0
to 18446744073709551615
(inclusive)value
- The value.IllegalArgumentException
- If the supplied value is negative or if
it is greater than MAX_VALUE
.public BigInteger bigIntValue()
BigInteger
.BigInteger
.public long longValue()
Long.MAX_VALUE
, it is returned as a positive long. If not, it is
returned as a negative long.public byte[] getBigEndianByteArray()
public static UnsignedLong fromBigEndianByteArray(byte[] barr) throws IllegalArgumentException
barr
- The byte array. It must be eight bytes long.IllegalArgumentException
- If the supplied byte array is not eight
bytes long.fromBigEndianByteArray(byte[], int)
public static UnsignedLong 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[])
public static UnsignedLong 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 eight positions by this method.org.entityfs.exception.UnexpectedEofException
- If the end of the file is reached before
eight bytes have been read.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public static UnsignedLong 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
eight bytes have been read.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public int compareTo(UnsignedLong l2)
compareTo
in interface Comparable<UnsignedLong>