This commit is contained in:
Denis Molony 2016-08-01 11:50:43 +10:00
parent 82d8201180
commit 40db75e96a

View File

@ -13,12 +13,10 @@ class Cell implements Comparable<Cell>, Value
private char repeatingChar;
private String repeat = "";
private String label;
private String expressionText;
private Value value;
private ValueType valueType;
enum CellType
{
@ -31,7 +29,7 @@ class Cell implements Comparable<Cell>, Value
this.address = address;
cellType = CellType.VALUE; // default to VALUE, formatting may change it
valueType = ValueType.VALUE;
value = new Number ("0.0");
}
void format (String format)
@ -182,7 +180,7 @@ class Cell implements Comparable<Cell>, Value
@Override
public ValueType getValueType ()
{
return valueType;
return value.getValueType ();
}
@Override
@ -192,36 +190,10 @@ class Cell implements Comparable<Cell>, Value
return value.getText ();
}
// @Override
// public boolean isValue ()
// {
// return type == CellType.VALUE;
// }
//
// @Override
// public boolean isError ()
// {
// return value.isError ();
// }
//
// @Override
// public boolean isNotAvailable ()
// {
// if (!isValue ())
// return true;
// return value.isNotAvailable ();
// }
//
// @Override
// public boolean isNotANumber ()
// {
// return value.isNotANumber ();
// }
@Override
public boolean is (ValueType type)
{
return valueType == type;
return value.is (type);
}
public boolean is (CellType type)
@ -233,23 +205,18 @@ class Cell implements Comparable<Cell>, Value
public Value calculate ()
{
if (!is (CellType.VALUE))
{
// System.out.println (value);
return this;
}
assert is (CellType.VALUE) : "Cell type: " + cellType + " @ " + address;
if (expressionText == null)
{
System.out.printf ("%s null expression text %n", address);
value = Function.getInstance (parent, "@ERROR");
valueType = ValueType.ERROR;
}
else
{
// should use Number or Cell or Function for simple Values
value = new Expression (parent, expressionText);
value.calculate ();
valueType = value.getValueType ();
}
return this;
}