dmolony-DiskBrowser/src/com/bytezone/diskbrowser/appleworks/CellConstant.java

44 lines
1.3 KiB
Java
Raw Normal View History

2015-06-01 09:35:51 +00:00
package com.bytezone.diskbrowser.appleworks;
2016-02-24 21:11:14 +00:00
import com.bytezone.diskbrowser.utilities.HexFormatter;
2015-06-01 09:35:51 +00:00
2020-02-08 07:50:03 +00:00
// -----------------------------------------------------------------------------------//
class CellConstant extends Cell
// -----------------------------------------------------------------------------------//
2015-06-01 09:35:51 +00:00
{
double saneDouble;
CellFormat format;
2020-02-08 07:50:03 +00:00
// ---------------------------------------------------------------------------------//
CellConstant (byte[] buffer, int row, int column, int offset, int length)
// ---------------------------------------------------------------------------------//
2015-06-01 09:35:51 +00:00
{
super (row, column, offset, length);
type = "Const";
// assert length == 10;
if (length != 10)
{
System.out.println ("Spreadsheet CellConstant with length != 10");
System.out.printf ("Row %d, Col %d, Length %d %n", row, column, length);
System.out.println (HexFormatter.format (buffer, offset, length));
type = "*** Invalid Constant ***";
value = "";
}
else
{
long bits = 0;
for (int i = 9; i >= 2; i--)
{
bits <<= 8;
bits |= buffer[offset + i] & 0xFF;
}
saneDouble = Double.longBitsToDouble (bits);
format = new CellFormat (buffer[offset], buffer[offset + 1]);
value = String.format (format.mask (), saneDouble).trim ();
}
}
}