* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public class BlankRecord
- extends Record
- implements CellValueRecordInterface, Comparable
-{
+public final class BlankRecord extends Record implements CellValueRecordInterface {
public final static short sid = 0x201;
- //private short field_1_row;
private int field_1_row;
private short field_2_col;
private short field_3_xf;
field_2_col = col;
}
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
return 10;
}
- public int compareTo(Object obj)
- {
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return 0;
- }
- if (this.getRow() < loc.getRow())
- {
- return -1;
- }
- if (this.getRow() > loc.getRow())
- {
- return 1;
- }
- if (this.getColumn() < loc.getColumn())
- {
- return -1;
- }
- if (this.getColumn() > loc.getColumn())
- {
- return 1;
- }
- return -1;
- }
-
- public boolean equals(Object obj)
- {
- if (!(obj instanceof CellValueRecordInterface))
- {
- return false;
- }
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return true;
- }
- return false;
- }
-
public Object clone() {
BlankRecord rec = new BlankRecord();
rec.field_1_row = field_1_row;
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public class BoolErrRecord
- extends Record
- implements CellValueRecordInterface, Comparable
-{
+public final class BoolErrRecord extends Record implements CellValueRecordInterface {
public final static short sid = 0x205;
- //private short field_1_row;
- private int field_1_row;
+ private int field_1_row;
private short field_2_column;
private short field_3_xf_index;
private byte field_4_bBoolErr;
return sid;
}
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
return true;
}
- public int compareTo(Object obj)
- {
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return 0;
- }
- if (this.getRow() < loc.getRow())
- {
- return -1;
- }
- if (this.getRow() > loc.getRow())
- {
- return 1;
- }
- if (this.getColumn() < loc.getColumn())
- {
- return -1;
- }
- if (this.getColumn() > loc.getColumn())
- {
- return 1;
- }
- return -1;
- }
-
- public boolean equals(Object obj)
- {
- if (!(obj instanceof CellValueRecordInterface))
- {
- return false;
- }
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return true;
- }
- return false;
- }
-
public Object clone() {
BoolErrRecord rec = new BoolErrRecord();
rec.field_1_row = field_1_row;
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * CellValueRecordInterface.java
- *
- * Created on October 2, 2001, 8:27 PM
- */
package org.apache.poi.hssf.record;
/**
* @see org.apache.poi.hssf.record.Record
* @see org.apache.poi.hssf.record.RecordFactory
*/
-
-public interface CellValueRecordInterface
-{
+public interface CellValueRecordInterface {
/**
- * get the row this cell occurs on
- *
- * @return the row
+ * @return the row this cell occurs on
*/
-
- //public short getRow();
- public int getRow();
+ int getRow();
/**
- * get the column this cell defines within the row
- *
- * @return the column
+ * @return the column this cell defines within the row
*/
-
- public short getColumn();
+ short getColumn();
/**
- * set the row this cell occurs on
* @param row the row this cell occurs within
*/
-
- //public void setRow(short row);
- public void setRow(int row);
+ void setRow(int row);
/**
- * set the column this cell defines within the row
- *
* @param col the column this cell defines
*/
+ void setColumn(short col);
- public void setColumn(short col);
-
- public void setXFIndex(short xf);
-
- public short getXFIndex();
-
- /**
- * returns whether this cell is before the passed in cell
- *
- * @param i another cell interface record to compare
- * @return true if the cells is before, or false if not
- */
-
- public boolean isBefore(CellValueRecordInterface i);
-
- /**
- * returns whether this cell is after the passed in cell
- *
- * @param i record to compare
- * @return true if the cell is after, false if not
- */
-
- public boolean isAfter(CellValueRecordInterface i);
-
- /**
- * returns whether this cell represents the same cell (NOT VALUE)
- *
- * @param i record to compare
- * @return true if the cells are the same cell (positionally), false if not.
- */
-
- public boolean isEqual(CellValueRecordInterface i);
+ void setXFIndex(short xf);
- public Object clone();
+ short getXFIndex();
}
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-public final class FormulaRecord
- extends Record
- implements CellValueRecordInterface, Comparable
-{
+public final class FormulaRecord extends Record implements CellValueRecordInterface {
public static final short sid = 0x0006; // docs say 406...because of a bug Microsoft support site article #Q184647)
return retval;
}
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
{
return true;
}
-
- public int compareTo(Object obj)
- {
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return 0;
- }
- if (this.getRow() < loc.getRow())
- {
- return -1;
- }
- if (this.getRow() > loc.getRow())
- {
- return 1;
- }
- if (this.getColumn() < loc.getColumn())
- {
- return -1;
- }
- if (this.getColumn() > loc.getColumn())
- {
- return 1;
- }
- return -1;
- }
-
- public boolean equals(Object obj)
- {
- if (!(obj instanceof CellValueRecordInterface))
- {
- return false;
- }
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return true;
- }
- return false;
- }
-
public String toString()
{
return buffer.toString();
}
-
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public class LabelSSTRecord
- extends Record
- implements CellValueRecordInterface, Comparable
-{
+public final class LabelSSTRecord extends Record implements CellValueRecordInterface {
public final static short sid = 0xfd;
- //private short field_1_row;
private int field_1_row;
private short field_2_column;
private short field_3_xf_index;
return sid;
}
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
return true;
}
- public int compareTo(Object obj)
- {
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return 0;
- }
- if (this.getRow() < loc.getRow())
- {
- return -1;
- }
- if (this.getRow() > loc.getRow())
- {
- return 1;
- }
- if (this.getColumn() < loc.getColumn())
- {
- return -1;
- }
- if (this.getColumn() > loc.getColumn())
- {
- return 1;
- }
- return -1;
- }
-
- public boolean equals(Object obj)
- {
- if (!(obj instanceof CellValueRecordInterface))
- {
- return false;
- }
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return true;
- }
- return false;
- }
-
public Object clone() {
LabelSSTRecord rec = new LabelSSTRecord();
rec.field_1_row = field_1_row;
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-/*
- * NumberRecord.java
- *
- * Created on October 1, 2001, 8:01 PM
- */
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian;
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public class NumberRecord
- extends Record
- implements CellValueRecordInterface, Comparable
-{
+public final class NumberRecord extends Record implements CellValueRecordInterface {
public static final short sid = 0x203;
- //private short field_1_row;
private int field_1_row;
private short field_2_col;
private short field_3_xf;
return sid;
}
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
return true;
}
- public int compareTo(Object obj)
- {
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return 0;
- }
- if (this.getRow() < loc.getRow())
- {
- return -1;
- }
- if (this.getRow() > loc.getRow())
- {
- return 1;
- }
- if (this.getColumn() < loc.getColumn())
- {
- return -1;
- }
- if (this.getColumn() > loc.getColumn())
- {
- return 1;
- }
- return -1;
- }
-
- public boolean equals(Object obj)
- {
- if (!(obj instanceof CellValueRecordInterface))
- {
- return false;
- }
- CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
-
- if ((this.getRow() == loc.getRow())
- && (this.getColumn() == loc.getColumn()))
- {
- return true;
- }
- return false;
- }
-
public Object clone() {
NumberRecord rec = new NumberRecord();
rec.field_1_row = field_1_row;
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
* @version 2.0-pre
* @see org.apache.poi.hssf.record.NumberRecord
*/
-
-public class RKRecord
- extends Record
- implements CellValueRecordInterface
-{
+public final class RKRecord extends Record implements CellValueRecordInterface {
public final static short sid = 0x27e;
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 short field_1_row;
private int field_1_row;
private short field_2_col;
private short field_3_xf_index;
return sid;
}
- public boolean isBefore(CellValueRecordInterface i)
- {
- if (this.getRow() > i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() > i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- if (this.getRow() < i.getRow())
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() < i.getColumn()))
- {
- return false;
- }
- if ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()))
- {
- return false;
- }
- return true;
- }
-
- public boolean isEqual(CellValueRecordInterface i)
- {
- return ((this.getRow() == i.getRow())
- && (this.getColumn() == i.getColumn()));
- }
-
public boolean isInValueSection()
{
return true;
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record.aggregates;
-import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.record.CellValueRecordInterface;
+import org.apache.poi.hssf.record.FormulaRecord;
+import org.apache.poi.hssf.record.StringRecord;
/**
* The formula record aggregate is used to join together the formula record and it's
*
* @author Glen Stampoultzis (glens at apache.org)
*/
-public class FormulaRecordAggregate
- extends Record
- implements CellValueRecordInterface, Comparable
-{
- public final static short sid = -2000;
+public final class FormulaRecordAggregate extends RecordAggregate implements CellValueRecordInterface {
- private FormulaRecord formulaRecord;
- private StringRecord stringRecord;
+ private FormulaRecord _formulaRecord;
+ private StringRecord _stringRecord;
public FormulaRecordAggregate( FormulaRecord formulaRecord, StringRecord stringRecord )
{
- this.formulaRecord = formulaRecord;
- this.stringRecord = stringRecord;
- }
-
- protected void validateSid( short id )
- {
- }
-
- protected void fillFields( RecordInputStream in )
- {
- }
-
- /**
- * 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
- */
-
- public int serialize( int offset, byte[] data )
- {
- int pos = offset;
- pos += formulaRecord.serialize(pos, data);
-
- if (stringRecord != null)
- {
- pos += stringRecord.serialize(pos, data);
- }
- return pos - offset;
-
+ _formulaRecord = formulaRecord;
+ _stringRecord = stringRecord;
}
- /**
- * gives the current serialized size of the record. Should include the sid and reclength (4 bytes).
- */
- public int getRecordSize()
- {
- int size = formulaRecord.getRecordSize() + (stringRecord == null ? 0 : stringRecord.getRecordSize());
- return size;
- }
-
-
- /**
- * return the non static version of the id for this record.
- */
- public short getSid()
- {
- return sid;
- }
-
- public void setStringRecord( StringRecord stringRecord )
- {
- this.stringRecord = stringRecord;
+ public void setStringRecord( StringRecord stringRecord ) {
+ _stringRecord = stringRecord;
}
public void setFormulaRecord( FormulaRecord formulaRecord )
{
- this.formulaRecord = formulaRecord;
+ _formulaRecord = formulaRecord;
}
public FormulaRecord getFormulaRecord()
{
- return formulaRecord;
+ return _formulaRecord;
}
public StringRecord getStringRecord()
{
- return stringRecord;
+ return _stringRecord;
}
- public boolean isEqual(CellValueRecordInterface i)
- {
- return formulaRecord.isEqual( i );
- }
-
- public boolean isAfter(CellValueRecordInterface i)
- {
- return formulaRecord.isAfter( i );
- }
-
- public boolean isBefore(CellValueRecordInterface i)
- {
- return formulaRecord.isBefore( i );
- }
-
public short getXFIndex()
{
- return formulaRecord.getXFIndex();
+ return _formulaRecord.getXFIndex();
}
public void setXFIndex(short xf)
{
- formulaRecord.setXFIndex( xf );
+ _formulaRecord.setXFIndex( xf );
}
public void setColumn(short col)
{
- formulaRecord.setColumn( col );
+ _formulaRecord.setColumn( col );
}
public void setRow(int row)
{
- formulaRecord.setRow( row );
+ _formulaRecord.setRow( row );
}
public short getColumn()
{
- return formulaRecord.getColumn();
+ return _formulaRecord.getColumn();
}
public int getRow()
{
- return formulaRecord.getRow();
+ return _formulaRecord.getRow();
}
- public int compareTo(Object o)
- {
- return formulaRecord.compareTo( o );
+ public String toString() {
+ return _formulaRecord.toString();
}
-
- public boolean equals(Object obj)
- {
- return formulaRecord.equals( obj );
- }
-
- public String toString()
- {
- return formulaRecord.toString();
- }
-
- /**
- * @see java.lang.Object#clone()
- */
- public Object clone() {
- StringRecord clonedString = (stringRecord == null) ? null : (StringRecord)stringRecord.clone();
-
- return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), clonedString);
+
+ public void visitContainedRecords(RecordVisitor rv) {
+ rv.visitRecord(_formulaRecord);
+ if (_stringRecord != null) {
+ rv.visitRecord(_stringRecord);
+ }
}
-
- /*
- * Setting to true so that this value does not abort the whole ValueAggregation
- * (non-Javadoc)
- * @see org.apache.poi.hssf.record.Record#isInValueSection()
- */
- public boolean isInValueSection() {
-
- return true;
- }
- public String getStringValue() {
- if(stringRecord==null) return null;
- return stringRecord.getString();
- }
+ public String getStringValue() {
+ if(_stringRecord==null) {
+ return null;
+ }
+ return _stringRecord.getString();
+ }
}
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.MergeCellsRecord;
import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.RecordBase;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.SharedFormulaRecord;
import org.apache.poi.hssf.record.StringRecord;
if (row > endRow)
break;
if ((row >=startRow) && (row <= endRow))
- size += ((Record)cell).getRecordSize();
+ size += ((RecordBase)cell).getRecordSize();
}
return size;
}
CellValueRecordInterface cell = (CellValueRecordInterface)itr.next();
if (cell.getRow() != row)
break;
- pos += (( Record ) cell).serialize(pos, data);
+ pos += (( RecordBase ) cell).serialize(pos, data);
}
return pos - offset;
}
{
return new MyIterator();
}
-
- /** Performs a deep clone of the record*/
- public Object clone() {
- ValueRecordsAggregate rec = new ValueRecordsAggregate();
- for (Iterator valIter = getIterator(); valIter.hasNext();) {
- CellValueRecordInterface val = (CellValueRecordInterface)((CellValueRecordInterface)valIter.next()).clone();
- rec.insertCell(val);
- }
- return rec;
- }
private final class MyIterator implements Iterator {
short nextColumn=-1;
/**
* used internally -- given a cell value record, figure out its type
*/
- private int determineType(CellValueRecordInterface cval)
- {
+ private static int determineType(CellValueRecordInterface cval) {
+ if (cval instanceof FormulaRecordAggregate) {
+ return HSSFCell.CELL_TYPE_FORMULA;
+ }
+ // all others are plain BIFF records
Record record = ( Record ) cval;
- int sid = record.getSid();
- int retval = 0;
-
- switch (sid)
- {
-
- case NumberRecord.sid :
- retval = HSSFCell.CELL_TYPE_NUMERIC;
- break;
-
- case BlankRecord.sid :
- retval = HSSFCell.CELL_TYPE_BLANK;
- break;
-
- case LabelSSTRecord.sid :
- retval = HSSFCell.CELL_TYPE_STRING;
- break;
-
- case FormulaRecordAggregate.sid :
- retval = HSSFCell.CELL_TYPE_FORMULA;
- break;
+ switch (record.getSid()) {
+ case NumberRecord.sid : return HSSFCell.CELL_TYPE_NUMERIC;
+ case BlankRecord.sid : return HSSFCell.CELL_TYPE_BLANK;
+ case LabelSSTRecord.sid : return HSSFCell.CELL_TYPE_STRING;
case BoolErrRecord.sid :
BoolErrRecord boolErrRecord = ( BoolErrRecord ) record;
- retval = (boolErrRecord.isBoolean())
+ return boolErrRecord.isBoolean()
? HSSFCell.CELL_TYPE_BOOLEAN
: HSSFCell.CELL_TYPE_ERROR;
- break;
}
- return retval;
+ throw new RuntimeException("Bad cell value rec (" + cval.getClass().getName() + ")");
}
/**
*
* @author avik
*/
-public class TestFormulaRecordAggregate extends junit.framework.TestCase {
+public final class TestFormulaRecordAggregate extends junit.framework.TestCase {
- /** Creates a new instance of TestFormulaRecordAggregate */
- public TestFormulaRecordAggregate(String arg) {
- super(arg);
- }
-
- public void testClone() {
+ public void testBasic() throws Exception {
FormulaRecord f = new FormulaRecord();
StringRecord s = new StringRecord();
+ s.setString("abc");
FormulaRecordAggregate fagg = new FormulaRecordAggregate(f,s);
- FormulaRecordAggregate newFagg = (FormulaRecordAggregate) fagg.clone();
- assertTrue("objects are different", fagg!=newFagg);
- assertTrue("deep clone", fagg.getFormulaRecord() != newFagg.getFormulaRecord());
- assertTrue("deep clone", fagg.getStringRecord() != newFagg.getStringRecord());
-
-
+ assertEquals("abc", fagg.getStringValue());
}
-
}
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.BlankRecord;
import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.RecordBase;
import org.apache.poi.hssf.record.SharedFormulaRecord;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
constructValueRecord(records);
Iterator iterator = valueRecord.getIterator();
- Record record = (Record) iterator.next();
+ RecordBase record = (RecordBase) iterator.next();
assertNotNull( "Row contains a value", record );
assertTrue( "First record is a FormulaRecordsAggregate", ( record instanceof FormulaRecordAggregate ) );
//Ensure that the SharedFormulaRecord has been converted