Top Description Fields Constructors Methods
org.apache.poi.ddf

public abstract Class EscherRecord

extends Object
implements Duplicatable, GenericRecord
Class Inheritance
All Implemented Interfaces
org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.common.Duplicatable
Known Direct Subclasses
org.apache.poi.ddf.EscherSpgrRecord, org.apache.poi.ddf.EscherSplitMenuColorsRecord, org.apache.poi.ddf.EscherSpRecord, org.apache.poi.ddf.EscherTextboxRecord, org.apache.poi.ddf.UnknownEscherRecord, org.apache.poi.ddf.AbstractEscherOptRecord, org.apache.poi.ddf.EscherBlipRecord, org.apache.poi.ddf.EscherBSERecord, org.apache.poi.ddf.EscherChildAnchorRecord, org.apache.poi.ddf.EscherClientAnchorRecord, org.apache.poi.ddf.EscherClientDataRecord, org.apache.poi.ddf.EscherContainerRecord, org.apache.poi.ddf.EscherDggRecord, org.apache.poi.ddf.EscherDgRecord
Imports
java.io.PrintWriter, java.util.Collections, .List, .Map, java.util.function.Supplier, org.apache.poi.common.Duplicatable, org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.util.BitField, .BitFieldFactory, .GenericRecordJsonWriter, .GenericRecordUtil, .GenericRecordXmlWriter, .Internal, .LittleEndian

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.

Field Summary

Modifier and TypeField and Description
private short
private short
private static final BitField
private static final BitField

Constructor Summary

AccessConstructor and Description
public
EscherRecord()

Create a new instance

protected

Method Summary

Modifier and TypeMethod and Description
public abstract EscherRecord
public void
display(PrintWriter
The print writer to output to.
w
,
int
The current indent level.
indent
)

The display methods allows escher variables to print the record names according to their hierarchy.

protected int

Returns:

The number of bytes written.
fillFields
(byte[]
they bytes to serialize from
data
,
EscherRecordFactory
the escher record factory
f
)

Delegates to fillFields(byte[], int, EscherRecordFactory)

public abstract int

Returns:

The number of bytes written.
fillFields
(byte[]
The byte array containing the serialized escher records.
data
,
int
The offset into the byte array.
offset
,
EscherRecordFactory
A factory for creating new escher records.
recordFactory
)

The contract of this method is to deserialize an escher record including its children.

public EscherRecord

Returns:

the indexed child record
getChild
(int
the index of the child within the child records
index
)

Returns the indexed child record.

public List<EscherRecord>

Returns:

Returns the children of this record. By default this will be an empty list. EscherCotainerRecord is the only record that may contain children.
getChildRecords
()

public List<? extends GenericRecord>
public Map<String, Supplier<?>>
public short

Returns:

The instance part of the record
getInstance
()

Returns the instance part of the option record.

public short

Returns:

The options field for this record. All records have one.
getOptions
()

Note that options is an internal field.

public short

Returns:

The 16 bit record id.
getRecordId
()

Return the current record id.

public abstract String

Returns:

the short name for this escher record
getRecordName
()

Subclasses should return the short name for this escher record.

public abstract int

Returns:

number of bytes
getRecordSize
()

Subclasses should effeciently return the number of bytes required to serialize the record.

public short

Returns:

The version part of the option record
getVersion
()

Returns the version part of the option record.

public boolean

Returns:

true is this is a container field.
isContainerRecord
()

Determine whether this is a container record by inspecting the option field.

protected int

Returns:

the number of bytes remaining in this record. This may include the children if this is a container.
readHeader
(byte[]
the byte array to read from
data
,
int
the offset to start reading from
offset
)

Reads the 8 byte header information and populates the options and recordId records.

protected static short

Returns:

value of instance part of options field
readInstance
(byte[]
the byte array to read from
data
,
int
the offset to start reading from
offset
)

Read the options field from header and return instance part of it.

public byte[]

Returns:

the serialized record.
serialize
()

Serializes to a new byte array.

public int

Returns:

The number of bytes written.
serialize
(int
the offset within the data byte array.
offset
,
byte[]
the data array to serialize to.
data
)

Serializes to an existing byte array without serialization listener.

public abstract int

Returns:

the number of bytes written.
serialize
(int
the offset within the byte array
offset
,
byte[]
the data array to serialize to
data
,
EscherSerializationListener
a listener for begin and end serialization events. This is useful because the serialization is hierarchical/recursive and sometimes you need to be able break into that.
listener
)

Serializes the record to an existing byte array.

public void
setChildRecords(List<EscherRecord>
Not used in base implementation.
childRecords
)

Sets the child records for this record.

public void
setInstance(short
instance part value
value
)

Sets the instance part of record

public void
setOptions(short
the record options
options
)

Set the options this record.

public void
setRecordId(short
the record id
recordId
)

Sets the record id for this record.

public void
setVersion(short
version part value
value
)

Sets the version part of record

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
public final String

Returns:

