| Method from org.apache.cocoon.poi.hssf.record.StyleRecord Detail: |
protected void fillFields(byte[] data,
short size,
int offset) {
field_1_xf_index = LittleEndian.getShort(data, 0 + offset);
if (getType() == 1)
{
field_2_builtin_style = data[ 2 + offset ];
field_3_outline_style_level = data[ 3 + offset ];
}
else if (getType() == 0)
{
field_2_name_length = data[ 2 + offset ];
field_3_name = new String(data, 3 + offset,
field_2_name_length);
}
// todo sanity check exception to make sure we're one or the other
}
|
public byte getBuiltin() {
return field_2_builtin_style;
}
if this is a builtin style get the number of the built in style |
public short getIndex() {
return field_1_xf_index;
}
get the entire index field (including the type) (see bit getters that reference this method) |
public String getName() {
return field_3_name;
}
|
public byte getNameLength() {
return field_2_name_length;
}
if this is a user defined record get the length of the style name |
public byte getOutlineStyleLevel() {
return field_3_outline_style_level;
}
get the row or column level of the style (if builtin 1||2) |
public short getSid() {
return this.sid;
}
|
public short getType() {
return ( short ) ((field_1_xf_index & 0x8000) > > 15);
}
get the type of the style (builtin or user-defined) |
public short getXFIndex() {
return ( short ) (field_1_xf_index & 0x1FFF);
}
get the actual index of the style extended format record |
public byte[] serialize() {
byte[] retval = null;
if (getType() == STYLE_BUILT_IN)
{
retval = new byte[ 8 ];
}
else
{
retval = new byte[ 7 + getNameLength() ];
}
LittleEndian.putShort(retval, 0, sid);
if (getType() == STYLE_BUILT_IN)
{
LittleEndian.putShort(retval, 2,
(( short ) 0x04)); // 4 bytes (8 total)
}
else
{
LittleEndian.putShort(retval, 2,
(( short ) (0x03 + getNameLength())));
}
LittleEndian.putShort(retval, 4, getIndex());
if (getType() == STYLE_BUILT_IN)
{
retval[ 6 ] = getBuiltin();
retval[ 7 ] = getOutlineStyleLevel();
}
else
{
retval[ 6 ] = getNameLength();
StringUtil.putCompressedUnicode(getName(), retval, 7);
}
return retval;
}
|
public void setBuiltin(byte builtin) {
field_2_builtin_style = builtin;
}
if this is a builtin style set teh number of the built in style |
public void setIndex(short index) {
field_1_xf_index = index;
}
set the entire index field (including the type) (see bit setters that reference this method) |
public void setName(String name) {
field_3_name = name;
}
|
public void setNameLength(byte length) {
field_2_name_length = length;
}
if this is a user defined record set the length of the style name |
public void setOutlineStyleLevel(byte level) {
field_3_outline_style_level = level;
}
set the row or column level of the style (if builtin 1||2) |
public void setType(short type) {
field_1_xf_index = setField(field_1_xf_index, type, 0x8000, 15);
}
set the type of the style (builtin or user-defined) |
public void setXFIndex(short index) {
field_1_xf_index = setField(field_1_xf_index, index, 0x1FFF, 0);
}
set the actual index of the style extended format record |
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[STYLE]\n");
buffer.append(" .xf_index_raw = ")
.append(Integer.toHexString(getIndex())).append("\n");
buffer.append(" .type = ")
.append(Integer.toHexString(getType())).append("\n");
buffer.append(" .xf_index = ")
.append(Integer.toHexString(getXFIndex())).append("\n");
if (getType() == STYLE_BUILT_IN)
{
buffer.append(" .builtin_style = ")
.append(Integer.toHexString(getBuiltin())).append("\n");
buffer.append(" .outline_level = ")
.append(Integer.toHexString(getOutlineStyleLevel()))
.append("\n");
}
else if (getType() == STYLE_USER_DEFINED)
{
buffer.append(" .name_length = ")
.append(Integer.toHexString(getNameLength())).append("\n");
buffer.append(" .name = ").append(getName())
.append("\n");
}
buffer.append("[/STYLE]\n");
return buffer.toString();
}
|
protected void validateSid(short id) {
if (id != sid)
{
throw new RecordFormatException("NOT A STYLE RECORD");
}
}
|