Package org.apache.poi.hssf.record.cont
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 augmentedLittleEndianOutput
used for serialization ofContinuableRecord
s. This class keeps track of how much remaining space is available in the current BIFF record and can start newContinueRecord
s as required.
-
-
Constructor Summary
Constructors Constructor Description ContinuableRecordOutput(LittleEndianOutput out, int sid)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ContinuableRecordOutput
createForCountingOnly()
int
getAvailableSpace()
int
getTotalSize()
void
write(byte[] b)
void
write(byte[] b, int offset, int len)
void
writeByte(int v)
void
writeContinue()
Terminates the current record and starts a newContinueRecord
(regardless of how much space is still available in the current record).void
writeContinueIfRequired(int requiredContinuousSize)
Will terminate the current record and start a newContinueRecord
if there isn't space for the requested number of bytesvoid
writeDouble(double v)
void
writeInt(int v)
void
writeLong(long v)
void
writeShort(int v)
void
writeString(String text, int numberOfRichTextRuns, int extendedDataSize)
Writes a unicode string complete with header and character data.void
writeStringData(String text)
Writes the 'optionFlags' byte and encoded character data of a unicode string.
-
-
-
Constructor Detail
-
ContinuableRecordOutput
public ContinuableRecordOutput(LittleEndianOutput out, int sid)
-
-
Method Detail
-
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 newContinueRecord
(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 newContinueRecord
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)
- 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)
bits of the 'optionFlags' Mask Description 0x01 is16bitEncoded 0x04 hasExtendedData 0x08 isRichText - 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 interfaceLittleEndianOutput
-
write
public void write(byte[] b, int offset, int len)
- Specified by:
write
in interfaceLittleEndianOutput
-
writeByte
public void writeByte(int v)
- Specified by:
writeByte
in interfaceLittleEndianOutput
-
writeDouble
public void writeDouble(double v)
- Specified by:
writeDouble
in interfaceLittleEndianOutput
-
writeInt
public void writeInt(int v)
- Specified by:
writeInt
in interfaceLittleEndianOutput
-
writeLong
public void writeLong(long v)
- Specified by:
writeLong
in interfaceLittleEndianOutput
-
writeShort
public void writeShort(int v)
- Specified by:
writeShort
in interfaceLittleEndianOutput
-
-