ShortFieldpublic class ShortField extends Object implements FixedFieldrepresentation of a short (16-bit) field at a fixed location within
a byte array |
Fields Summary |
---|
private short | _value | private final int | _offset |
Constructors Summary |
---|
public ShortField(int offset)construct the ShortField with its offset into its containing
byte array
if (offset < 0)
{
throw new ArrayIndexOutOfBoundsException("Illegal offset: "
+ offset);
}
_offset = offset;
| public ShortField(int offset, short value)construct the ShortField with its offset into its containing
byte array and initialize its value
this(offset);
set(value);
| public ShortField(int offset, byte[] data)Construct the ShortField with its offset into its containing
byte array and initialize its value from its byte array
this(offset);
readFromBytes(data);
| public ShortField(int offset, short value, byte[] data)construct the ShortField with its offset into its containing
byte array, initialize its value, and write its value to its
byte array
this(offset);
set(value, data);
|
Methods Summary |
---|
public short | get()get the ShortField's current value
return _value;
| public void | readFromBytes(byte[] data)set the value from its offset into an array of bytes
_value = LittleEndian.getShort(data, _offset);
| public void | readFromStream(java.io.InputStream stream)set the value from an InputStream
_value = LittleEndian.readShort(stream);
| public void | set(short value)set the ShortField's current value
_value = value;
| public void | set(short value, byte[] data)set the ShortField's current value and write it to a byte array
_value = value;
writeToBytes(data);
| public java.lang.String | toString()return the value as a String
return String.valueOf(_value);
| public void | writeToBytes(byte[] data)write the value out to an array of bytes at the appropriate
offset
LittleEndian.putShort(data, _offset, _value);
|
|