Package loci.poi.hssf.record
Class RecordInputStream
- java.lang.Object
-
- java.io.InputStream
-
- loci.poi.hssf.record.RecordInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class RecordInputStream extends InputStream
Title: Record Input StreamDescription: Wraps a stream and provides helper methods for the construction of records.
- Author:
- Jason Height (jheight @ apache dot org)
-
-
Field Summary
Fields Modifier and Type Field Description protected short
currentLength
protected short
currentSid
protected byte[]
data
static short
MAX_RECORD_DATA_SIZE
Maximum size of a single record (minus the 4 byte header) without a continueprotected short
nextSid
protected long
pos
protected short
recordOffset
-
Constructor Summary
Constructors Constructor Description RecordInputStream(InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
checkRecordPosition()
boolean
getAutoContinue()
short
getLength()
byte[]
getNANData()
long
getPos()
short
getRecordOffset()
short
getSid()
boolean
hasNextRecord()
boolean
isContinueNext()
Returns true iif a Continue record is next in the excel streamvoid
nextRecord()
Moves to the next record in the stream.int
read()
This method will read a byte from the current recordbyte[]
readAllContinuedRemainder()
Deprecated.Best to write a input stream that wraps this one where there is special sub record that may overlap continue records.byte
readByte()
String
readCompressedUnicode(int length)
double
readDouble()
int
readInt()
long
readLong()
byte[]
readRemainder()
Returns the remaining bytes for the current record.short
readShort()
short[]
readShortArray()
String
readUnicodeLEString(int length)
given a byte array of 16-bit unicode characters, compress to 8-bit and return a string { 0x16, 0x00 } -0x16UnicodeString
readUnicodeString()
Returns an excel style unicode string from the bytes reminaing in the record.int
readUShort()
int
remaining()
The remaining number of bytes in the current record.void
setAutoContinue(boolean enable)
-
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Field Detail
-
MAX_RECORD_DATA_SIZE
public static final short MAX_RECORD_DATA_SIZE
Maximum size of a single record (minus the 4 byte header) without a continue- See Also:
- Constant Field Values
-
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 Detail
-
RecordInputStream
public RecordInputStream(InputStream in) throws RecordFormatException
- Throws:
RecordFormatException
-
-
Method Detail
-
read
public int read() throws IOException
This method will read a byte from the current record- Specified by:
read
in classInputStream
- Throws:
IOException
-
getSid
public short getSid()
-
getLength
public short getLength()
-
getRecordOffset
public short getRecordOffset()
-
getPos
public long getPos()
-
hasNextRecord
public boolean hasNextRecord()
-
nextRecord
public void nextRecord() throws RecordFormatException
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
public String readUnicodeLEString(int length)
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
public String readCompressedUnicode(int length)
-
readUnicodeString
public UnicodeString 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.
-
-