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

BOFRecord

public class BOFRecord extends Record
Title: Beginning Of File

Description: Somewhat of a misnomer, its used for the beginning of a set of records that have a particular pupose or subject. Used in sheets and workbooks.

REFERENCE: PG 289 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

author
Andrew C. Oliver
author
Jason Height (jheight at chariot dot net dot au)
version
2.0-pre

Fields Summary
public static final short
sid
for BIFF8 files the BOF is 0x809. For earlier versions it was 0x09 or 0x(biffversion)09
private short
field_1_version
private short
field_2_type
private short
field_3_build
private short
field_4_year
private int
field_5_history
private int
field_6_rversion
public static final short
VERSION
suggested default (0x06 - BIFF8)
public static final short
BUILD
suggested default 0x10d3
public static final short
BUILD_YEAR
suggested default 0x07CC (1996)
public static final short
HISTORY_MASK
suggested default for a normal sheet (0x41)
public static final short
TYPE_WORKBOOK
public static final short
TYPE_VB_MODULE
public static final short
TYPE_WORKSHEET
public static final short
TYPE_CHART
public static final short
TYPE_EXCEL_4_MACRO
public static final short
TYPE_WORKSPACE_FILE
Constructors Summary
public BOFRecord()
Constructs an empty BOFRecord with no fields set.


                 

     
    
    
public BOFRecord(RecordInputStream in)
Constructs a BOFRecord and sets its fields appropriately

param
id id must be 0x809 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);

        // fillFields(data,size);
    
Methods Summary
public java.lang.Objectclone()

      BOFRecord rec = new BOFRecord();
      rec.field_1_version = field_1_version;
      rec.field_2_type = field_2_type;
      rec.field_3_build = field_3_build;
      rec.field_4_year = field_4_year;
      rec.field_5_history = field_5_history;
      rec.field_6_rversion = field_6_rversion;
      return rec;
    
protected voidfillFields(org.apache.poi.hssf.record.RecordInputStream in)

        field_1_version  = in.readShort();
        field_2_type     = in.readShort();
        field_3_build    = in.readShort();
        field_4_year     = in.readShort();
        field_5_history  = in.readInt();
        field_6_rversion = in.readInt();
    
public shortgetBuild()
get the build that wrote this file

see
#BUILD
return
short build number of the generator of this file

        return field_3_build;
    
public shortgetBuildYear()
Year of the build that wrote this file

see
#BUILD_YEAR
return
short build year of the generator of this file

        return field_4_year;
    
public intgetHistoryBitMask()
get the history bit mask (not very useful)

see
#HISTORY_MASK
return
int bitmask showing the history of the file (who cares!)

        return field_5_history;
    
public intgetRecordSize()

        return 20;
    
public intgetRequiredVersion()
get the minimum version required to read this file

see
#VERSION
return
int least version that can read the file

        return field_6_rversion;
    
public shortgetSid()

        return sid;
    
public shortgetType()
type of object this marks

see
#TYPE_WORKBOOK
see
#TYPE_VB_MODULE
see
#TYPE_WORKSHEET
see
#TYPE_CHART
see
#TYPE_EXCEL_4_MACRO
see
#TYPE_WORKSPACE_FILE
return
short type of object

        return field_2_type;
    
public shortgetVersion()
Version number - for BIFF8 should be 0x06

see
#VERSION
return
short version number of the generator of this file

        return field_1_version;
    
public intserialize(int offset, byte[] data)

        LittleEndian.putShort(data, 0 + offset, sid);
        LittleEndian.putShort(data, 2 + offset,
                              (( short ) 0x10));   // 16 byte length
        LittleEndian.putShort(data, 4 + offset, getVersion());
        LittleEndian.putShort(data, 6 + offset, getType());
        LittleEndian.putShort(data, 8 + offset, getBuild());
        LittleEndian.putShort(data, 10 + offset, getBuildYear());
        LittleEndian.putInt(data, 12 + offset, getHistoryBitMask());
        LittleEndian.putInt(data, 16 + offset, getRequiredVersion());
        return getRecordSize();
    
public voidsetBuild(short build)
build that wrote this file

see
#BUILD
param
build build number to set

        field_3_build = build;
    
public voidsetBuildYear(short year)
Year of the build that wrote this file

see
#BUILD_YEAR
param
year build year to set

        field_4_year = year;
    
public voidsetHistoryBitMask(int bitmask)
set the history bit mask (not very useful)

see
#HISTORY_MASK
param
bitmask bitmask to set for the history

        field_5_history = bitmask;
    
public voidsetRequiredVersion(int version)
set the minimum version required to read this file

see
#VERSION
param
version version to set

        field_6_rversion = version;
    
public voidsetType(short type)
type of object this marks

see
#TYPE_WORKBOOK
see
#TYPE_VB_MODULE
see
#TYPE_WORKSHEET
see
#TYPE_CHART
see
#TYPE_EXCEL_4_MACRO
see
#TYPE_WORKSPACE_FILE
param
type type to be set

        field_2_type = type;
    
public voidsetVersion(short version)
Version number - for BIFF8 should be 0x06

see
#VERSION
param
version version to be set

        field_1_version = version;
    
public java.lang.StringtoString()

        StringBuffer buffer = new StringBuffer();

        buffer.append("[BOF RECORD]\n");
        buffer.append("    .version         = ")
            .append(Integer.toHexString(getVersion())).append("\n");
        buffer.append("    .type            = ")
            .append(Integer.toHexString(getType())).append("\n");
        buffer.append("    .build           = ")
            .append(Integer.toHexString(getBuild())).append("\n");
        buffer.append("    .buildyear       = ").append(getBuildYear())
            .append("\n");
        buffer.append("    .history         = ")
            .append(Integer.toHexString(getHistoryBitMask())).append("\n");
        buffer.append("    .requiredversion = ")
            .append(Integer.toHexString(getRequiredVersion())).append("\n");
        buffer.append("[/BOF RECORD]\n");
        return buffer.toString();
    
protected voidvalidateSid(short id)

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