Methods Summary |
---|
public java.lang.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(org.apache.poi.hssf.record.RecordInputStream in)called by the constructor, should set class level fields. Should throw
runtime exception for bad/icomplete data.
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()gives the current serialized size of the record. Should include the sid and reclength (4 bytes).
return 4 + 2 + 1 + getStringByteLength();
|
public short | getSid()return the non static version of the id for this record.
return sid;
|
public java.lang.String | getString()
return field_3_string;
|
private int | getStringByteLength()
return isUnCompressedUnicode() ? field_1_string_length * 2 : field_1_string_length;
|
public boolean | isInValueSection()
return true;
|
public boolean | isUnCompressedUnicode()is this uncompressed unicode (16bit)? Or just 8-bit compressed?
return (field_2_unicode_flag == 1);
|
public int | serialize(int offset, byte[] data)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.
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();
|
public void | setCompressedFlag(byte unicode_flag)Sets whether the string is compressed or not
this.field_2_unicode_flag = unicode_flag;
|
public void | setString(java.lang.String string)Sets the string represented by this record.
this.field_1_string_length = string.length();
this.field_3_string = string;
setCompressedFlag(StringUtil.hasMultibyte(string) ? (byte)1 : (byte)0);
|
public java.lang.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)Throw a runtime exception in the event of a
record passed with a differing ID.
if (id != sid)
{
throw new RecordFormatException("Not a valid StringRecord");
}
|