Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.util
Class ByteField

    java.lang.Object
      org.apache.poi.util.ByteField

All Implemented Interfaces:
  FixedField

    public class ByteField

extends java.lang.Object
implements FixedField

representation of a byte (8-bit) field at a fixed location within a byte array

Author:
  Marc Johnson (mjohnson at apache dot org

Constructor Summary
`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

Method Summary
`byte` | `get()` get the ByteField's current value
`void` | `readFromBytes(byte[] data)` set the value from its offset into an array of bytes
`void` | `readFromStream(java.io.InputStream stream)` set the value from an InputStream
`void` | `set(byte value)` set the ByteField's current value
`void` | `set(byte value, byte[] data)` set the ByteField's current value and write it to a byte array
`java.lang.String` | `toString()` return the value as a String
`void` | `writeToBytes(byte[] data)` write the value out to an array of bytes at the appropriate offset

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ByteField

    public ByteField(int offset)
              throws java.lang.ArrayIndexOutOfBoundsException

  construct the ByteField with its offset into its containing byte array and a default value of 0

  Parameters:
    `offset` - of the field within its byte array
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException` - if offset is negative

### ByteField

    public ByteField(int offset,
                     byte value)
              throws java.lang.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:
    `java.lang.ArrayIndexOutOfBoundsException` - if offset is negative

### ByteField

    public ByteField(int offset,
                     byte[] data)
              throws java.lang.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:
    `java.lang.ArrayIndexOutOfBoundsException` - if the offset is not within the range of 0..(data.length - 1)

### ByteField

    public ByteField(int offset,
                     byte value,
                     byte[] data)
              throws java.lang.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:
    `java.lang.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 java.lang.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:
    `java.lang.ArrayIndexOutOfBoundsException` - if the offset is out of the byte array's range

### readFromBytes

    public void readFromBytes(byte[] data)
                       throws java.lang.ArrayIndexOutOfBoundsException

  set the value from its offset into an array of bytes

  Specified by:
    `readFromBytes` in interface `FixedField`
  Parameters:
    `data` - the byte array from which the value is to be read
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException` - if the offset is out of range of the bte array

### readFromStream

    public void readFromStream(java.io.InputStream stream)
                        throws java.io.IOException,
                               LittleEndian.BufferUnderrunException

  set the value from an InputStream

  Specified by:
    `readFromStream` in interface `FixedField`
  Parameters:
    `stream` - the InputStream from which the value is to be read
  Throws:
    `LittleEndian.BufferUnderrunException` - if there is not enough data available from the InputStream
    `java.io.IOException` - if an IOException is thrown from reading the InputStream

### writeToBytes

    public void writeToBytes(byte[] data)
                      throws java.lang.ArrayIndexOutOfBoundsException

  write the value out to an array of bytes at the appropriate offset

  Specified by:
    `writeToBytes` in interface `FixedField`
  Parameters:
    `data` - the array of bytes to which the value is to be written
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException` - if the offset is out of the byte array's range

### toString

    public java.lang.String toString()

  return the value as a String

  Specified by:
    `toString` in interface `FixedField`
  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the value as a String

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2010 The Apache Software Foundation or its licensors, as applicable.