Package loci.poi.util
Class LongField
java.lang.Object
loci.poi.util.LongField
- All Implemented Interfaces:
FixedField
representation of a long (16-bit) field at a fixed location within
a byte array
- Author:
- Marc Johnson (mjohnson at apache dot org
-
Constructor Summary
ConstructorsConstructorDescriptionLongField(int offset) construct the LongField with its offset into its containing byte arrayLongField(int offset, byte[] data) Construct the LongField with its offset into its containing byte array and initialize its value from its byte arrayLongField(int offset, long value) construct the LongField with its offset into its containing byte array and initialize its valueLongField(int offset, long value, byte[] data) construct the LongField with its offset into its containing byte array, initialize its value, and write the value to a byte array -
Method Summary
Modifier and TypeMethodDescriptionlongget()get the LongField's current valuevoidreadFromBytes(byte[] data) set the value from its offset into an array of bytesvoidreadFromStream(InputStream stream) set the value from an InputStreamvoidset(long value) set the LongField's current valuevoidset(long value, byte[] data) set the LongField's current value and write it to a byte arraytoString()return the value as a StringvoidwriteToBytes(byte[] data) write the value out to an array of bytes at the appropriate offset
-
Constructor Details
-
LongField
construct the LongField with its offset into its containing byte array- Parameters:
offset- of the field within its byte array- Throws:
ArrayIndexOutOfBoundsException- if offset is negative
-
LongField
construct the LongField 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:
ArrayIndexOutOfBoundsException- if offset is negative
-
LongField
Construct the LongField 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:
ArrayIndexOutOfBoundsException- if the offset is not within the range of 0..(data.length - 1)
-
LongField
construct the LongField 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:
ArrayIndexOutOfBoundsException- if offset is negative
-
-
Method Details
-
get
public long get()get the LongField's current value- Returns:
- current value
-
set
public void set(long value) set the LongField's current value- Parameters:
value- to be set
-
set
set the LongField's current value and write it to a byte array- Parameters:
value- to be setdata- the byte array to write the value to- Throws:
ArrayIndexOutOfBoundsException- if the offset is out of range
-
readFromBytes
set the value from its offset into an array of bytes- Specified by:
readFromBytesin interfaceFixedField- Parameters:
data- the byte array from which the value is to be read- Throws:
ArrayIndexOutOfBoundsException- if the offset is out of range
-
readFromStream
public void readFromStream(InputStream stream) throws IOException, LittleEndian.BufferUnderrunException set the value from an InputStream- Specified by:
readFromStreamin 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 InputStreamIOException- if an IOException is thrown from reading the InputStream
-
writeToBytes
write the value out to an array of bytes at the appropriate offset- Specified by:
writeToBytesin interfaceFixedField- Parameters:
data- the array of bytes to which the value is to be written- Throws:
ArrayIndexOutOfBoundsException- if the offset is out of range
-
toString
return the value as a String- Specified by:
toStringin interfaceFixedField- Overrides:
toStringin classObject- Returns:
- the value as a String
-