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