From: Josh Micich Date: Mon, 9 Feb 2009 23:16:49 +0000 (+0000) Subject: Refactored common CellValueRecordInterface code into a new superclass CellRecord X-Git-Tag: REL_3_5_BETA6~129 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=472815b5d25fdeb1a45262bf543495dd83fed70e;p=poi.git Refactored common CellValueRecordInterface code into a new superclass CellRecord git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@742785 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java index 5b8f9186d7..9aa862f7d2 100644 --- a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java +++ b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java @@ -27,47 +27,25 @@ import org.apache.poi.util.LittleEndianOutput; * @author Michael P. Harhen * @author Jason Height (jheight at chariot dot net dot au) */ -public final class BoolErrRecord extends StandardRecord implements CellValueRecordInterface { +public final class BoolErrRecord extends CellRecord { public final static short sid = 0x0205; - private int field_1_row; - private short field_2_column; - private short field_3_xf_index; private byte field_4_bBoolErr; private byte field_5_fError; /** Creates new BoolErrRecord */ public BoolErrRecord() { - + // fields uninitialised } /** * @param in the RecordInputstream to read the record from */ public BoolErrRecord(RecordInputStream in) { - field_1_row = in.readUShort(); - field_2_column = in.readShort(); - field_3_xf_index = in.readShort(); + super(in); field_4_bBoolErr = in.readByte(); field_5_fError = in.readByte(); } - public void setRow(int row) { - field_1_row = row; - } - - public void setColumn(short col) { - field_2_column = col; - } - - /** - * set the index to the ExtendedFormat - * @see org.apache.poi.hssf.record.ExtendedFormatRecord - * @param xf index to the XF record - */ - public void setXFIndex(short xf) { - field_3_xf_index = xf; - } - /** * set the boolean value for the cell * @@ -101,23 +79,6 @@ public final class BoolErrRecord extends StandardRecord implements CellValueReco throw new IllegalArgumentException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value); } - public int getRow() { - return field_1_row; - } - - public short getColumn() { - return field_2_column; - } - - /** - * get the index to the ExtendedFormat - * @see org.apache.poi.hssf.record.ExtendedFormatRecord - * @return index to the XF record - */ - public short getXFIndex() { - return field_3_xf_index; - } - /** * get the value for the cell * @@ -162,44 +123,39 @@ public final class BoolErrRecord extends StandardRecord implements CellValueReco return field_5_fError != 0; } - public String toString() { - StringBuffer sb = new StringBuffer(); - - sb.append("[BOOLERR]\n"); - sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); - sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n"); - sb.append(" .xfindex= ").append(HexDump.shortToHex(getXFIndex())).append("\n"); + @Override + protected String getRecordName() { + return "BOOLERR"; + } + @Override + protected void appendValueText(StringBuilder sb) { if (isBoolean()) { - sb.append(" .booleanValue = ").append(getBooleanValue()).append("\n"); + sb.append(" .boolVal = "); + sb.append(getBooleanValue()); } else { - sb.append(" .errorValue = ").append(getErrorValue()).append("\n"); + sb.append(" .errCode = "); + sb.append(ErrorConstants.getText(getErrorValue())); + sb.append(" (").append(HexDump.byteToHex(getErrorValue())).append(")"); } - sb.append("[/BOOLERR]\n"); - return sb.toString(); } - - public void serialize(LittleEndianOutput out) { - out.writeShort(getRow()); - out.writeShort(getColumn()); - out.writeShort(getXFIndex()); + @Override + protected void serializeValue(LittleEndianOutput out) { out.writeByte(field_4_bBoolErr); out.writeByte(field_5_fError); } - protected int getDataSize() { - return 8; + @Override + protected int getValueDataSize() { + return 2; } - public short getSid() - { + public short getSid() { return sid; } public Object clone() { BoolErrRecord rec = new BoolErrRecord(); - rec.field_1_row = field_1_row; - rec.field_2_column = field_2_column; - rec.field_3_xf_index = field_3_xf_index; + copyBaseFields(rec); rec.field_4_bBoolErr = field_4_bBoolErr; rec.field_5_fError = field_5_fError; return rec; diff --git a/src/java/org/apache/poi/hssf/record/CellRecord.java b/src/java/org/apache/poi/hssf/record/CellRecord.java new file mode 100644 index 0000000000..99ba1dde6d --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/CellRecord.java @@ -0,0 +1,132 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.hssf.record; + +import org.apache.poi.util.HexDump; +import org.apache.poi.util.LittleEndianOutput; + +/** + * Base class for all cell value records (implementors of {@link CellValueRecordInterface}). + * Subclasses are expected to manage the cell data values (of various types). + * + * @author Josh Micich + */ +public abstract class CellRecord extends StandardRecord implements CellValueRecordInterface { + private int _rowIndex; + private int _columnIndex; + private int _formatIndex; + + protected CellRecord() { + // fields uninitialised + } + + protected CellRecord(RecordInputStream in) { + _rowIndex = in.readUShort(); + _columnIndex = in.readUShort(); + _formatIndex = in.readUShort(); + } + + public final void setRow(int row) { + _rowIndex = row; + } + + public final void setColumn(short col) { + _columnIndex = col; + } + + /** + * set the index to the ExtendedFormat + * + * @see org.apache.poi.hssf.record.ExtendedFormatRecord + * @param xf index to the XF record + */ + public final void setXFIndex(short xf) { + _formatIndex = xf; + } + + public final int getRow() { + return _rowIndex; + } + + public final short getColumn() { + return (short) _columnIndex; + } + + /** + * get the index to the ExtendedFormat + * + * @see org.apache.poi.hssf.record.ExtendedFormatRecord + * @return index to the XF record + */ + public final short getXFIndex() { + return (short) _formatIndex; + } + + public final String toString() { + StringBuilder sb = new StringBuilder(); + String recordName = getRecordName(); + + sb.append("[").append(recordName).append("]\n"); + sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); + sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n"); + sb.append(" .xfindex= ").append(HexDump.shortToHex(getXFIndex())).append("\n"); + appendValueText(sb); + sb.append("\n"); + sb.append("[/NUMBER]\n"); + return sb.toString(); + } + + /** + * Append specific debug info (used by {@link #toString()} for the value + * contained in this record. Trailing new-line should not be appended + * (superclass does that). + */ + protected abstract void appendValueText(StringBuilder sb); + + /** + * Gets the debug info BIFF record type name (used by {@link #toString()}. + */ + protected abstract String getRecordName(); + + /** + * writes out the value data for this cell record + */ + protected abstract void serializeValue(LittleEndianOutput out); + + /** + * @return the size (in bytes) of the value data for this cell record + */ + protected abstract int getValueDataSize(); + + public final void serialize(LittleEndianOutput out) { + out.writeShort(getRow()); + out.writeShort(getColumn()); + out.writeShort(getXFIndex()); + serializeValue(out); + } + + protected final int getDataSize() { + return 6 + getValueDataSize(); + } + + protected final void copyBaseFields(CellRecord rec) { + rec._rowIndex = _rowIndex; + rec._columnIndex = _columnIndex; + rec._formatIndex = _formatIndex; + } +} diff --git a/src/java/org/apache/poi/hssf/record/FormulaRecord.java b/src/java/org/apache/poi/hssf/record/FormulaRecord.java index 53ad71a51d..cd38fefd52 100644 --- a/src/java/org/apache/poi/hssf/record/FormulaRecord.java +++ b/src/java/org/apache/poi/hssf/record/FormulaRecord.java @@ -24,7 +24,6 @@ import org.apache.poi.ss.formula.Formula; import org.apache.poi.util.BitField; import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.HexDump; -import org.apache.poi.util.LittleEndianByteArrayOutputStream; import org.apache.poi.util.LittleEndianInput; import org.apache.poi.util.LittleEndianOutput; @@ -33,12 +32,11 @@ import org.apache.poi.util.LittleEndianOutput; * REFERENCE: PG 317/444 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) * @author Jason Height (jheight at chariot dot net dot au) - * @version 2.0-pre */ -public final class FormulaRecord extends StandardRecord implements CellValueRecordInterface { +public final class FormulaRecord extends CellRecord { public static final short sid = 0x0006; // docs say 406...because of a bug Microsoft support site article #Q184647) - private static int FIXED_SIZE = 20; + private static int FIXED_SIZE = 14; // double + short + int private static final BitField alwaysCalc = BitFieldFactory.getInstance(0x0001); private static final BitField calcOnLoad = BitFieldFactory.getInstance(0x0002); @@ -168,11 +166,6 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco } } - - - private int field_1_row; - private short field_2_column; - private short field_3_xf; private double field_4_value; private short field_5_options; /** @@ -195,10 +188,8 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco } public FormulaRecord(RecordInputStream ris) { + super(ris); LittleEndianInput in = ris; - field_1_row = in.readUShort(); - field_2_column = in.readShort(); - field_3_xf = in.readShort(); long valueLongBits = in.readLong(); field_5_options = in.readShort(); specialCachedValue = SpecialCachedValue.create(valueLongBits); @@ -213,19 +204,6 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco field_8_parsed_expr = Formula.read(field_7_expression_len, in, nBytesAvailable); } - - public void setRow(int row) { - field_1_row = row; - } - - public void setColumn(short column) { - field_2_column = column; - } - - public void setXFIndex(short xf) { - field_3_xf = xf; - } - /** * set the calculated value of the formula * @@ -284,18 +262,6 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco field_5_options = options; } - public int getRow() { - return field_1_row; - } - - public short getColumn() { - return field_2_column; - } - - public short getXFIndex() { - return field_3_xf; - } - /** * get the calculated value of the formula * @@ -357,14 +323,12 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco return sid; } - protected int getDataSize() { + @Override + protected int getValueDataSize() { return FIXED_SIZE + field_8_parsed_expr.getEncodedSize(); } - public void serialize(LittleEndianOutput out) { - - out.writeShort(getRow()); - out.writeShort(getColumn()); - out.writeShort(getXFIndex()); + @Override + protected void serializeValue(LittleEndianOutput out) { if (specialCachedValue == null) { out.writeDouble(field_4_value); @@ -377,14 +341,14 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco out.writeInt(field_6_zero); // may as well write original data back so as to minimise differences from original field_8_parsed_expr.serialize(out); } - - public String toString() { - - StringBuffer sb = new StringBuffer(); - sb.append("[FORMULA]\n"); - sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); - sb.append(" .column = ").append(HexDump.shortToHex(getColumn())).append("\n"); - sb.append(" .xf = ").append(HexDump.shortToHex(getXFIndex())).append("\n"); + + @Override + protected String getRecordName() { + return "FORMULA"; + } + + @Override + protected void appendValueText(StringBuilder sb) { sb.append(" .value = "); if (specialCachedValue == null) { sb.append(field_4_value).append("\n"); @@ -395,23 +359,22 @@ public final class FormulaRecord extends StandardRecord implements CellValueReco sb.append(" .alwaysCalc= ").append(isAlwaysCalc()).append("\n"); sb.append(" .calcOnLoad= ").append(isCalcOnLoad()).append("\n"); sb.append(" .shared = ").append(isSharedFormula()).append("\n"); - sb.append(" .zero = ").append(HexDump.intToHex(field_6_zero)).append("\n"); + sb.append(" .zero = ").append(HexDump.intToHex(field_6_zero)); Ptg[] ptgs = field_8_parsed_expr.getTokens(); for (int k = 0; k < ptgs.length; k++ ) { + if (k>0) { + sb.append("\n"); + } sb.append(" Ptg[").append(k).append("]="); Ptg ptg = ptgs[k]; - sb.append(ptg.toString()).append(ptg.getRVAType()).append("\n"); + sb.append(ptg.toString()).append(ptg.getRVAType()); } - sb.append("[/FORMULA]\n"); - return sb.toString(); } public Object clone() { FormulaRecord rec = new FormulaRecord(); - rec.field_1_row = field_1_row; - rec.field_2_column = field_2_column; - rec.field_3_xf = field_3_xf; + copyBaseFields(rec); rec.field_4_value = field_4_value; rec.field_5_options = field_5_options; rec.field_6_zero = field_6_zero; diff --git a/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java b/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java index ee371b5203..83667ef55f 100644 --- a/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java +++ b/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java @@ -27,82 +27,30 @@ import org.apache.poi.util.LittleEndianOutput; * REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) * @author Jason Height (jheight at chariot dot net dot au) - * @version 2.0-pre */ -public final class LabelSSTRecord extends StandardRecord implements CellValueRecordInterface { +public final class LabelSSTRecord extends CellRecord { public final static short sid = 0xfd; - private int field_1_row; - private int field_2_column; - private int field_3_xf_index; private int field_4_sst_index; - public LabelSSTRecord() - { + public LabelSSTRecord() { + // fields uninitialised } - public LabelSSTRecord(RecordInputStream in) - { - field_1_row = in.readUShort(); - field_2_column = in.readUShort(); - field_3_xf_index = in.readUShort(); + public LabelSSTRecord(RecordInputStream in) { + super(in); field_4_sst_index = in.readInt(); } - public void setRow(int row) - { - field_1_row = row; - } - - public void setColumn(short col) - { - field_2_column = col; - } - - /** - * set the index to the extended format record - * - * @see org.apache.poi.hssf.record.ExtendedFormatRecord - * @param index - the index to the XF record - */ - - public void setXFIndex(short index) - { - field_3_xf_index = index; - } - /** * set the index to the string in the SSTRecord * * @param index - of string in the SST Table * @see org.apache.poi.hssf.record.SSTRecord */ - - public void setSSTIndex(int index) - { + public void setSSTIndex(int index) { field_4_sst_index = index; } - public int getRow() - { - return field_1_row; - } - - public short getColumn() - { - return (short)field_2_column; - } - - /** - * get the index to the extended format record - * - * @see org.apache.poi.hssf.record.ExtendedFormatRecord - * @return the index to the XF record - */ - - public short getXFIndex() - { - return (short)field_3_xf_index; - } /** * get the index to the string in the SSTRecord @@ -110,46 +58,37 @@ public final class LabelSSTRecord extends StandardRecord implements CellValueRec * @return index of string in the SST Table * @see org.apache.poi.hssf.record.SSTRecord */ - - public int getSSTIndex() - { + public int getSSTIndex() { return field_4_sst_index; } - - public String toString() - { - StringBuffer sb = new StringBuffer(); - - sb.append("[LABELSST]\n"); - sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); - sb.append(" .column = ").append(HexDump.shortToHex(getColumn())).append("\n"); - sb.append(" .xfindex = ").append(HexDump.shortToHex(getXFIndex())).append("\n"); - sb.append(" .sstindex= ").append(HexDump.intToHex(getSSTIndex())).append("\n"); - sb.append("[/LABELSST]\n"); - return sb.toString(); + + @Override + protected String getRecordName() { + return "LABELSST"; } - public void serialize(LittleEndianOutput out) { - out.writeShort(getRow()); - out.writeShort(getColumn()); - out.writeShort(getXFIndex()); + @Override + protected void appendValueText(StringBuilder sb) { + sb.append(" .sstIndex = "); + sb.append(HexDump.shortToHex(getXFIndex())); + } + @Override + protected void serializeValue(LittleEndianOutput out) { out.writeInt(getSSTIndex()); } - protected int getDataSize() { - return 10; + @Override + protected int getValueDataSize() { + return 4; } - public short getSid() - { + public short getSid() { return sid; } public Object clone() { LabelSSTRecord rec = new LabelSSTRecord(); - rec.field_1_row = field_1_row; - rec.field_2_column = field_2_column; - rec.field_3_xf_index = field_3_xf_index; + copyBaseFields(rec); rec.field_4_sst_index = field_4_sst_index; return rec; } diff --git a/src/java/org/apache/poi/hssf/record/NumberRecord.java b/src/java/org/apache/poi/hssf/record/NumberRecord.java index 5724b41a7c..7380165c91 100644 --- a/src/java/org/apache/poi/hssf/record/NumberRecord.java +++ b/src/java/org/apache/poi/hssf/record/NumberRecord.java @@ -17,134 +17,77 @@ package org.apache.poi.hssf.record; -import org.apache.poi.util.HexDump; +import org.apache.poi.ss.util.NumberToTextConverter; import org.apache.poi.util.LittleEndianOutput; -import org.apache.poi.hssf.record.Record; /** * NUMBER (0x0203) Contains a numeric cell value.

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

* @author Andrew C. Oliver (acoliver at apache dot org) * @author Jason Height (jheight at chariot dot net dot au) - * @version 2.0-pre */ -public final class NumberRecord extends StandardRecord implements CellValueRecordInterface { +public final class NumberRecord extends CellRecord { public static final short sid = 0x0203; - private int field_1_row; - private int field_2_col; - private int field_3_xf; private double field_4_value; /** Creates new NumberRecord */ - public NumberRecord() - { + public NumberRecord() { + // fields uninitialised } /** * @param in the RecordInputstream to read the record from */ - public NumberRecord(RecordInputStream in) - { - field_1_row = in.readUShort(); - field_2_col = in.readUShort(); - field_3_xf = in.readUShort(); + public NumberRecord(RecordInputStream in) { + super(in); field_4_value = in.readDouble(); } - public void setRow(int row) - { - field_1_row = row; - } - - public void setColumn(short col) - { - field_2_col = col; - } - - /** - * set the index to the ExtendedFormat - * @see org.apache.poi.hssf.record.ExtendedFormatRecord - * @param xf index to the XF record - */ - public void setXFIndex(short xf) - { - field_3_xf = xf; - } - /** * set the value for the cell * * @param value double representing the value */ - public void setValue(double value) - { + public void setValue(double value){ field_4_value = value; } - public int getRow() - { - return field_1_row; - } - - public short getColumn() - { - return (short)field_2_col; - } - - /** - * get the index to the ExtendedFormat - * @see org.apache.poi.hssf.record.ExtendedFormatRecord - * @return index to the XF record - */ - public short getXFIndex() - { - return (short)field_3_xf; - } - /** * get the value for the cell * * @return double representing the value */ - public double getValue() - { + public double getValue(){ return field_4_value; } - public String toString() - { - StringBuffer sb = new StringBuffer(); + @Override + protected String getRecordName() { + return "NUMBER"; + } - sb.append("[NUMBER]\n"); - sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); - sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n"); - sb.append(" .xfindex= ").append(HexDump.shortToHex(getXFIndex())).append("\n"); - sb.append(" .value = ").append(getValue()).append("\n"); - sb.append("[/NUMBER]\n"); - return sb.toString(); + @Override + protected void appendValueText(StringBuilder sb) { + sb.append(" .value= ").append(NumberToTextConverter.toText(field_4_value)); } - public void serialize(LittleEndianOutput out) { - out.writeShort(getRow()); - out.writeShort(getColumn()); - out.writeShort(getXFIndex()); + @Override + protected void serializeValue(LittleEndianOutput out) { out.writeDouble(getValue()); } - protected int getDataSize() { - return 14; + @Override + protected int getValueDataSize() { + return 8; } - public short getSid() - { + public short getSid() { return sid; } public Object clone() { NumberRecord rec = new NumberRecord(); - rec.field_1_row = field_1_row; - rec.field_2_col = field_2_col; - rec.field_3_xf = field_3_xf; + copyBaseFields(rec); rec.field_4_value = field_4_value; return rec; } diff --git a/src/java/org/apache/poi/hssf/record/RKRecord.java b/src/java/org/apache/poi/hssf/record/RKRecord.java index 966aaf219c..4ad30d915f 100644 --- a/src/java/org/apache/poi/hssf/record/RKRecord.java +++ b/src/java/org/apache/poi/hssf/record/RKRecord.java @@ -18,7 +18,6 @@ package org.apache.poi.hssf.record; import org.apache.poi.hssf.util.RKUtil; -import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndianOutput; /** @@ -37,65 +36,23 @@ import org.apache.poi.util.LittleEndianOutput; * @author Jason Height (jheight at chariot dot net dot au) * @see org.apache.poi.hssf.record.NumberRecord */ -public final class RKRecord extends StandardRecord implements CellValueRecordInterface { +public final class RKRecord extends CellRecord { public final static short sid = 0x027E; public final static short RK_IEEE_NUMBER = 0; public final static short RK_IEEE_NUMBER_TIMES_100 = 1; public final static short RK_INTEGER = 2; public final static short RK_INTEGER_TIMES_100 = 3; - private int field_1_row; - private int field_2_col; - private int field_3_xf_index; private int field_4_rk_number; - private RKRecord() - { + private RKRecord() { + // fields uninitialised } - public RKRecord(RecordInputStream in) - { - field_1_row = in.readUShort(); - field_2_col = in.readUShort(); - field_3_xf_index = in.readUShort(); + public RKRecord(RecordInputStream in) { + super(in); field_4_rk_number = in.readInt(); } - public int getRow() - { - return field_1_row; - } - - public short getColumn() - { - return (short) field_2_col; - } - - public short getXFIndex() - { - return (short) field_3_xf_index; - } - - public int getRKField() - { - return field_4_rk_number; - } - - /** - * Get the type of the number - * - * @return one of these values: - *

    - *
  1. RK_IEEE_NUMBER
  2. - *
  3. RK_IEEE_NUMBER_TIMES_100
  4. - *
  5. RK_INTEGER
  6. - *
  7. RK_INTEGER_TIMES_100
  8. - *
- */ - public short getRKType() - { - return ( short ) (field_4_rk_number & 3); - } - /** * Extract the value of the number *

@@ -113,60 +70,37 @@ public final class RKRecord extends StandardRecord implements CellValueRecordInt * @return the value as a proper double (hey, it could * happen) */ - public double getRKNumber() - { + public double getRKNumber() { return RKUtil.decodeNumber(field_4_rk_number); } - - public String toString() - { - StringBuffer sb = new StringBuffer(); - - sb.append("[RK]\n"); - sb.append(" .row = ").append(HexDump.shortToHex(getRow())).append("\n"); - sb.append(" .col = ").append(HexDump.shortToHex(getColumn())).append("\n"); - sb.append(" .xfindex = ").append(HexDump.shortToHex(getXFIndex())).append("\n"); - sb.append(" .rknumber = ").append(HexDump.intToHex(getRKField())).append("\n"); - sb.append(" .rktype = ").append(HexDump.byteToHex(getRKType())).append("\n"); - sb.append(" .rknumber= ").append(getRKNumber()).append("\n"); - sb.append("[/RK]\n"); - return sb.toString(); + @Override + protected String getRecordName() { + return "RK"; } - public void serialize(LittleEndianOutput out) { - throw new RecordFormatException( "Sorry, you can't serialize RK in this release"); - } - protected int getDataSize() { - throw new RecordFormatException( "Sorry, you can't serialize RK in this release"); - } - - public short getSid() - { - return sid; + @Override + protected void appendValueText(StringBuilder sb) { + sb.append(" .value= ").append(getRKNumber()); } - public void setColumn(short col) - { + @Override + protected void serializeValue(LittleEndianOutput out) { + out.writeInt(field_4_rk_number); } - public void setRow(int row) - { + @Override + protected int getValueDataSize() { + return 4; } - /** - * NO OP! - */ - - public void setXFIndex(short xf) - { + public short getSid() { + return sid; } public Object clone() { RKRecord rec = new RKRecord(); - rec.field_1_row = field_1_row; - rec.field_2_col = field_2_col; - rec.field_3_xf_index = field_3_xf_index; + copyBaseFields(rec); rec.field_4_rk_number = field_4_rk_number; return rec; }