| Method from org.apache.poi.hssf.record.RKRecord Detail: |
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;
rec.field_4_rk_number = field_4_rk_number;
return rec;
}
|
protected void fillFields(RecordInputStream in) {
//field_1_row = LittleEndian.getShort(data, 0 + offset);
field_1_row = in.readUShort();
field_2_col = in.readShort();
field_3_xf_index = in.readShort();
field_4_rk_number = in.readInt();
}
|
public short getColumn() {
return field_2_col;
}
|
public int getRKField() {
return field_4_rk_number;
}
|
public double getRKNumber() {
return RKUtil.decodeNumber(field_4_rk_number);
}
Extract the value of the number
The mechanism for determining the value is dependent on the two
low order bits of the raw number. If bit 1 is set, the number
is an integer and can be cast directly as a double, otherwise,
it's apparently the exponent and mantissa of a double (and the
remaining low-order bits of the double's mantissa are 0's).
If bit 0 is set, the result of the conversion to a double is
divided by 100; otherwise, the value is left alone.
[insert picture of Screwy Squirrel in full Napoleonic regalia] |
public short getRKType() {
return ( short ) (field_4_rk_number & 3);
}
Get the type of the number |
public int getRow() {
return field_1_row;
}
|
public short getSid() {
return sid;
}
|
public short getXFIndex() {
return field_3_xf_index;
}
|
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 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 isEqual(CellValueRecordInterface i) {
return ((this.getRow() == i.getRow())
&& (this.getColumn() == i.getColumn()));
}
|
public boolean isInValueSection() {
return true;
}
|
public boolean isValue() {
return true;
}
|
public static void main(String[] ignored_args) {
int[] values =
{
0x3FF00000, 0x405EC001, 0x02F1853A, 0x02F1853B, 0xFCDD699A
};
double[] rvalues =
{
1, 1.23, 12345678, 123456.78, -13149594
};
for (int j = 0; j < values.length; j++)
{
System.out.println("input = " + Integer.toHexString(values[ j ])
+ " - > " + rvalues[ j ] + ": "
+ RKUtil.decodeNumber(values[ j ]));
}
}
Debugging main()
Normally I'd do this in a junit test, but let's face it -- once
this algorithm has been tested and it works, we are never ever
going to change it. This is driven by the Faceless Enemy's
minions, who dare not change the algorithm out from under us. |
public int serialize(int offset,
byte[] data) {
NumberRecord rec = new NumberRecord();
rec.setColumn(getColumn());
rec.setRow(getRow());
rec.setValue(getRKNumber());
rec.setXFIndex(getXFIndex());
return rec.serialize(offset, data);
}
|
public void setColumn(short col) {
}
|
public void setRow(int row) {
}
|
public void setXFIndex(short xf) {
}
|
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[RK]\n");
buffer.append(" .row = ")
.append(Integer.toHexString(getRow())).append("\n");
buffer.append(" .col = ")
.append(Integer.toHexString(getColumn())).append("\n");
buffer.append(" .xfindex = ")
.append(Integer.toHexString(getXFIndex())).append("\n");
buffer.append(" .rknumber = ")
.append(Integer.toHexString(getRKField())).append("\n");
buffer.append(" .rktype = ")
.append(Integer.toHexString(getRKType())).append("\n");
buffer.append(" .rknumber = ").append(getRKNumber())
.append("\n");
buffer.append("[/RK]\n");
return buffer.toString();
}
|
protected void validateSid(short id) {
if (id != sid)
{
throw new RecordFormatException("NOT A valid RK RECORD");
}
}
|