| Method from org.apache.poi.hssf.record.StringRecord Detail: |
public Object clone() {
StringRecord rec = new StringRecord();
rec.field_1_string_length = this.field_1_string_length;
rec.field_2_unicode_flag= this.field_2_unicode_flag;
rec.field_3_string = this.field_3_string;
return rec;
}
|
protected void fillFields(RecordInputStream in) {
field_1_string_length = in.readShort();
field_2_unicode_flag = in.readByte();
byte[] data = in.readRemainder();
//Why isnt this using the in.readString methods???
if (isUnCompressedUnicode())
{
field_3_string = StringUtil.getFromUnicodeLE(data, 0, field_1_string_length );
}
else
{
field_3_string = StringUtil.getFromCompressedUnicode(data, 0, field_1_string_length);
}
}
|
public int getRecordSize() {
return 4 + 2 + 1 + getStringByteLength();
}
gives the current serialized size of the record. Should include the sid and reclength (4 bytes). |
public short getSid() {
return sid;
}
return the non static version of the id for this record. |
public String getString() {
return field_3_string;
}
|
public boolean isInValueSection() {
return true;
}
|
public boolean isUnCompressedUnicode() {
return (field_2_unicode_flag == 1);
}
is this uncompressed unicode (16bit)? Or just 8-bit compressed? |
public void processContinueRecord(byte[] data) {
if(isUnCompressedUnicode()) {
field_3_string += StringUtil.getFromUnicodeLE(data, 0, field_1_string_length - field_3_string.length());
} else {
field_3_string += StringUtil.getFromCompressedUnicode(data, 0, field_1_string_length - field_3_string.length());
}
}
|
public int serialize(int offset,
byte[] data) {
LittleEndian.putShort(data, 0 + offset, sid);
LittleEndian.putShort(data, 2 + offset, ( short ) (3 + getStringByteLength()));
LittleEndian.putUShort(data, 4 + offset, field_1_string_length);
data[6 + offset] = field_2_unicode_flag;
if (isUnCompressedUnicode())
{
StringUtil.putUnicodeLE(field_3_string, data, 7 + offset);
}
else
{
StringUtil.putCompressedUnicode(field_3_string, data, 7 + offset);
}
return getRecordSize();
}
called by the class that is responsible for writing this sucker.
Subclasses should implement this so that their data is passed back in a
byte array. |
public void setCompressedFlag(byte unicode_flag) {
this.field_2_unicode_flag = unicode_flag;
}
Sets whether the string is compressed or not |
public void setString(String string) {
this.field_1_string_length = string.length();
this.field_3_string = string;
setCompressedFlag(StringUtil.hasMultibyte(string) ? (byte)1 : (byte)0);
}
Sets the string represented by this record. |
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[STRING]\n");
buffer.append(" .string = ")
.append(field_3_string).append("\n");
buffer.append("[/STRING]\n");
return buffer.toString();
}
|
protected void validateSid(short id) {
if (id != sid)
{
throw new RecordFormatException("Not a valid StringRecord");
}
}
Throw a runtime exception in the event of a
record passed with a differing ID. |