public final class UnsignedShort extends Object implements Serializable, Comparable<UnsignedShort>
65535
. It is immutable.
Unsigned shorts are created by calling any of the static creation methods of this class.
UnsignedByte
,
UnsignedInteger
,
UnsignedLong
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
MAX_VALUE
The maximum value of an unsigned short (65535).
|
static int |
MIN_VALUE
The minimum value of an unsigned short (0).
|
static UnsignedShort |
ONE
The value 1.
|
static UnsignedShort |
ONE_THOUSAND
The value 1000.
|
static int |
SIZE
Each unsigned short is two bytes long.
|
static UnsignedShort |
ZERO
The value 0.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(UnsignedShort s2) |
boolean |
equals(Object o) |
static UnsignedShort |
fromBigEndianByteArray(byte[] barr)
Create an unsigned short value from a two bytes long, big-endian byte
array.
|
static UnsignedShort |
fromBigEndianByteArray(byte[] barr,
int offset)
Create an unsigned short value from two bytes read from the given offset
position in the supplied byte array.
|
byte[] |
getBigEndianByteArray()
Get the unsigned short value as a big-endian, two bytes long byte array.
|
int |
hashCode() |
int |
intValue()
Get the unsigned short value.
|
static UnsignedShort |
readBigEndian(InputStream is)
Create an unsigned short value from two bytes read from the stream.
|
static UnsignedShort |
readBigEndian(org.entityfs.RandomAccess ra)
Create an unsigned short value from two bytes read starting from the
current position in the supplied
RandomAccess . |
String |
toString() |
static UnsignedShort |
valueOf(int value)
Create an unsigned short from the supplied integer value which must be
between
0 and 65535 (inclusive). |
static UnsignedShort |
valueOf(short value)
Create a new unsigned short.
|
public static final int SIZE
public static final int MAX_VALUE
public static final int MIN_VALUE
public static final UnsignedShort ZERO
public static final UnsignedShort ONE
public static final UnsignedShort ONE_THOUSAND
public static UnsignedShort valueOf(short value)
32768
and 65535
(inclusive).value
- The signed short value.public static UnsignedShort valueOf(int value) throws IllegalArgumentException
0
and 65535
(inclusive).value
- The value.IllegalArgumentException
- If the supplied value is not in the
permitted range.public int intValue()
public byte[] getBigEndianByteArray()
public static UnsignedShort fromBigEndianByteArray(byte[] barr) throws IllegalArgumentException
barr
- The byte array. It must be two bytes long.IllegalArgumentException
- If the supplied byte array is not two
bytes long.fromBigEndianByteArray(byte[], int)
public static UnsignedShort 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 UnsignedShort 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 two positions by this method.org.entityfs.exception.UnexpectedEofException
- If the end of the file is reached before
two bytes have been read.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public static UnsignedShort 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
two bytes have been read.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public int compareTo(UnsignedShort s2)
compareTo
in interface Comparable<UnsignedShort>