improved toString methods
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@721043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b780e3173a
commit
c87a1fe88a
@ -1,4 +1,3 @@
|
||||
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
@ -16,78 +15,56 @@
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
|
||||
package org.apache.poi.hssf.record;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.LittleEndianOutput;
|
||||
|
||||
/**
|
||||
* Title: Beginning Of File<P>
|
||||
* Title: Beginning Of File (0x0809)<P>
|
||||
* Description: Somewhat of a misnomer, its used for the beginning of a set of
|
||||
* records that have a particular pupose or subject.
|
||||
* records that have a particular purpose or subject.
|
||||
* Used in sheets and workbooks.<P>
|
||||
* REFERENCE: PG 289 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
|
||||
* @author Andrew C. Oliver
|
||||
* @author Jason Height (jheight at chariot dot net dot au)
|
||||
* @version 2.0-pre
|
||||
*/
|
||||
|
||||
public final class BOFRecord
|
||||
extends StandardRecord
|
||||
{
|
||||
|
||||
public final class BOFRecord extends StandardRecord {
|
||||
/**
|
||||
* for BIFF8 files the BOF is 0x809. For earlier versions it was 0x09 or 0x(biffversion)09
|
||||
*/
|
||||
|
||||
public final static short sid = 0x809;
|
||||
private short field_1_version;
|
||||
private short field_2_type;
|
||||
private short field_3_build;
|
||||
private short field_4_year;
|
||||
|
||||
/** suggested default (0x06 - BIFF8) */
|
||||
public final static int VERSION = 0x06;
|
||||
/** suggested default 0x10d3 */
|
||||
public final static int BUILD = 0x10d3;
|
||||
/** suggested default 0x07CC (1996) */
|
||||
public final static int BUILD_YEAR = 0x07CC; // 1996
|
||||
/** suggested default for a normal sheet (0x41) */
|
||||
public final static int HISTORY_MASK = 0x41;
|
||||
|
||||
public final static int TYPE_WORKBOOK = 0x05;
|
||||
public final static int TYPE_VB_MODULE = 0x06;
|
||||
public final static int TYPE_WORKSHEET = 0x10;
|
||||
public final static int TYPE_CHART = 0x20;
|
||||
public final static int TYPE_EXCEL_4_MACRO = 0x40;
|
||||
public final static int TYPE_WORKSPACE_FILE = 0x100;
|
||||
|
||||
private int field_1_version;
|
||||
private int field_2_type;
|
||||
private int field_3_build;
|
||||
private int field_4_year;
|
||||
private int field_5_history;
|
||||
private int field_6_rversion;
|
||||
|
||||
/**
|
||||
* suggested default (0x06 - BIFF8)
|
||||
*/
|
||||
|
||||
public final static short VERSION = 0x06;
|
||||
|
||||
/**
|
||||
* suggested default 0x10d3
|
||||
*/
|
||||
|
||||
public final static short BUILD = 0x10d3;
|
||||
|
||||
/**
|
||||
* suggested default 0x07CC (1996)
|
||||
*/
|
||||
|
||||
public final static short BUILD_YEAR = 0x07CC; // 1996
|
||||
|
||||
/**
|
||||
* suggested default for a normal sheet (0x41)
|
||||
*/
|
||||
|
||||
public final static short HISTORY_MASK = 0x41;
|
||||
public final static short TYPE_WORKBOOK = 0x05;
|
||||
public final static short TYPE_VB_MODULE = 0x06;
|
||||
public final static short TYPE_WORKSHEET = 0x10;
|
||||
public final static short TYPE_CHART = 0x20;
|
||||
public final static short TYPE_EXCEL_4_MACRO = 0x40;
|
||||
public final static short TYPE_WORKSPACE_FILE = 0x100;
|
||||
|
||||
/**
|
||||
* Constructs an empty BOFRecord with no fields set.
|
||||
*/
|
||||
|
||||
public BOFRecord()
|
||||
{
|
||||
public BOFRecord() {
|
||||
}
|
||||
|
||||
public BOFRecord(RecordInputStream in)
|
||||
{
|
||||
public BOFRecord(RecordInputStream in) {
|
||||
field_1_version = in.readShort();
|
||||
field_2_type = in.readShort();
|
||||
|
||||
@ -112,9 +89,7 @@ public final class BOFRecord
|
||||
* @see #VERSION
|
||||
* @param version version to be set
|
||||
*/
|
||||
|
||||
public void setVersion(short version)
|
||||
{
|
||||
public void setVersion(int version) {
|
||||
field_1_version = version;
|
||||
}
|
||||
|
||||
@ -128,9 +103,7 @@ public final class BOFRecord
|
||||
* @see #TYPE_WORKSPACE_FILE
|
||||
* @param type type to be set
|
||||
*/
|
||||
|
||||
public void setType(short type)
|
||||
{
|
||||
public void setType(int type) {
|
||||
field_2_type = type;
|
||||
}
|
||||
|
||||
@ -139,9 +112,7 @@ public final class BOFRecord
|
||||
* @see #BUILD
|
||||
* @param build build number to set
|
||||
*/
|
||||
|
||||
public void setBuild(short build)
|
||||
{
|
||||
public void setBuild(int build) {
|
||||
field_3_build = build;
|
||||
}
|
||||
|
||||
@ -150,9 +121,7 @@ public final class BOFRecord
|
||||
* @see #BUILD_YEAR
|
||||
* @param year build year to set
|
||||
*/
|
||||
|
||||
public void setBuildYear(short year)
|
||||
{
|
||||
public void setBuildYear(int year) {
|
||||
field_4_year = year;
|
||||
}
|
||||
|
||||
@ -161,9 +130,7 @@ public final class BOFRecord
|
||||
* @see #HISTORY_MASK
|
||||
* @param bitmask bitmask to set for the history
|
||||
*/
|
||||
|
||||
public void setHistoryBitMask(int bitmask)
|
||||
{
|
||||
public void setHistoryBitMask(int bitmask) {
|
||||
field_5_history = bitmask;
|
||||
}
|
||||
|
||||
@ -173,20 +140,16 @@ public final class BOFRecord
|
||||
* @see #VERSION
|
||||
* @param version version to set
|
||||
*/
|
||||
|
||||
public void setRequiredVersion(int version)
|
||||
{
|
||||
public void setRequiredVersion(int version) {
|
||||
field_6_rversion = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Version number - for BIFF8 should be 0x06
|
||||
* @see #VERSION
|
||||
* @return short version number of the generator of this file
|
||||
* @return version number of the generator of this file
|
||||
*/
|
||||
|
||||
public short getVersion()
|
||||
{
|
||||
public int getVersion() {
|
||||
return field_1_version;
|
||||
}
|
||||
|
||||
@ -198,11 +161,9 @@ public final class BOFRecord
|
||||
* @see #TYPE_CHART
|
||||
* @see #TYPE_EXCEL_4_MACRO
|
||||
* @see #TYPE_WORKSPACE_FILE
|
||||
* @return short type of object
|
||||
* @return type of object
|
||||
*/
|
||||
|
||||
public short getType()
|
||||
{
|
||||
public int getType() {
|
||||
return field_2_type;
|
||||
}
|
||||
|
||||
@ -211,9 +172,7 @@ public final class BOFRecord
|
||||
* @see #BUILD
|
||||
* @return short build number of the generator of this file
|
||||
*/
|
||||
|
||||
public short getBuild()
|
||||
{
|
||||
public int getBuild() {
|
||||
return field_3_build;
|
||||
}
|
||||
|
||||
@ -222,9 +181,7 @@ public final class BOFRecord
|
||||
* @see #BUILD_YEAR
|
||||
* @return short build year of the generator of this file
|
||||
*/
|
||||
|
||||
public short getBuildYear()
|
||||
{
|
||||
public int getBuildYear() {
|
||||
return field_4_year;
|
||||
}
|
||||
|
||||
@ -233,9 +190,7 @@ public final class BOFRecord
|
||||
* @see #HISTORY_MASK
|
||||
* @return int bitmask showing the history of the file (who cares!)
|
||||
*/
|
||||
|
||||
public int getHistoryBitMask()
|
||||
{
|
||||
public int getHistoryBitMask() {
|
||||
return field_5_history;
|
||||
}
|
||||
|
||||
@ -245,33 +200,37 @@ public final class BOFRecord
|
||||
* @see #VERSION
|
||||
* @return int least version that can read the file
|
||||
*/
|
||||
|
||||
public int getRequiredVersion()
|
||||
{
|
||||
public int getRequiredVersion() {
|
||||
return field_6_rversion;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
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(" .version = ").append(HexDump.shortToHex(getVersion())).append("\n");
|
||||
buffer.append(" .type = ").append(HexDump.shortToHex(getType()));
|
||||
buffer.append(" (").append(getTypeName()).append(")").append("\n");
|
||||
buffer.append(" .build = ").append(HexDump.shortToHex(getBuild())).append("\n");
|
||||
buffer.append(" .buildyear= ").append(getBuildYear()).append("\n");
|
||||
buffer.append(" .history = ").append(HexDump.intToHex(getHistoryBitMask())).append("\n");
|
||||
buffer.append(" .reqver = ").append(HexDump.intToHex(getRequiredVersion())).append("\n");
|
||||
buffer.append("[/BOF RECORD]\n");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private String getTypeName() {
|
||||
switch(field_2_type) {
|
||||
case TYPE_CHART: return "chart";
|
||||
case TYPE_EXCEL_4_MACRO: return "excel 4 macro";
|
||||
case TYPE_VB_MODULE: return "vb module";
|
||||
case TYPE_WORKBOOK: return "workbook";
|
||||
case TYPE_WORKSHEET: return "worksheet";
|
||||
case TYPE_WORKSPACE_FILE: return "workspace file";
|
||||
}
|
||||
return "#error unknown type#";
|
||||
}
|
||||
|
||||
public void serialize(LittleEndianOutput out) {
|
||||
out.writeShort(getVersion());
|
||||
out.writeShort(getType());
|
||||
@ -285,8 +244,7 @@ public final class BOFRecord
|
||||
return 16;
|
||||
}
|
||||
|
||||
public short getSid()
|
||||
{
|
||||
public short getSid(){
|
||||
return sid;
|
||||
}
|
||||
|
||||
|
@ -66,31 +66,21 @@ public final class LinkedDataRecord extends StandardRecord {
|
||||
field_5_formulaOfLink = Formula.read(encodedTokenLen, in);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append("[AI]\n");
|
||||
buffer.append(" .linkType = ")
|
||||
.append("0x").append(HexDump.toHex( getLinkType ()))
|
||||
.append(" (").append( getLinkType() ).append(" )");
|
||||
buffer.append(System.getProperty("line.separator"));
|
||||
buffer.append(" .referenceType = ")
|
||||
.append("0x").append(HexDump.toHex( getReferenceType ()))
|
||||
.append(" (").append( getReferenceType() ).append(" )");
|
||||
buffer.append(System.getProperty("line.separator"));
|
||||
buffer.append(" .options = ")
|
||||
.append("0x").append(HexDump.toHex( getOptions ()))
|
||||
.append(" (").append( getOptions() ).append(" )");
|
||||
buffer.append(System.getProperty("line.separator"));
|
||||
buffer.append(" .linkType = ").append(HexDump.byteToHex(getLinkType())).append('\n');
|
||||
buffer.append(" .referenceType = ").append(HexDump.byteToHex(getReferenceType())).append('\n');
|
||||
buffer.append(" .options = ").append(HexDump.shortToHex(getOptions())).append('\n');
|
||||
buffer.append(" .customNumberFormat = ").append(isCustomNumberFormat()).append('\n');
|
||||
buffer.append(" .indexNumberFmtRecord = ")
|
||||
.append("0x").append(HexDump.toHex( getIndexNumberFmtRecord ()))
|
||||
.append(" (").append( getIndexNumberFmtRecord() ).append(" )");
|
||||
buffer.append(System.getProperty("line.separator"));
|
||||
buffer.append(" .formulaOfLink = ")
|
||||
.append(" (").append( getFormulaOfLink() ).append(" )");
|
||||
buffer.append(System.getProperty("line.separator"));
|
||||
buffer.append(" .indexNumberFmtRecord = ").append(HexDump.shortToHex(getIndexNumberFmtRecord())).append('\n');
|
||||
buffer.append(" .formulaOfLink = ").append('\n');
|
||||
Ptg[] ptgs = field_5_formulaOfLink.getTokens();
|
||||
for (int i = 0; i < ptgs.length; i++) {
|
||||
Ptg ptg = ptgs[i];
|
||||
buffer.append(ptg.toString()).append(ptg.getRVAType()).append('\n');
|
||||
}
|
||||
|
||||
buffer.append("[/AI]\n");
|
||||
return buffer.toString();
|
||||
|
Loading…
Reference in New Issue
Block a user