Package org.apache.poi.util
Class ByteField
- java.lang.Object
- 
- org.apache.poi.util.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 SummaryConstructors Constructor Description ByteField(int offset)construct the ByteField with its offset into its containing byte array and a default value of 0ByteField(int offset, byte value)construct the ByteField with its offset into its containing byte array and initialize its valueByteField(int offset, byte[] data)Construct the ByteField with its offset into its containing byte array and initialize its value from its byte arrayByteField(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 SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description byteget()get the ByteField's current valuevoidreadFromBytes(byte[] data)set the value from its offset into an array of bytesvoidreadFromStream(InputStream stream)set the value from an InputStreamvoidset(byte value)set the ByteField's current valuevoidset(byte value, byte[] data)set the ByteField's current value and write it to a byte arrayStringtoString()return the value as a StringvoidwriteToBytes(byte[] data)write the value out to an array of bytes at the appropriate offset
 
- 
- 
- 
Constructor Detail- 
ByteFieldpublic ByteField(int offset) throws ArrayIndexOutOfBoundsExceptionconstruct 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:
- ArrayIndexOutOfBoundsException- if offset is negative
 
 - 
ByteFieldpublic ByteField(int offset, byte value) throws ArrayIndexOutOfBoundsExceptionconstruct 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
 
 - 
ByteFieldpublic ByteField(int offset, byte[] data) throws ArrayIndexOutOfBoundsExceptionConstruct 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)
 
 - 
ByteFieldpublic ByteField(int offset, byte value, byte[] data) throws ArrayIndexOutOfBoundsExceptionconstruct 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- 
getpublic byte get() get the ByteField's current value- Returns:
- current value
 
 - 
setpublic void set(byte value) set the ByteField's current value- Parameters:
- value- to be set
 
 - 
setpublic void set(byte value, byte[] data) throws ArrayIndexOutOfBoundsExceptionset 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
 
 - 
readFromBytespublic void readFromBytes(byte[] data) throws ArrayIndexOutOfBoundsExceptionset the value from its offset into an array of bytes- Specified by:
- readFromBytesin interface- FixedField
- Parameters:
- data- the byte array from which the value is to be read
- Throws:
- ArrayIndexOutOfBoundsException- if the offset is out of range of the bte array
 
 - 
readFromStreampublic void readFromStream(InputStream stream) throws IOException set the value from an InputStream- Specified by:
- readFromStreamin 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
- IOException- if an IOException is thrown from reading the InputStream
 
 - 
writeToBytespublic void writeToBytes(byte[] data) throws ArrayIndexOutOfBoundsExceptionwrite the value out to an array of bytes at the appropriate offset- Specified by:
- writeToBytesin interface- FixedField
- Parameters:
- data- the array of bytes to which the value is to be written
- Throws:
- ArrayIndexOutOfBoundsException- if the offset is out of the byte array's range
 
 - 
toStringpublic String toString() return the value as a String- Specified by:
- toStringin interface- FixedField
- Overrides:
- toStringin class- Object
- Returns:
- the value as a String
 
 
- 
 
-