Class ContinuableRecordOutput

java.lang.Object
org.apache.poi.hssf.record.cont.ContinuableRecordOutput
All Implemented Interfaces:
LittleEndianOutput

public final class ContinuableRecordOutput extends Object implements LittleEndianOutput
An augmented LittleEndianOutput used for serialization of ContinuableRecords. This class keeps track of how much remaining space is available in the current BIFF record and can start new ContinueRecords as required.
  • Constructor Details

    • ContinuableRecordOutput

      public ContinuableRecordOutput(LittleEndianOutput out, int sid)
  • Method Details

    • createForCountingOnly

      public static ContinuableRecordOutput createForCountingOnly()
    • getTotalSize

      public int getTotalSize()
      Returns:
      total number of bytes written so far (including all BIFF headers)
    • getAvailableSpace

      public int getAvailableSpace()
      Returns:
      number of remaining bytes of space in current record
    • writeContinue

      public void writeContinue()
      Terminates the current record and starts a new ContinueRecord (regardless of how much space is still available in the current record).
    • writeContinueIfRequired

      public void writeContinueIfRequired(int requiredContinuousSize)
      Will terminate the current record and start a new ContinueRecord if there isn't space for the requested number of bytes
      Parameters:
      requiredContinuousSize - The number of bytes that need to be written
    • writeStringData

      public void writeStringData(String text)
      Writes the 'optionFlags' byte and encoded character data of a unicode string. This includes:
      • byte optionFlags
      • encoded character data (in "ISO-8859-1" or "UTF-16LE" encoding)
      Notes:
      • The value of the 'is16bitEncoded' flag is determined by the actual character data of text
      • The string options flag is never separated (by a ContinueRecord) from the first chunk of character data it refers to.
      • The 'ushort length' field is assumed to have been explicitly written earlier. Hence, there may be an intervening ContinueRecord
    • writeString

      public void writeString(String text, int numberOfRichTextRuns, int extendedDataSize)
      Writes a unicode string complete with header and character data. This includes:
      • ushort length
      • byte optionFlags
      • ushort numberOfRichTextRuns (optional)
      • ushort extendedDataSize (optional)
      • encoded character data (in "ISO-8859-1" or "UTF-16LE" encoding)
      The following bits of the 'optionFlags' byte will be set as appropriate:
      MaskDescription
      0x01is16bitEncoded
      0x04hasExtendedData
      0x08isRichText
      Notes:
      • The value of the 'is16bitEncoded' flag is determined by the actual character data of text
      • The string header fields are never separated (by a ContinueRecord) from the first chunk of character data (i.e. the first character is always encoded in the same record as the string header).
    • write

      public void write(byte[] b)
      Specified by:
      write in interface LittleEndianOutput
    • write

      public void write(byte[] b, int offset, int len)
      Specified by:
      write in interface LittleEndianOutput
    • writeByte

      public void writeByte(int v)
      Specified by:
      writeByte in interface LittleEndianOutput
    • writeDouble

      public void writeDouble(double v)
      Specified by:
      writeDouble in interface LittleEndianOutput
    • writeInt

      public void writeInt(int v)
      Specified by:
      writeInt in interface LittleEndianOutput
    • writeLong

      public void writeLong(long v)
      Specified by:
      writeLong in interface LittleEndianOutput
    • writeShort

      public void writeShort(int v)
      Specified by:
      writeShort in interface LittleEndianOutput