ByteFieldpublic class ByteField extends Object implements FixedFieldrepresentation of a byte (8-bit) field at a fixed location within a
byte array |
Fields Summary |
---|
private static final byte | _default_value | private byte | _value | private final int | _offset |
Constructors Summary |
---|
public ByteField(int offset)construct the ByteField with its offset into its containing
byte array and a default value of 0
this(offset, _default_value);
| public ByteField(int offset, byte value)construct the ByteField with its offset into its containing
byte array and initialize its value
if (offset < 0)
{
throw new ArrayIndexOutOfBoundsException(
"offset cannot be negative");
}
_offset = offset;
set(value);
| public ByteField(int offset, byte[] data)Construct the ByteField with its offset into its containing
byte array and initialize its value from its byte array
this(offset);
readFromBytes(data);
| public ByteField(int offset, byte value, byte[] data)construct the ByteField with its offset into its containing
byte array, initialize its value, and write its value to its
byte array
this(offset, value);
writeToBytes(data);
|
Methods Summary |
---|
public byte | get()get the ByteField's current value
return _value;
| public void | readFromBytes(byte[] data)set the value from its offset into an array of bytes
_value = data[ _offset ];
| public void | readFromStream(java.io.InputStream stream)set the value from an InputStream
_value =
(LittleEndian.readFromStream(stream,
LittleEndianConsts.BYTE_SIZE))[ 0 ];
| public void | set(byte value)set the ByteField's current value
_value = value;
| public void | set(byte value, byte[] data)set the ByteField's current value and write it to a byte array
set(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
data[ _offset ] = _value;
|
|