The base abstract record from which all escher records are defined. Subclasses will need
to define methods for serialization/deserialization and for determining the record size.
| Method from org.apache.poi.ddf.EscherRecord Detail: |
public Object clone() {
throw new RuntimeException( "The class " + getClass().getName() + " needs to define a clone method" );
}
Escher records may need to be clonable in the future. |
public void display(PrintWriter w,
int indent) {
for (int i = 0; i < indent * 4; i++) w.print(' ");
w.println(getRecordName());
}
The display methods allows escher variables to print the record names
according to their hierarchy. |
protected int fillFields(byte[] data,
EscherRecordFactory f) {
return fillFields( data, 0, f );
}
Delegates to fillFields(byte[], int, EscherRecordFactory) |
abstract public int fillFields(byte[] data,
int offset,
EscherRecordFactory recordFactory)
The contract of this method is to deserialize an escher record including
it's children. |
public EscherRecord getChild(int index) {
return (EscherRecord) getChildRecords().get(index);
}
Returns the indexed child record. |
public List getChildRecords() {
return Collections.EMPTY_LIST;
}
|
public short getInstance() {
return (short) ( options > > 4 );
}
Returns the instance part of the option record. |
public short getOptions() {
return options;
}
|
public short getRecordId() {
return recordId;
}
Return the current record id. |
abstract public String getRecordName()
Subclasses should return the short name for this escher record. |
abstract public int getRecordSize()
Subclasses should effeciently return the number of bytes required to
serialize the record. |
public boolean isContainerRecord() {
return (options & (short)0x000f) == (short)0x000f;
}
Determine whether this is a container record by inspecting the option
field. |
protected int readHeader(byte[] data,
int offset) {
EscherRecordHeader header = EscherRecordHeader.readHeader(data, offset);
options = header.getOptions();
recordId = header.getRecordId();
return header.getRemainingBytes();
}
Reads the 8 byte header information and populates the options
and recordId records. |
public byte[] serialize() {
byte[] retval = new byte[getRecordSize()];
serialize( 0, retval );
return retval;
}
Serializes to a new byte array. This is done by delegating to
serialize(int, byte[]); |
public int serialize(int offset,
byte[] data) {
return serialize( offset, data, new NullEscherSerializationListener() );
}
Serializes to an existing byte array without serialization listener.
This is done by delegating to serialize(int, byte[], EscherSerializationListener). |
abstract public int serialize(int offset,
byte[] data,
EscherSerializationListener listener)
Serializes the record to an existing byte array. |
public void setChildRecords(List childRecords) {
throw new IllegalArgumentException("This record does not support child records.");
}
Sets the child records for this record. By default this will throw
an exception as only EscherContainerRecords may have children. |
public void setOptions(short options) {
this.options = options;
}
Set the options this this record. Container records should have the
last nibble set to 0xF. |
public void setRecordId(short recordId) {
this.recordId = recordId;
}
Sets the record id for this record. |