xml representation of this record
toXml
(String
- each children must be indented right relative to its parent
tab
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_optionsback to summary
private short _options
_recordIdback to summary
private short _recordId
fInstanceback to summary
private static final BitField fInstance
fVersionback to summary
private static final BitField fVersion

Constructor Detail

EscherRecordback to summary
public EscherRecord()

Create a new instance

EscherRecordback to summary
protected EscherRecord(EscherRecord other)

Method Detail

copyback to summary
public abstract EscherRecord copy()

Redeclares org.apache.poi.common.Duplicatable.copy.

Returns:EscherRecord

Doc from org.apache.poi.common.Duplicatable.copy.

a deep copy of the implementing class / instance

Annotations
@Override
displayback to summary
public void display(PrintWriter w, int indent)

The display methods allows escher variables to print the record names according to their hierarchy.

Parameters
w:PrintWriter

The print writer to output to.

indent:int

The current indent level.

fillFieldsback to summary
protected int fillFields(byte[] data, EscherRecordFactory f)

Delegates to fillFields(byte[], int, EscherRecordFactory)

Parameters
data:byte[]

they bytes to serialize from

f:EscherRecordFactory

the escher record factory

Returns:int

The number of bytes written.

See Also
fillFields(byte[], int, org.apache.poi.ddf.EscherRecordFactory)
fillFieldsback to summary
public abstract int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory)

The contract of this method is to deserialize an escher record including its children.

Parameters
data:byte[]

The byte array containing the serialized escher records.

offset:int

The offset into the byte array.

recordFactory:EscherRecordFactory

A factory for creating new escher records.

Returns:int

The number of bytes written.

getChildback to summary
public EscherRecord getChild(int index)

Returns the indexed child record.

Parameters
index:int

the index of the child within the child records

Returns:EscherRecord

the indexed child record

getChildRecordsback to summary
public List<EscherRecord> getChildRecords()
Returns:List<EscherRecord>

Returns the children of this record. By default this will be an empty list. EscherCotainerRecord is the only record that may contain children.

See Also
EscherContainerRecord
getGenericChildrenback to summary
public List<? extends GenericRecord> getGenericChildren()

Overrides default org.apache.poi.common.usermodel.GenericRecord.getGenericChildren.

Annotations
@Override
getGenericPropertiesback to summary
public Map<String, Supplier<?>> getGenericProperties()

Implements org.apache.poi.common.usermodel.GenericRecord.getGenericProperties.

Annotations
@Override
getInstanceback to summary
public short getInstance()

Returns the instance part of the option record.

Returns:short

The instance part of the record

getOptionsback to summary
public short getOptions()

Note that options is an internal field. Use setInstance(short) ()} and setVersion(short) ()} to set the actual fields.

Returns:short

The options field for this record. All records have one.

Annotations
@Internal
getRecordIdback to summary
public short getRecordId()

Return the current record id.

Returns:short

The 16 bit record id.

getRecordNameback to summary
public abstract String getRecordName()

Subclasses should return the short name for this escher record.

Returns:String

the short name for this escher record

getRecordSizeback to summary
public abstract int getRecordSize()

Subclasses should effeciently return the number of bytes required to serialize the record.

Returns:int

number of bytes

getVersionback to summary
public short getVersion()

Returns the version part of the option record.

Returns:short

The version part of the option record

isContainerRecordback to summary
public boolean isContainerRecord()

Determine whether this is a container record by inspecting the option field.

Returns:boolean

true is this is a container field.

readHeaderback to summary
protected int readHeader(byte[] data, int offset)

Reads the 8 byte header information and populates the options and recordId records.

Parameters
data:byte[]

the byte array to read from

offset:int

the offset to start reading from

Returns:int

the number of bytes remaining in this record. This may include the children if this is a container.

readInstanceback to summary
protected static short readInstance(byte[] data, int offset)

Read the options field from header and return instance part of it.

Parameters
data:byte[]

the byte array to read from

offset:int

the offset to start reading from

Returns:short

value of instance part of options field

serializeback to summary
public byte[] serialize()

Serializes to a new byte array. This is done by delegating to serialize(int, byte[]);

Returns:byte[]

the serialized record.

See Also
serialize(int, byte[])
serializeback to summary
public int serialize(int offset, byte[] data)

Serializes to an existing byte array without serialization listener. This is done by delegating to serialize(int, byte[], EscherSerializationListener).

Parameters
offset:int

the offset within the data byte array.

data:byte[]

the data array to serialize to.

Returns:int

The number of bytes written.

See Also
serialize(int, byte[], org.apache.poi.ddf.EscherSerializationListener)
serializeback to summary
public abstract int serialize(int offset, byte[] data, EscherSerializationListener listener)

Serializes the record to an existing byte array.

Parameters
offset:int

the offset within the byte array

data:byte[]

the data array to serialize to

listener:EscherSerializationListener

a listener for begin and end serialization events. This is useful because the serialization is hierarchical/recursive and sometimes you need to be able break into that.

Returns:int

the number of bytes written.

setChildRecordsback to summary
public void setChildRecords(List<EscherRecord> childRecords)

Sets the child records for this record. By default this will throw an exception as only EscherContainerRecords may have children.

Parameters
childRecords:List<EscherRecord>

Not used in base implementation.

setInstanceback to summary
public void setInstance(short value)

Sets the instance part of record

Parameters
value:short

instance part value

setOptionsback to summary
public void setOptions(short options)

Set the options this record. Container records should have the last nibble set to 0xF.

Note that options is an internal field. Use getInstance() and getVersion() to access actual fields.

Parameters
options:short

the record options

Annotations
@Internal
setRecordIdback to summary
public void setRecordId(short recordId)

Sets the record id for this record.

Parameters
recordId:short

the record id

setVersionback to summary
public void setVersion(short value)

Sets the version part of record

Parameters
value:short

version part value

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
toXmlback to summary
public String toXml()
toXmlback to summary
public final String toXml(String tab)
Parameters
tab:String

- each children must be indented right relative to its parent

Returns:String

xml representation of this record