Class ByteField

  • All Implemented Interfaces:
    FixedField

    public class ByteField
    extends Object
    implements FixedField
    representation of a byte (8-bit) field at a fixed location within a byte array
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteField​(int offset)
      construct the ByteField with its offset into its containing byte array and a default value of 0
      ByteField​(int offset, byte value)
      construct the ByteField with its offset into its containing byte array and initialize its value
      ByteField​(int offset, byte[] data)
      Construct the ByteField with its offset into its containing byte array and initialize its value from its byte array
      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
    • Constructor Detail

      • ByteField

        public ByteField​(int offset,
                         byte value)
                  throws ArrayIndexOutOfBoundsException
        construct the ByteField with its offset into its containing byte array and initialize its value
        Parameters:
        offset - of the field within its byte array
        value - the initial value
        Throws:
        ArrayIndexOutOfBoundsException - if offset is negative
      • ByteField

        public ByteField​(int offset,
                         byte[] data)
                  throws ArrayIndexOutOfBoundsException
        Construct the ByteField with its offset into its containing byte array and initialize its value from its byte array
        Parameters:
        offset - of the field within its byte array
        data - the byte array to read the value from
        Throws:
        ArrayIndexOutOfBoundsException - if the offset is not within the range of 0..(data.length - 1)
      • ByteField

        public ByteField​(int offset,
                         byte value,
                         byte[] data)
                  throws ArrayIndexOutOfBoundsException
        construct the ByteField with its offset into its containing byte array, initialize its value, and write its value to its byte array
        Parameters:
        offset - of the field within its byte array
        value - the initial value
        data - the byte array to write the value to
        Throws:
        ArrayIndexOutOfBoundsException - if the offset is not within the range of 0..(data.length - 1)
    • Method Detail

      • get

        public byte get()
        get the ByteField's current value
        Returns:
        current value
      • set

        public void set​(byte value)
        set the ByteField's current value
        Parameters:
        value - to be set
      • set

        public void set​(byte value,
                        byte[] data)
                 throws ArrayIndexOutOfBoundsException
        set the ByteField's current value and write it to a byte array
        Parameters:
        value - to be set
        data - the byte array to write the value to
        Throws:
        ArrayIndexOutOfBoundsException - if the offset is out of the byte array's range