Top Description Fields Constructors Methods
org.apache.poi.hssf.record

public final Class SSTRecord

extends ContinuableRecord
Class Inheritance
Imports
java.util.Iterator, .Map, java.util.function.Supplier, org.apache.poi.hssf.record.common.UnicodeString, org.apache.poi.hssf.record.cont.ContinuableRecord, .ContinuableRecordOutput, org.apache.poi.util.GenericRecordUtil, .IntMapper

Static String Table Record (0x00FC)

This holds all the strings for LabelSSTRecords.

See Also
org.apache.poi.hssf.record.LabelSSTRecord, org.apache.poi.hssf.record.ContinueRecord

Field Summary

Modifier and TypeField and Description
private int[]
bucketAbsoluteOffsets

Offsets from the beginning of the SST record (even across continuations)

private int[]
bucketRelativeOffsets

Offsets relative the start of the current SST or continue record

private final SSTDeserializer
private static final UnicodeString
private int
field_1_num_strings

union of strings in the SST and EXTSST

private int
field_2_num_unique_strings

according to docs ONLY SST

private final IntMapper<UnicodeString>
public static final short

Constructor Summary

AccessConstructor and Description
public
public
public
SSTRecord(RecordInputStream
the RecordInputStream to read the record from
in
)

Fill the fields from the data

The data consists of sets of string data.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the index of that string in the table
addString
(UnicodeString
string to be added
string
)

Add a string.

public int

Returns:

The size of the ExtSST record in bytes.
calcExtSSTRecordSize
()

Calculates the size in bytes of the EXTSST record as it would be if the record was serialized.

public SSTRecord
pack-priv int

Returns:

count of the strings we hold.
countStrings
()

public ExtSSTRecord

Returns:

The new SST record.
createExtSSTRecord
(int
The offset in the stream to the start of the SST record.
sstOffset
)

Creates an extended string record based on the current contents of the current SST record.

public Map<String, Supplier<?>>
public HSSFRecordTypes
public int

Returns:

number of strings
getNumStrings
()

public int

Returns:

number of unique strings
getNumUniqueStrings
()

public short
getSid()

Implements abstract org.apache.poi.hssf.record.Record.getSid.

return the non static version of the id for this record.

public UnicodeString

Returns:

the desired string
getString
(int
index into the array of strings
id
)

Get a particular string by its index

pack-priv Iterator<UnicodeString>

Returns:

an iterator of the strings we hold. All instances are UnicodeStrings
getStrings
()

protected void
serialize(ContinuableRecordOutput
a data output stream
out
)

Implements abstract org.apache.poi.hssf.record.cont.ContinuableRecord.serialize.

Serializes this record's content to the supplied data output.

Inherited from org.apache.poi.hssf.record.cont.ContinuableRecord:
getRecordSizeserialize

Field Detail

bucketAbsoluteOffsetsback to summary
private int[] bucketAbsoluteOffsets

Offsets from the beginning of the SST record (even across continuations)

bucketRelativeOffsetsback to summary
private int[] bucketRelativeOffsets

Offsets relative the start of the current SST or continue record

deserializerback to summary
private final SSTDeserializer deserializer
EMPTY_STRINGback to summary
private static final UnicodeString EMPTY_STRING
field_1_num_stringsback to summary
private int field_1_num_strings

union of strings in the SST and EXTSST

field_2_num_unique_stringsback to summary
private int field_2_num_unique_strings

according to docs ONLY SST

field_3_stringsback to summary
private final IntMapper<UnicodeString> field_3_strings
sidback to summary
public static final short sid

Constructor Detail

SSTRecordback to summary
public SSTRecord()
SSTRecordback to summary
public SSTRecord(SSTRecord other)
SSTRecordback to summary
public SSTRecord(RecordInputStream in)

Fill the fields from the data

The data consists of sets of string data. This string data is arranged as follows:

short  string_length;   // length of string data
byte   string_flag;     // flag specifying special string
                        // handling
short  run_count;       // optional count of formatting runs
int    extend_length;   // optional extension length
char[] string_data;     // string data, can be byte[] or
                        // short[] (length of array is
                        // string_length)
