|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.poi.hssf.record.Record | +--org.apache.poi.hssf.record.SSTRecord
Title: Static String Table Record
Description: This holds all the strings for LabelSSTRecords.
REFERENCE: PG 389 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
LabelSSTRecord
,
ContinueRecord
Field Summary | |
static short |
sid
|
Constructor Summary | |
SSTRecord()
default constructor |
|
SSTRecord(short id,
short size,
byte[] data)
Constructs an SST record and sets its fields appropriately. |
|
SSTRecord(short id,
short size,
byte[] data,
int offset)
Constructs an SST record and sets its fields appropriately. |
Method Summary | |
int |
addString(java.lang.String string)
Add a string. |
int |
addString(java.lang.String string,
boolean useUTF16)
Add a string and assert the encoding (8-bit or 16-bit) to be used. |
boolean |
equals(java.lang.Object o)
|
protected void |
fillFields(byte[] data,
short size,
int offset)
Fill the fields from the data |
int |
getNumStrings()
|
int |
getNumUniqueStrings()
|
void |
getNumUniqueStrings(int count)
USE THIS METHOD AT YOUR OWN PERIL: THE addString
METHODS MANIPULATE THE NUMBER OF UNIQUE STRINGS AS A SIDE
EFFECT; YOUR ATTEMPTS AT MANIPULATING THE UNIQUE STRING COUNT
IS LIKELY TO BE VERY WRONG AND WILL RESULT IN BAD BEHAVIOR WHEN
THIS RECORD IS WRITTEN OUT AND ANOTHER PROCESS ATTEMPTS TO READ
THE RECORD |
int |
getRecordSize()
gives the current serialized size of the record. |
short |
getSid()
return the non static version of the id for this record. |
java.lang.String |
getString(int id)
Get a particular string by its index |
int |
hashCode()
|
boolean |
isString16bit(int id)
|
void |
processContinueRecord(byte[] record)
Strange to handle continue records this way. |
int |
serialize(int offset,
byte[] data)
called by the class that is responsible for writing this sucker. |
void |
setNumStrings(int count)
USE THIS METHOD AT YOUR OWN PERIL: THE addString
METHODS MANIPULATE THE NUMBER OF STRINGS AS A SIDE EFFECT; YOUR
ATTEMPTS AT MANIPULATING THE STRING COUNT IS LIKELY TO BE VERY
WRONG AND WILL RESULT IN BAD BEHAVIOR WHEN THIS RECORD IS
WRITTEN OUT AND ANOTHER PROCESS ATTEMPTS TO READ THE RECORD |
java.lang.String |
toString()
Return a debugging string representation |
protected void |
validateSid(short id)
validate SID |
Methods inherited from class org.apache.poi.hssf.record.Record |
fillFields, isInValueSection, isValue, serialize |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final short sid
Constructor Detail |
public SSTRecord()
public SSTRecord(short id, short size, byte[] data)
id
- must be 0xfc or an exception will be throw upon
validationsize
- the size of the data area of the recorddata
- of the record (should not contain sid/len)public SSTRecord(short id, short size, byte[] data, int offset)
id
- must be 0xfc or an exception will be throw upon
validationsize
- the size of the data area of the recorddata
- of the record (should not contain sid/len)offset
- of the recordMethod Detail |
public int addString(java.lang.String string)
THIS IS THE PREFERRED METHOD OF ADDING A STRING. IF YOU USE THE OTHER ,code>addString METHOD AND FORCE 8-BIT ENCODING ON A STRING THAT SHOULD USE 16-BIT ENCODING, YOU WILL CORRUPT THE STRING; IF YOU USE THAT METHOD AND FORCE 16-BIT ENCODING, YOU ARE WASTING SPACE WHEN THE WORKBOOK IS WRITTEN OUT.
string
- string to be addedpublic int addString(java.lang.String string, boolean useUTF16)
USE THIS METHOD AT YOUR OWN RISK. IF YOU FORCE 8-BIT ENCODING, YOU MAY CORRUPT YOUR STRING. IF YOU FORCE 16-BIT ENCODING AND IT ISN'T NECESSARY, YOU WILL WASTE SPACE WHEN THIS RECORD IS WRITTEN OUT.
string
- string to be addeduseUTF16
- if true, forces 16-bit encoding. If false,
forces 8-bit encodingpublic int getNumStrings()
public int getNumUniqueStrings()
public void setNumStrings(int count)
addString
METHODS MANIPULATE THE NUMBER OF STRINGS AS A SIDE EFFECT; YOUR
ATTEMPTS AT MANIPULATING THE STRING COUNT IS LIKELY TO BE VERY
WRONG AND WILL RESULT IN BAD BEHAVIOR WHEN THIS RECORD IS
WRITTEN OUT AND ANOTHER PROCESS ATTEMPTS TO READ THE RECORDcount
- number of stringspublic void getNumUniqueStrings(int count)
addString
METHODS MANIPULATE THE NUMBER OF UNIQUE STRINGS AS A SIDE
EFFECT; YOUR ATTEMPTS AT MANIPULATING THE UNIQUE STRING COUNT
IS LIKELY TO BE VERY WRONG AND WILL RESULT IN BAD BEHAVIOR WHEN
THIS RECORD IS WRITTEN OUT AND ANOTHER PROCESS ATTEMPTS TO READ
THE RECORDcount
- number of stringspublic java.lang.String getString(int id)
id
- index into the array of stringspublic boolean isString16bit(int id)
public java.lang.String toString()
toString
in class Record
public short getSid()
Record
getSid
in class Record
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
protected void validateSid(short id) throws RecordFormatException
validateSid
in class Record
id
- the alleged SIDRecordFormatException
- if validation failsprotected void fillFields(byte[] data, short size, int offset)
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:
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
fillFields
in class Record
data
- raw datasize
- size of the raw datapublic int serialize(int offset, byte[] data)
serialize
in class Record
public int getRecordSize()
Record
getRecordSize
in class Record
public void processContinueRecord(byte[] record)
processContinueRecord
in class Record
org.apache.poi.hssf.record.Record
record
- the continuation record's data
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |