representation of a byte (8-bit) field at a fixed location within a byte array @author Marc Johnson (mjohnson at apache dot org
| 32 | */ |
| 33 | |
| 34 | public class ByteField |
| 35 | implements FixedField |
| 36 | { |
| 37 | private static final byte _default_value = 0; |
| 38 | private byte _value; |
| 39 | private final int _offset; |
| 40 | |
| 41 | /** |
| 42 | * construct the ByteField with its offset into its containing |
| 43 | * byte array and a default value of 0 |
| 44 | * |
| 45 | * @param offset of the field within its byte array |
| 46 | * |
| 47 | * @exception ArrayIndexOutOfBoundsException if offset is negative |
| 48 | */ |
| 49 | |
| 50 | public ByteField(final int offset) |
| 51 | throws ArrayIndexOutOfBoundsException |
| 52 | { |
| 53 | this(offset, _default_value); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * construct the ByteField with its offset into its containing |
| 58 | * byte array and initialize its value |
| 59 | * |
| 60 | * @param offset of the field within its byte array |
| 61 | * @param value the initial value |
| 62 | * |
| 63 | * @exception ArrayIndexOutOfBoundsException if offset is negative |
| 64 | */ |
| 65 | |
| 66 | public ByteField(final int offset, final byte value) |
| 67 | throws ArrayIndexOutOfBoundsException |
| 68 | { |
| 69 | if (offset < 0) |
| 70 | { |
| 71 | throw new ArrayIndexOutOfBoundsException( |
| 72 | "offset cannot be negative"); |
| 73 | } |
| 74 | _offset = offset; |
| 75 | set(value); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Construct the ByteField with its offset into its containing |
| 80 | * byte array and initialize its value from its byte array |
| 81 | * |
| 82 | * @param offset of the field within its byte array |
| 83 | * @param data the byte array to read the value from |
| 84 | * |
| 85 | * @exception ArrayIndexOutOfBoundsException if the offset is not |
| 86 | * within the range of 0..(data.length - 1) |
| 87 | */ |
| 88 | |
| 89 | public ByteField(final int offset, final byte [] data) |
| 90 | throws ArrayIndexOutOfBoundsException |
| 91 | { |
nothing calls this directly
no outgoing calls
no test coverage detected