org.apache.poi.ddf
Class EscherContainerRecord

java.lang.Object
  extended by org.apache.poi.ddf.EscherRecord
      extended by org.apache.poi.ddf.EscherContainerRecord
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Iterable<EscherRecord>

public final class EscherContainerRecord
extends EscherRecord
implements java.lang.Iterable<EscherRecord>

Escher container records store other escher records as children. The container records themselves never store any information beyond the standard header used by all escher records. This one record is used to represent many different types of records.


Field Summary
static short BSTORE_CONTAINER
           
static short DG_CONTAINER
           
static short DGG_CONTAINER
           
static short SOLVER_CONTAINER
           
static short SP_CONTAINER
           
static short SPGR_CONTAINER
           
 
Constructor Summary
EscherContainerRecord()
           
 
Method Summary
 void addChildBefore(EscherRecord record, int insertBeforeRecordId)
          Add a child record before the record with given recordId
 void addChildRecord(EscherRecord record)
          Append a child record
 void display(java.io.PrintWriter w, int indent)
          The display methods allows escher variables to print the record names according to their hierarchy.
 int fillFields(byte[] data, int pOffset, EscherRecordFactory recordFactory)
          The contract of this method is to deserialize an escher record including it's children.
protected  java.lang.Object[][] getAttributeMap()
          For the purpose of providing toString() and toXml() a subclass can either override those methods or provide a Object[][] array in the form { { "Attribute Name (Header)", value, "optional attribute", value }, ...
 EscherRecord getChild(int index)
          Returns the indexed child record.
<T extends EscherRecord>
T
getChildById(short recordId)
           
 java.util.List<EscherContainerRecord> getChildContainers()
          Returns all of our children which are also EscherContainers (may be 0, 1, or vary rarely 2 or 3)
 java.util.Iterator<EscherRecord> getChildIterator()
          Deprecated. POI 3.16 beta 1. use iterator() or loop over the container record instead, e.g. "for (EscherRecord r : container) ..."
 java.util.List<EscherRecord> getChildRecords()
           
 java.lang.String getRecordName()
          Subclasses should return the short name for this escher record.
 void getRecordsById(short recordId, java.util.List<EscherRecord> out)
          Recursively find records with the specified record ID
 int getRecordSize()
          Subclasses should effeciently return the number of bytes required to serialize the record.
 boolean hasChildOfType(short recordId)
          Do any of our (top level) children have the given recordId?
 java.util.Iterator<EscherRecord> iterator()
           
 boolean removeChildRecord(EscherRecord toBeRemoved)
          Removes the given escher record from the child list
 int serialize(int offset, byte[] data, EscherSerializationListener listener)
          Serializes the record to an existing byte array.
 void setChildRecords(java.util.List<EscherRecord> childRecords)
          replaces the internal child list with the contents of the supplied childRecords
 
Methods inherited from class org.apache.poi.ddf.EscherRecord
clone, fillFields, getInstance, getOptions, getRecordId, getVersion, isContainerRecord, readHeader, readInstance, serialize, serialize, setInstance, setOptions, setRecordId, setVersion, toString, toXml, toXml
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DGG_CONTAINER

public static final short DGG_CONTAINER
See Also:
Constant Field Values

BSTORE_CONTAINER

public static final short BSTORE_CONTAINER
See Also:
Constant Field Values

DG_CONTAINER

public static final short DG_CONTAINER
See Also:
Constant Field Values

SPGR_CONTAINER

public static final short SPGR_CONTAINER
See Also:
Constant Field Values

SP_CONTAINER

public static final short SP_CONTAINER
See Also:
Constant Field Values

SOLVER_CONTAINER

public static final short SOLVER_CONTAINER
See Also:
Constant Field Values
Constructor Detail

EscherContainerRecord

public EscherContainerRecord()
Method Detail

fillFields

public int fillFields(byte[] data,
                      int pOffset,
                      EscherRecordFactory recordFactory)
Description copied from class: EscherRecord
The contract of this method is to deserialize an escher record including it's children.

Specified by:
fillFields in class EscherRecord
Parameters:
data - The byte array containing the serialized escher records.
pOffset - The offset into the byte array.
recordFactory - A factory for creating new escher records.
Returns:
The number of bytes written.

serialize

public int serialize(int offset,
                     byte[] data,
                     EscherSerializationListener listener)
Description copied from class: EscherRecord
Serializes the record to an existing byte array.

Specified by:
serialize in class EscherRecord
Parameters:
offset - the offset within the byte array
data - the data array to serialize to
listener - 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:
the number of bytes written.

getRecordSize

public int getRecordSize()
Description copied from class: EscherRecord
Subclasses should effeciently return the number of bytes required to serialize the record.

Specified by:
getRecordSize in class EscherRecord
Returns:
number of bytes

hasChildOfType

public boolean hasChildOfType(short recordId)
Do any of our (top level) children have the given recordId?

Parameters:
recordId - the recordId of the child
Returns:
true, if any child has the given recordId

getChild

public EscherRecord getChild(int index)
Description copied from class: EscherRecord
Returns the indexed child record.

Overrides:
getChild in class EscherRecord
Parameters:
index - the index of the child within the child records
Returns:
the indexed child record

getChildRecords

public java.util.List<EscherRecord> getChildRecords()
Overrides:
getChildRecords in class EscherRecord
Returns:
a copy of the list of all the child records of the container.
See Also:
EscherContainerRecord

getChildIterator

@Removal(version="3.18")
@Deprecated
public java.util.Iterator<EscherRecord> getChildIterator()
Deprecated. POI 3.16 beta 1. use iterator() or loop over the container record instead, e.g. "for (EscherRecord r : container) ..."

Returns:
an iterator over the child records

iterator

public java.util.Iterator<EscherRecord> iterator()
Specified by:
iterator in interface java.lang.Iterable<EscherRecord>
Returns:
an iterator over the child records

setChildRecords

public void setChildRecords(java.util.List<EscherRecord> childRecords)
replaces the internal child list with the contents of the supplied childRecords

Overrides:
setChildRecords in class EscherRecord
Parameters:
childRecords - Not used in base implementation.

removeChildRecord

public boolean removeChildRecord(EscherRecord toBeRemoved)
Removes the given escher record from the child list

Parameters:
toBeRemoved - the escher record to be removed
Returns:
true, if the record was found and removed

getChildContainers

public java.util.List<EscherContainerRecord> getChildContainers()
Returns all of our children which are also EscherContainers (may be 0, 1, or vary rarely 2 or 3)

Returns:
EscherContainer children

getRecordName

public java.lang.String getRecordName()
Description copied from class: EscherRecord
Subclasses should return the short name for this escher record.

Specified by:
getRecordName in class EscherRecord
Returns:
the short name for this escher record

display

public void display(java.io.PrintWriter w,
                    int indent)
Description copied from class: EscherRecord
The display methods allows escher variables to print the record names according to their hierarchy.

Overrides:
display in class EscherRecord
Parameters:
w - The print writer to output to.
indent - The current indent level.

addChildRecord

public void addChildRecord(EscherRecord record)
Append a child record

Parameters:
record - the record to be added

addChildBefore

public void addChildBefore(EscherRecord record,
                           int insertBeforeRecordId)
Add a child record before the record with given recordId

Parameters:
record - the record to be added
insertBeforeRecordId - the recordId of the next sibling

getChildById

public <T extends EscherRecord> T getChildById(short recordId)

getRecordsById

public void getRecordsById(short recordId,
                           java.util.List<EscherRecord> out)
Recursively find records with the specified record ID

Parameters:
recordId - the recordId to be searched for
out - - list to store found records

getAttributeMap

protected java.lang.Object[][] getAttributeMap()
Description copied from class: EscherRecord
For the purpose of providing toString() and toXml() a subclass can either override those methods or provide a Object[][] array in the form { { "Attribute Name (Header)", value, "optional attribute", value }, ... } .

Null values won't be printed.

The attributes record, version, instance, options must not be returned.

Specified by:
getAttributeMap in class EscherRecord
Returns:
the attribute map