FileDocCategorySizeDatePackage
EscherContainerRecord.javaAPI DocApache Poi 3.0.16677Mon Jan 01 12:39:40 GMT 2007org.apache.poi.ddf

EscherContainerRecord

public class EscherContainerRecord extends 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.
author
Glen Stampoultzis

Fields Summary
public static final short
DGG_CONTAINER
public static final short
BSTORE_CONTAINER
public static final short
DG_CONTAINER
public static final short
SPGR_CONTAINER
public static final short
SP_CONTAINER
public static final short
SOLVER_CONTAINER
private List
childRecords
Constructors Summary
Methods Summary
public voidaddChildRecord(org.apache.poi.ddf.EscherRecord record)

        this.childRecords.add( record );
    
public voiddisplay(java.io.PrintWriter w, int indent)

        super.display( w, indent );
        for ( Iterator iterator = childRecords.iterator(); iterator.hasNext(); )
        {
            EscherRecord escherRecord = (EscherRecord) iterator.next();
            escherRecord.display( w, indent + 1 );
        }
    
public intfillFields(byte[] data, int offset, org.apache.poi.ddf.EscherRecordFactory recordFactory)


             
    
        int bytesRemaining = readHeader( data, offset );
        int bytesWritten = 8;
        offset += 8;
        while ( bytesRemaining > 0 && offset < data.length )
        {
            EscherRecord child = recordFactory.createRecord(data, offset);
            int childBytesWritten = child.fillFields( data, offset, recordFactory );
            bytesWritten += childBytesWritten;
            offset += childBytesWritten;
            bytesRemaining -= childBytesWritten;
            getChildRecords().add( child );
            if (offset >= data.length && bytesRemaining > 0)
            {
                System.out.println("WARNING: " + bytesRemaining + " bytes remaining but no space left");
            }
        }
        return bytesWritten;
    
public org.apache.poi.ddf.EscherSpRecordgetChildById(short recordId)

        for ( Iterator iterator = childRecords.iterator(); iterator.hasNext(); )
        {
            EscherRecord escherRecord = (EscherRecord) iterator.next();
            if (escherRecord.getRecordId() == recordId)
                return (EscherSpRecord) escherRecord;
        }
        return null;
    
public java.util.ListgetChildRecords()

        return childRecords;
    
public java.lang.StringgetRecordName()

        switch ((short)getRecordId())
        {
            case DGG_CONTAINER:
                return "DggContainer";
            case BSTORE_CONTAINER:
                return "BStoreContainer";
            case DG_CONTAINER:
                return "DgContainer";
            case SPGR_CONTAINER:
                return "SpgrContainer";
            case SP_CONTAINER:
                return "SpContainer";
            case SOLVER_CONTAINER:
                return "SolverContainer";
            default:
                return "Container 0x" + HexDump.toHex(getRecordId());
        }
    
public intgetRecordSize()

        int childRecordsSize = 0;
        for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
        {
            EscherRecord r = (EscherRecord) iterator.next();
            childRecordsSize += r.getRecordSize();
        }
        return 8 + childRecordsSize;
    
public intserialize(int offset, byte[] data, org.apache.poi.ddf.EscherSerializationListener listener)

        listener.beforeRecordSerialize( offset, getRecordId(), this );

        LittleEndian.putShort(data, offset, getOptions());
        LittleEndian.putShort(data, offset+2, getRecordId());
        int remainingBytes = 0;
        for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
        {
            EscherRecord r = (EscherRecord) iterator.next();
            remainingBytes += r.getRecordSize();
        }
        LittleEndian.putInt(data, offset+4, remainingBytes);
        int pos = offset+8;
        for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
        {
            EscherRecord r = (EscherRecord) iterator.next();
            pos += r.serialize(pos, data, listener );
        }

        listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this );
        return pos - offset;
    
public voidsetChildRecords(java.util.List childRecords)

        this.childRecords = childRecords;
    
public java.lang.StringtoString()

        String nl = System.getProperty( "line.separator" );

        StringBuffer children = new StringBuffer();
        if ( getChildRecords().size() > 0 )
        {
            children.append( "  children: " + nl );
            for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
            {
                EscherRecord record = (EscherRecord) iterator.next();
                children.append( record.toString() );
//                children.append( nl );
            }
        }

        return getClass().getName() + " (" + getRecordName() + "):" + nl +
                "  isContainer: " + isContainerRecord() + nl +
                "  options: 0x" + HexDump.toHex( getOptions() ) + nl +
                "  recordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
                "  numchildren: " + getChildRecords().size() + nl +
                children.toString();