int[]  formatting_runs; // optional formatting runs (length of
                        // array is run_count)
byte[] extension;       // optional extension (length of array
                        // is extend_length)

The string_flag is bit mapped as follows:

string_flag mapping
Bit number Meaning if 0 Meaning if 1
0 string_data is byte[] string_data is short[]
1 Should always be 0 string_flag is defective
2 extension is not included extension is included
3 formatting run data is not included formatting run data is included
4 Should always be 0 string_flag is defective
5 Should always be 0 string_flag is defective
6 Should always be 0 string_flag is defective
7 Should always be 0 string_flag is defective

We can handle eating the overhead associated with bits 2 or 3 (or both) being set, but we have no idea what to do with the associated data. The UnicodeString class can handle the byte[] vs short[] nature of the actual string data

Parameters
in:RecordInputStream

the RecordInputStream to read the record from

Method Detail

addStringback to summary
public int addString(UnicodeString string)

Add a string.

Parameters
string:UnicodeString

string to be added

Returns:int

the index of that string in the table

calcExtSSTRecordSizeback to summary
public int calcExtSSTRecordSize()

Calculates the size in bytes of the EXTSST record as it would be if the record was serialized.

Returns:int

The size of the ExtSST record in bytes.

copyback to summary
public SSTRecord copy()

Implements abstract org.apache.poi.hssf.record.Record.copy.

Implements org.apache.poi.common.Duplicatable.copy.

Returns:SSTRecord

Doc from org.apache.poi.common.Duplicatable.copy.

a deep copy of the implementing class / instance

Annotations
@Override
countStringsback to summary
pack-priv int countStrings()
Returns:int

count of the strings we hold.

createExtSSTRecordback to summary
public ExtSSTRecord createExtSSTRecord(int sstOffset)

Creates an extended string record based on the current contents of the current SST record. The offset within the stream to the SST record is required because the extended string record points directly to the strings in the SST record.

Note

THIS FUNCTION MUST ONLY BE CALLED AFTER THE SST RECORD HAS BEEN SERIALIZED.

Parameters
sstOffset:int

The offset in the stream to the start of the SST record.

Returns:ExtSSTRecord

The new SST record.

getGenericPropertiesback to summary
public Map<String, Supplier<?>> getGenericProperties()

Implements org.apache.poi.common.usermodel.GenericRecord.getGenericProperties.

Annotations
@Override
getGenericRecordTypeback to summary
public HSSFRecordTypes getGenericRecordType()

Overrides default org.apache.poi.common.usermodel.GenericRecord.getGenericRecordType.

Implements abstract org.apache.poi.hssf.record.Record.getGenericRecordType.

Annotations
@Override
getNumStringsback to summary
public int getNumStrings()
Returns:int

number of strings

getNumUniqueStringsback to summary
public int getNumUniqueStrings()
Returns:int

number of unique strings

getSidback to summary
public short getSid()

Implements abstract org.apache.poi.hssf.record.Record.getSid.

Doc from org.apache.poi.hssf.record.Record.getSid.

return the non static version of the id for this record.

Returns:short

he id for this record

Annotations
@Override
getStringback to summary
public UnicodeString getString(int id)

Get a particular string by its index

Parameters
id:int

index into the array of strings

Returns:UnicodeString

the desired string

getStringsback to summary
pack-priv Iterator<UnicodeString> getStrings()
Returns:Iterator<UnicodeString>

an iterator of the strings we hold. All instances are UnicodeStrings

serializeback to summary
protected void serialize(ContinuableRecordOutput out)

Implements abstract org.apache.poi.hssf.record.cont.ContinuableRecord.serialize.

Doc from org.apache.poi.hssf.record.cont.ContinuableRecord.serialize.

Serializes this record's content to the supplied data output.

The standard BIFF header (ushort sid, ushort size) has been handled by the superclass, so only BIFF data should be written by this method. Simple data types can be written with the standard LittleEndianOutput methods. Methods from ContinuableRecordOutput can be used to serialize strings (with ContinueRecords being written as required). If necessary, implementors can explicitly start ContinueRecords (regardless of the amount of remaining space).

Parameters
out:ContinuableRecordOutput

a data output stream

Annotations
@Override