Package loci.poi.hssf.record
Class RecordInputStream
java.lang.Object
java.io.InputStream
loci.poi.hssf.record.RecordInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Title: Record Input Stream
Description: Wraps a stream and provides helper methods for the construction of records.
- Author:
- Jason Height (jheight @ apache dot org)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected shortprotected shortprotected byte[]static final shortMaximum size of a single record (minus the 4 byte header) without a continueprotected shortprotected longprotected short -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleanshortbyte[]longgetPos()shortshortgetSid()booleanbooleanReturns true iif a Continue record is next in the excel streamvoidMoves to the next record in the stream.intread()This method will read a byte from the current recordbyte[]Deprecated.Best to write a input stream that wraps this one where there is special sub record that may overlap continue records.bytereadByte()readCompressedUnicode(int length) doubleintreadInt()longreadLong()byte[]Returns the remaining bytes for the current record.shortshort[]readUnicodeLEString(int length) given a byte array of 16-bit unicode characters, compress to 8-bit and return a string { 0x16, 0x00 } -0x16Returns an excel style unicode string from the bytes reminaing in the record.intintThe remaining number of bytes in the current record.voidsetAutoContinue(boolean enable) Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
MAX_RECORD_DATA_SIZE
public static final short MAX_RECORD_DATA_SIZEMaximum size of a single record (minus the 4 byte header) without a continue- See Also:
-
currentSid
protected short currentSid -
currentLength
protected short currentLength -
nextSid
protected short nextSid -
data
protected byte[] data -
recordOffset
protected short recordOffset -
pos
protected long pos
-
-
Constructor Details
-
RecordInputStream
- Throws:
RecordFormatException
-
-
Method Details
-
read
This method will read a byte from the current record- Specified by:
readin classInputStream- Throws:
IOException
-
getSid
public short getSid() -
getLength
public short getLength() -
getRecordOffset
public short getRecordOffset() -
getPos
public long getPos() -
hasNextRecord
public boolean hasNextRecord() -
nextRecord
Moves to the next record in the stream. Note: The auto continue flag is reset to true- Throws:
RecordFormatException
-
setAutoContinue
public void setAutoContinue(boolean enable) -
getAutoContinue
public boolean getAutoContinue() -
checkRecordPosition
protected void checkRecordPosition() -
readByte
public byte readByte() -
readShort
public short readShort() -
readInt
public int readInt() -
readLong
public long readLong() -
readUShort
public int readUShort() -
readDouble
public double readDouble() -
getNANData
public byte[] getNANData() -
readShortArray
public short[] readShortArray() -
readUnicodeLEString
given a byte array of 16-bit unicode characters, compress to 8-bit and return a string { 0x16, 0x00 } -0x16- Parameters:
length- the length of the final string- Returns:
- the converted string
- Throws:
IllegalArgumentException- if len is too large (i.e., there is not enough data in string to create a String of that length)
-
readCompressedUnicode
-
readUnicodeString
Returns an excel style unicode string from the bytes reminaing in the record. Note: Unicode strings differ from normal strings due to the addition of formatting information.- Returns:
- The unicode string representation of the remaining bytes.
-
readRemainder
public byte[] readRemainder()Returns the remaining bytes for the current record.- Returns:
- The remaining bytes of the current record.
-
readAllContinuedRemainder
public byte[] readAllContinuedRemainder()Deprecated.Best to write a input stream that wraps this one where there is special sub record that may overlap continue records.Reads all byte data for the current record, including any that overlaps into any following continue records. -
remaining
public int remaining()The remaining number of bytes in the current record.- Returns:
- The number of bytes remaining in the current record
-
isContinueNext
public boolean isContinueNext()Returns true iif a Continue record is next in the excel stream- Returns:
- True when a ContinueRecord is next.
-