Package org.apache.poi.util
Class IntegerField
- java.lang.Object
-
- org.apache.poi.util.IntegerField
-
- All Implemented Interfaces:
FixedField
public class IntegerField extends java.lang.Object implements FixedField
representation of an integer (32-bit) field at a fixed location within a byte array
-
-
Constructor Summary
Constructors Constructor Description IntegerField(int offset)
construct the IntegerField with its offset into its containing byte arrayIntegerField(int offset, byte[] data)
Construct the IntegerField with its offset into its containing byte array and initialize its value from its byte arrayIntegerField(int offset, int value)
construct the IntegerField with its offset into its containing byte array and initialize its valueIntegerField(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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
get()
get the IntegerField's current valuevoid
readFromBytes(byte[] data)
set the value from its offset into an array of bytesvoid
readFromStream(java.io.InputStream stream)
set the value from an InputStreamvoid
set(int value)
set the IntegerField's current valuevoid
set(int value, byte[] data)
set the IntegerField's current value and write it to a byte arrayjava.lang.String
toString()
return the value as a Stringvoid
writeToBytes(byte[] data)
write the value out to an array of bytes at the appropriate offset
-
-
-
Constructor Detail
-
IntegerField
public IntegerField(int offset) throws java.lang.ArrayIndexOutOfBoundsException
construct the IntegerField with its offset into its containing byte array- Parameters:
offset
- of the field within its byte array- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the offset is negative
-
IntegerField
public IntegerField(int offset, int value) throws java.lang.ArrayIndexOutOfBoundsException
construct the IntegerField with its offset into its containing byte array and initialize its value- Parameters:
offset
- of the field within its byte arrayvalue
- the initial value- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the offset is negative
-
IntegerField
public IntegerField(int offset, byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
Construct the IntegerField with its offset into its containing byte array and initialize its value from its byte array- Parameters:
offset
- of the field within its byte arraydata
- 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)
-
IntegerField
public IntegerField(int offset, int value, byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
construct the IntegerField with its offset into its containing byte array, initialize its value, and write the value to a byte array- Parameters:
offset
- of the field within its byte arrayvalue
- the initial valuedata
- the byte array to write the value to- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the offset is negative or too large
-
-
Method Detail
-
get
public int get()
get the IntegerField's current value- Returns:
- current value
-
set
public void set(int value)
set the IntegerField's current value- Parameters:
value
- to be set
-
set
public void set(int value, byte[] data) throws java.lang.ArrayIndexOutOfBoundsException
set the IntegerField's current value and write it to a byte array- Parameters:
value
- to be setdata
- the byte array to write the value to- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the offset is too large
-
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 interfaceFixedField
- Parameters:
data
- the byte array from which the value is to be read- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the offset is too large
-
readFromStream
public void readFromStream(java.io.InputStream stream) throws java.io.IOException
set the value from an InputStream- Specified by:
readFromStream
in interfaceFixedField
- Parameters:
stream
- the InputStream from which the value is to be read- Throws:
LittleEndian.BufferUnderrunException
- if there is not enough data available from the InputStreamjava.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 interfaceFixedField
- Parameters:
data
- the array of bytes to which the value is to be written- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the offset is too large
-
toString
public java.lang.String toString()
return the value as a String- Specified by:
toString
in interfaceFixedField
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the value as a String
-
-