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

UnknownRecord

public class UnknownRecord extends Record
Title: Unknown Record (for debugging)

Description: Unknown record just tells you the sid so you can figure out what records you are missing. Also helps us read/modify sheets we don't know all the records to. (HSSF leaves these alone!)

Company: SuperLink Software, Inc.

author
Andrew C. Oliver (acoliver at apache dot org)
author
Jason Height (jheight at chariot dot net dot au)
author
Glen Stampoultzis (glens at apache.org)

Fields Summary
private short
sid
private byte[]
thedata
Constructors Summary
public UnknownRecord()


     
    
    
public UnknownRecord(short id, byte[] data)
construct an unknown record. No fields are interperated and the record will be serialized in its original form more or less

param
id id of the record -not validated, just stored for serialization
param
data the data

      this.sid = id;
      this.thedata = data;
    
public UnknownRecord(RecordInputStream in)
construct an unknown record. No fields are interperated and the record will be serialized in its original form more or less

param
id id of the record -not validated, just stored for serialization
param
size size of the data
param
data the data

        sid     = in.getSid();
        thedata = in.readRemainder();
        
        //System.out.println("UnknownRecord: 0x"+Integer.toHexString(sid));
    
Methods Summary
public java.lang.Objectclone()
Unlike the other Record.clone methods this is a shallow clone

      UnknownRecord rec = new UnknownRecord();
      rec.sid = sid;
      rec.thedata = thedata;
      return 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 records data (provided a big array of the file)

        throw new RecordFormatException(
            "Unknown record cannot be constructed via offset -- we need a copy of the data");
    
protected voidfillFields(byte[] data, short sid)

        this.sid     = sid;
        thedata = data;
    
public intgetRecordSize()

        int retval = 4;

        if (thedata != null)
        {
            retval += thedata.length;
        }
        return retval;
    
public shortgetSid()

        return sid;
    
public intserialize(int offset, byte[] data)
spit the record out AS IS. no interpretation or identification

        if (thedata == null)
        {
            thedata = new byte[ 0 ];
        }
        LittleEndian.putShort(data, 0 + offset, sid);
        LittleEndian.putShort(data, 2 + offset, ( short ) (thedata.length));
        if (thedata.length > 0)
        {
            System.arraycopy(thedata, 0, data, 4 + offset, thedata.length);
        }
        return getRecordSize();
    
public java.lang.StringtoString()
print a sort of string representation ([UNKNOWN RECORD] id = x [/UNKNOWN RECORD])

        StringBuffer buffer = new StringBuffer();

        buffer.append("[UNKNOWN RECORD:" + Integer.toHexString(sid) + "]\n");
        buffer.append("    .id        = ").append(Integer.toHexString(sid))
            .append("\n");
        buffer.append("[/UNKNOWN RECORD]\n");
        return buffer.toString();
    
protected voidvalidateSid(short id)
NO OP!


        // if we had a valid sid we wouldn't be using the "Unknown Record" record now would we?