FileDocCategorySizeDatePackage
ExternSheetRecord.javaAPI DocApache Poi 3.0.15950Mon Jan 01 12:39:40 GMT 2007org.apache.poi.hssf.record

ExternSheetRecord

public class ExternSheetRecord extends Record
Title: Extern Sheet

Description: A List of Inndexes to SupBook

REFERENCE:

author
Libin Roman (Vista Portal LDT. Developer)
version
1.0-pre

Fields Summary
public static final short
sid
private short
field_1_number_of_REF_sturcutres
private ArrayList
field_2_REF_structures
Constructors Summary
public ExternSheetRecord()

    
      
        field_2_REF_structures = new ArrayList();
    
public ExternSheetRecord(RecordInputStream in)
Constructs a Extern Sheet record and sets its fields appropriately.

param
id id must be 0x16 or an exception will be throw upon validation
param
size the size of the data area of the record
param
data data of the record (should not contain sid/len)

        super(in);
    
Methods Summary
public voidaddREFRecord(ExternSheetSubRecord rec)
adds REF struct (ExternSheetSubRecord)

param
rec REF struct

        field_2_REF_structures.add(rec);
    
protected voidfillFields(org.apache.poi.hssf.record.RecordInputStream in)
called by the constructor, should set class level fields. Should throw runtime exception for bad/icomplete data.

param
data raw data
param
size size of data
param
offset of the record's data (provided a big array of the file)

        field_2_REF_structures           = new ArrayList();
        
        field_1_number_of_REF_sturcutres = in.readShort();
        
        for (int i = 0 ; i < field_1_number_of_REF_sturcutres ; ++i) {
            ExternSheetSubRecord rec = new ExternSheetSubRecord(in);
            
            field_2_REF_structures.add( rec);
        }
    
public intgetNumOfREFRecords()
returns the number of REF Records, which is in model

return
number of REF records

        return field_2_REF_structures.size();
    
public shortgetNumOfREFStructures()
return the number of the REF structors , that is in Excel file

return
number of REF structs

        return field_1_number_of_REF_sturcutres;
    
public ExternSheetSubRecordgetREFRecordAt(int elem)
returns the REF record (ExternSheetSubRecord)

param
elem index to place
return
REF record

        ExternSheetSubRecord result = ( ExternSheetSubRecord ) field_2_REF_structures.get(elem);
        
        return result;
    
public intgetRecordSize()

        return 4 + 2 + getNumOfREFRecords() * 6;
    
public shortgetSid()
return the non static version of the id for this record.

        return sid;
    
public intserialize(int offset, byte[] data)
called by the class that is responsible for writing this sucker. Subclasses should implement this so that their data is passed back in a byte array.

param
offset to begin writing at
param
data byte array containing instance data
return
number of bytes written

        LittleEndian.putShort(data, 0 + offset, sid);
        LittleEndian.putShort(data, 2 + offset,(short)(2 + (getNumOfREFRecords() *6)));
        
        LittleEndian.putShort(data, 4 + offset, getNumOfREFStructures());
        
        int pos = 6 ;
        
        for (int k = 0; k < getNumOfREFRecords(); k++) {
            ExternSheetSubRecord record = getREFRecordAt(k);
            System.arraycopy(record.serialize(), 0, data, pos + offset, 6);
            
            pos +=6;
        }
        return getRecordSize();
    
public voidsetNumOfREFStructures(short numStruct)
sets the number of the REF structors , that is in Excel file

param
numStruct number of REF structs

        field_1_number_of_REF_sturcutres = numStruct;
    
public java.lang.StringtoString()

        StringBuffer buffer = new StringBuffer();
        
        buffer.append("[EXTERNSHEET]\n");
        buffer.append("   numOfRefs     = ").append(getNumOfREFStructures()).append("\n");
        for (int k=0; k < this.getNumOfREFRecords(); k++) {
            buffer.append("refrec         #").append(k).append('\n");
            buffer.append(getREFRecordAt(k).toString());
            buffer.append("----refrec     #").append(k).append('\n");
        }
        buffer.append("[/EXTERNSHEET]\n");
        
        
        return buffer.toString();
    
protected voidvalidateSid(short id)
called by constructor, should throw runtime exception in the event of a record passed with a differing ID.

param
id alleged id for this record

        if (id != sid) {
            throw new RecordFormatException("NOT An ExternSheet RECORD");
        }