|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.at4j.support.lang.UnsignedShort
public final class UnsignedShort
This object represents an unsigned short value (two bytes or 16 bits) with a
value between {code 0} and 65535. It is immutable.
Unsigned shorts are created by calling any of the static creation methods of this class.
UnsignedByte,
UnsignedInteger,
UnsignedLong,
Serialized Form| Field Summary | |
|---|---|
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. |
| Method Summary | |
|---|---|
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(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. |
| 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 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
| Method Detail |
|---|
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(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 two positions by this method.
UnexpectedEofException - If the end of the file is reached before
two bytes have been read.
WrappedIOException - On I/O errors.
public static UnsignedShort readBigEndian(InputStream is)
throws UnexpectedEofException,
WrappedIOException
is - The stream to read from.
UnexpectedEofException - If the end of the stream is reached before
two bytes have been read.
WrappedIOException - On I/O errors.public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic int compareTo(UnsignedShort s2)
compareTo in interface Comparable<UnsignedShort>public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||