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 Stream

Description: Wraps a stream and provides helper methods for the construction of records.

Author:
Jason Height (jheight @ apache dot org)
  • Field Details

    • 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:
    • 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

  • Method Details

    • read

      public int read() throws IOException
      This method will read a byte from the current record
      Specified by:
      read in class InputStream
      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.