mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-20 04:29:02 +00:00
renamed is()
This commit is contained in:
parent
40db75e96a
commit
cf833ab7d7
@ -117,8 +117,8 @@ class Cell implements Comparable<Cell>, Value
|
|||||||
return justify (repeat, colWidth, format);
|
return justify (repeat, colWidth, format);
|
||||||
|
|
||||||
case VALUE:
|
case VALUE:
|
||||||
if (value.is (ValueType.ERROR) || value.is (ValueType.NA)
|
if (value.isValueType (ValueType.ERROR) || value.isValueType (ValueType.NA)
|
||||||
|| value.is (ValueType.NAN))
|
|| value.isValueType (ValueType.NAN))
|
||||||
return justify (value.getText (), colWidth, format);
|
return justify (value.getText (), colWidth, format);
|
||||||
|
|
||||||
Double thisValue = value.getValue ();
|
Double thisValue = value.getValue ();
|
||||||
@ -173,7 +173,6 @@ class Cell implements Comparable<Cell>, Value
|
|||||||
@Override
|
@Override
|
||||||
public double getValue ()
|
public double getValue ()
|
||||||
{
|
{
|
||||||
assert cellType == CellType.VALUE;
|
|
||||||
return value.getValue ();
|
return value.getValue ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,17 +185,16 @@ class Cell implements Comparable<Cell>, Value
|
|||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
{
|
{
|
||||||
assert is (CellType.VALUE) : "Cell type: " + cellType;
|
|
||||||
return value.getText ();
|
return value.getText ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean is (ValueType type)
|
public boolean isValueType (ValueType type)
|
||||||
{
|
{
|
||||||
return value.is (type);
|
return value.isValueType (type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is (CellType type)
|
public boolean isCellType (CellType type)
|
||||||
{
|
{
|
||||||
return cellType == type;
|
return cellType == type;
|
||||||
}
|
}
|
||||||
@ -204,7 +202,7 @@ class Cell implements Comparable<Cell>, Value
|
|||||||
@Override
|
@Override
|
||||||
public Value calculate ()
|
public Value calculate ()
|
||||||
{
|
{
|
||||||
if (!is (CellType.VALUE))
|
if (!isCellType (CellType.VALUE))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (expressionText == null)
|
if (expressionText == null)
|
||||||
|
@ -56,7 +56,7 @@ class Condition
|
|||||||
valueExpression.calculate ();
|
valueExpression.calculate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conditionExpression.is (ValueType.ERROR) || valueExpression.is (ValueType.ERROR))
|
if (conditionExpression.isValueType (ValueType.ERROR) || valueExpression.isValueType (ValueType.ERROR))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
double conditionResult = conditionExpression.getValue ();
|
double conditionResult = conditionExpression.getValue ();
|
||||||
|
@ -16,10 +16,10 @@ class Count extends RangeFunction
|
|||||||
for (Address address : range)
|
for (Address address : range)
|
||||||
{
|
{
|
||||||
Cell cell = parent.getCell (address);
|
Cell cell = parent.getCell (address);
|
||||||
if (cell == null || cell.is (ValueType.NA))
|
if (cell == null || cell.isValueType (ValueType.NA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cell.is (ValueType.ERROR))
|
if (cell.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = ValueType.ERROR;
|
valueType = ValueType.ERROR;
|
||||||
break;
|
break;
|
||||||
|
@ -127,13 +127,13 @@ class Expression implements Value
|
|||||||
{
|
{
|
||||||
Value thisValue = values.get (0);
|
Value thisValue = values.get (0);
|
||||||
thisValue.calculate ();
|
thisValue.calculate ();
|
||||||
if (thisValue.is (ValueType.ERROR))
|
if (thisValue.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = thisValue.getValueType ();
|
valueType = thisValue.getValueType ();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = thisValue.is (ValueType.NA) ? 0 : thisValue.getValue ();
|
value = thisValue.isValueType (ValueType.NA) ? 0 : thisValue.getValue ();
|
||||||
|
|
||||||
String sign = signs.get (0);
|
String sign = signs.get (0);
|
||||||
if (sign.equals ("(-)"))
|
if (sign.equals ("(-)"))
|
||||||
@ -143,13 +143,13 @@ class Expression implements Value
|
|||||||
{
|
{
|
||||||
thisValue = values.get (i);
|
thisValue = values.get (i);
|
||||||
thisValue.calculate ();
|
thisValue.calculate ();
|
||||||
if (thisValue.is (ValueType.ERROR))
|
if (thisValue.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = thisValue.getValueType ();
|
valueType = thisValue.getValueType ();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
double nextValue = thisValue.is (ValueType.NA) ? 0 : thisValue.getValue ();
|
double nextValue = thisValue.isValueType (ValueType.NA) ? 0 : thisValue.getValue ();
|
||||||
|
|
||||||
sign = signs.get (i);
|
sign = signs.get (i);
|
||||||
if (sign.equals ("(-)"))
|
if (sign.equals ("(-)"))
|
||||||
@ -211,7 +211,7 @@ class Expression implements Value
|
|||||||
// return valueType == ValueType.ERROR;
|
// return valueType == ValueType.ERROR;
|
||||||
// }
|
// }
|
||||||
@Override
|
@Override
|
||||||
public boolean is (ValueType type)
|
public boolean isValueType (ValueType type)
|
||||||
{
|
{
|
||||||
return valueType == type;
|
return valueType == type;
|
||||||
}
|
}
|
||||||
|
@ -114,32 +114,8 @@ abstract class Function implements Value
|
|||||||
return valueType;
|
return valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean isValue ()
|
|
||||||
// {
|
|
||||||
// return valueType == ValueType.VALUE;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isError ()
|
|
||||||
// {
|
|
||||||
// return valueType == ValueType.ERROR;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isNotAvailable ()
|
|
||||||
// {
|
|
||||||
// return valueType == ValueType.NA;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean isNotANumber ()
|
|
||||||
// {
|
|
||||||
// return valueType == ValueType.NAN;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean is (ValueType type)
|
public boolean isValueType (ValueType type)
|
||||||
{
|
{
|
||||||
return valueType == type;
|
return valueType == type;
|
||||||
}
|
}
|
||||||
@ -165,7 +141,6 @@ abstract class Function implements Value
|
|||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
// return isNotAvailable () ? "NA" : isError () ? "Error" : isNotANumber () ? "NaN" : "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ class If extends Function
|
|||||||
|
|
||||||
expTrue.calculate ();
|
expTrue.calculate ();
|
||||||
|
|
||||||
if (expTrue.is (ValueType.ERROR) || expTrue.is (ValueType.NA))
|
if (expTrue.isValueType (ValueType.ERROR) || expTrue.isValueType (ValueType.NA))
|
||||||
valueType = expTrue.getValueType ();
|
valueType = expTrue.getValueType ();
|
||||||
else
|
else
|
||||||
value = expTrue.getValue ();
|
value = expTrue.getValue ();
|
||||||
@ -49,7 +49,7 @@ class If extends Function
|
|||||||
|
|
||||||
expFalse.calculate ();
|
expFalse.calculate ();
|
||||||
|
|
||||||
if (expFalse.is (ValueType.ERROR) || expFalse.is (ValueType.NA))
|
if (expFalse.isValueType (ValueType.ERROR) || expFalse.isValueType (ValueType.NA))
|
||||||
valueType = expFalse.getValueType ();
|
valueType = expFalse.getValueType ();
|
||||||
else
|
else
|
||||||
value = expFalse.getValue ();
|
value = expFalse.getValue ();
|
||||||
|
@ -22,15 +22,15 @@ class Lookup extends RangeFunction
|
|||||||
source = new Expression (parent, sourceText);
|
source = new Expression (parent, sourceText);
|
||||||
|
|
||||||
source.calculate ();
|
source.calculate ();
|
||||||
if (source.is (ValueType.ERROR) || source.is (ValueType.NA))
|
if (!source.isValueType (ValueType.VALUE))
|
||||||
{
|
{
|
||||||
valueType = source.getValueType ();
|
valueType = source.getValueType ();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
double sourceValue = source.getValue ();
|
double sourceValue = source.getValue ();
|
||||||
|
|
||||||
Address target = null;
|
Address target = null;
|
||||||
|
|
||||||
for (Address address : range)
|
for (Address address : range)
|
||||||
{
|
{
|
||||||
Cell cell = parent.getCell (address);
|
Cell cell = parent.getCell (address);
|
||||||
|
@ -16,10 +16,10 @@ class Max extends RangeFunction
|
|||||||
for (Address address : range)
|
for (Address address : range)
|
||||||
{
|
{
|
||||||
Cell cell = parent.getCell (address);
|
Cell cell = parent.getCell (address);
|
||||||
if (cell == null || cell.is (ValueType.NA))
|
if (cell == null || cell.isValueType (ValueType.NA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cell.is (ValueType.ERROR))
|
if (cell.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = ValueType.ERROR;
|
valueType = ValueType.ERROR;
|
||||||
break;
|
break;
|
||||||
|
@ -16,10 +16,10 @@ class Min extends RangeFunction
|
|||||||
for (Address address : range)
|
for (Address address : range)
|
||||||
{
|
{
|
||||||
Cell cell = parent.getCell (address);
|
Cell cell = parent.getCell (address);
|
||||||
if (cell == null || cell.is (ValueType.NA))
|
if (cell == null || cell.isValueType (ValueType.NA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cell.is (ValueType.ERROR))
|
if (cell.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = ValueType.ERROR;
|
valueType = ValueType.ERROR;
|
||||||
break;
|
break;
|
||||||
|
@ -27,10 +27,10 @@ public class Npv extends RangeFunction
|
|||||||
for (Address address : range)
|
for (Address address : range)
|
||||||
{
|
{
|
||||||
Cell cell = parent.getCell (address);
|
Cell cell = parent.getCell (address);
|
||||||
if (cell == null || cell.is (ValueType.NA))
|
if (cell == null || cell.isValueType (ValueType.NA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cell.is (ValueType.ERROR))
|
if (cell.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = ValueType.ERROR;
|
valueType = ValueType.ERROR;
|
||||||
break;
|
break;
|
||||||
|
@ -42,7 +42,7 @@ class Number implements Value
|
|||||||
// return valueType == ValueType.NAN;
|
// return valueType == ValueType.NAN;
|
||||||
// }
|
// }
|
||||||
@Override
|
@Override
|
||||||
public boolean is (ValueType type)
|
public boolean isValueType (ValueType type)
|
||||||
{
|
{
|
||||||
return valueType == type;
|
return valueType == type;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class Sheet
|
|||||||
{
|
{
|
||||||
Map<Integer, Cell> cells = order == 'R' ? rowOrderCells : columnOrderCells;
|
Map<Integer, Cell> cells = order == 'R' ? rowOrderCells : columnOrderCells;
|
||||||
for (Cell cell : cells.values ())
|
for (Cell cell : cells.values ())
|
||||||
if (cell.is (ValueType.VALUE))
|
if (cell.isValueType (ValueType.VALUE))
|
||||||
cell.calculate ();
|
cell.calculate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@ class Sum extends RangeFunction
|
|||||||
for (Address address : range)
|
for (Address address : range)
|
||||||
{
|
{
|
||||||
Cell cell = parent.getCell (address);
|
Cell cell = parent.getCell (address);
|
||||||
if (cell == null || cell.is (ValueType.NA))
|
if (cell == null || cell.isValueType (ValueType.NA))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cell.is (ValueType.ERROR))
|
if (cell.isValueType (ValueType.ERROR))
|
||||||
{
|
{
|
||||||
valueType = ValueType.ERROR;
|
valueType = ValueType.ERROR;
|
||||||
break;
|
break;
|
||||||
|
@ -7,20 +7,13 @@ interface Value
|
|||||||
VALUE, ERROR, NA, NAN
|
VALUE, ERROR, NA, NAN
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueType getValueType ();
|
|
||||||
|
|
||||||
public double getValue ();
|
public double getValue ();
|
||||||
|
|
||||||
public String getText ();
|
public String getText ();
|
||||||
|
|
||||||
// public boolean isValue ();
|
public boolean isValueType (ValueType valueType);
|
||||||
//
|
|
||||||
// public boolean isError ();
|
public ValueType getValueType ();
|
||||||
//
|
|
||||||
// public boolean isNotAvailable ();
|
|
||||||
//
|
|
||||||
// public boolean isNotANumber ();
|
|
||||||
public boolean is (ValueType valueType);
|
|
||||||
|
|
||||||
public Value calculate ();
|
public Value calculate ();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user