From cf833ab7d7a8fb8f6afc2dbc8ae855535bc596a2 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Mon, 1 Aug 2016 15:18:51 +1000 Subject: [PATCH] renamed is() --- .../bytezone/diskbrowser/visicalc/Cell.java | 14 +++++----- .../diskbrowser/visicalc/Condition.java | 2 +- .../bytezone/diskbrowser/visicalc/Count.java | 4 +-- .../diskbrowser/visicalc/Expression.java | 10 +++---- .../diskbrowser/visicalc/Function.java | 27 +------------------ src/com/bytezone/diskbrowser/visicalc/If.java | 4 +-- .../bytezone/diskbrowser/visicalc/Lookup.java | 4 +-- .../bytezone/diskbrowser/visicalc/Max.java | 4 +-- .../bytezone/diskbrowser/visicalc/Min.java | 4 +-- .../bytezone/diskbrowser/visicalc/Npv.java | 4 +-- .../bytezone/diskbrowser/visicalc/Number.java | 2 +- .../bytezone/diskbrowser/visicalc/Sheet.java | 2 +- .../bytezone/diskbrowser/visicalc/Sum.java | 4 +-- .../bytezone/diskbrowser/visicalc/Value.java | 13 +++------ 14 files changed, 32 insertions(+), 66 deletions(-) diff --git a/src/com/bytezone/diskbrowser/visicalc/Cell.java b/src/com/bytezone/diskbrowser/visicalc/Cell.java index 9016c80..e24f57b 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Cell.java +++ b/src/com/bytezone/diskbrowser/visicalc/Cell.java @@ -117,8 +117,8 @@ class Cell implements Comparable, Value return justify (repeat, colWidth, format); case VALUE: - if (value.is (ValueType.ERROR) || value.is (ValueType.NA) - || value.is (ValueType.NAN)) + if (value.isValueType (ValueType.ERROR) || value.isValueType (ValueType.NA) + || value.isValueType (ValueType.NAN)) return justify (value.getText (), colWidth, format); Double thisValue = value.getValue (); @@ -173,7 +173,6 @@ class Cell implements Comparable, Value @Override public double getValue () { - assert cellType == CellType.VALUE; return value.getValue (); } @@ -186,17 +185,16 @@ class Cell implements Comparable, Value @Override public String getText () { - assert is (CellType.VALUE) : "Cell type: " + cellType; return value.getText (); } @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; } @@ -204,7 +202,7 @@ class Cell implements Comparable, Value @Override public Value calculate () { - if (!is (CellType.VALUE)) + if (!isCellType (CellType.VALUE)) return this; if (expressionText == null) diff --git a/src/com/bytezone/diskbrowser/visicalc/Condition.java b/src/com/bytezone/diskbrowser/visicalc/Condition.java index f579c39..f9b1d1b 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Condition.java +++ b/src/com/bytezone/diskbrowser/visicalc/Condition.java @@ -56,7 +56,7 @@ class Condition valueExpression.calculate (); } - if (conditionExpression.is (ValueType.ERROR) || valueExpression.is (ValueType.ERROR)) + if (conditionExpression.isValueType (ValueType.ERROR) || valueExpression.isValueType (ValueType.ERROR)) return false; double conditionResult = conditionExpression.getValue (); diff --git a/src/com/bytezone/diskbrowser/visicalc/Count.java b/src/com/bytezone/diskbrowser/visicalc/Count.java index 8dab7fb..bd00cb6 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Count.java +++ b/src/com/bytezone/diskbrowser/visicalc/Count.java @@ -16,10 +16,10 @@ class Count extends RangeFunction for (Address address : range) { Cell cell = parent.getCell (address); - if (cell == null || cell.is (ValueType.NA)) + if (cell == null || cell.isValueType (ValueType.NA)) continue; - if (cell.is (ValueType.ERROR)) + if (cell.isValueType (ValueType.ERROR)) { valueType = ValueType.ERROR; break; diff --git a/src/com/bytezone/diskbrowser/visicalc/Expression.java b/src/com/bytezone/diskbrowser/visicalc/Expression.java index 3de1362..12bff07 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Expression.java +++ b/src/com/bytezone/diskbrowser/visicalc/Expression.java @@ -127,13 +127,13 @@ class Expression implements Value { Value thisValue = values.get (0); thisValue.calculate (); - if (thisValue.is (ValueType.ERROR)) + if (thisValue.isValueType (ValueType.ERROR)) { valueType = thisValue.getValueType (); return this; } - value = thisValue.is (ValueType.NA) ? 0 : thisValue.getValue (); + value = thisValue.isValueType (ValueType.NA) ? 0 : thisValue.getValue (); String sign = signs.get (0); if (sign.equals ("(-)")) @@ -143,13 +143,13 @@ class Expression implements Value { thisValue = values.get (i); thisValue.calculate (); - if (thisValue.is (ValueType.ERROR)) + if (thisValue.isValueType (ValueType.ERROR)) { valueType = thisValue.getValueType (); return this; } - double nextValue = thisValue.is (ValueType.NA) ? 0 : thisValue.getValue (); + double nextValue = thisValue.isValueType (ValueType.NA) ? 0 : thisValue.getValue (); sign = signs.get (i); if (sign.equals ("(-)")) @@ -211,7 +211,7 @@ class Expression implements Value // return valueType == ValueType.ERROR; // } @Override - public boolean is (ValueType type) + public boolean isValueType (ValueType type) { return valueType == type; } diff --git a/src/com/bytezone/diskbrowser/visicalc/Function.java b/src/com/bytezone/diskbrowser/visicalc/Function.java index b9b3f5d..9daf474 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Function.java +++ b/src/com/bytezone/diskbrowser/visicalc/Function.java @@ -114,32 +114,8 @@ abstract class Function implements Value 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 - public boolean is (ValueType type) + public boolean isValueType (ValueType type) { return valueType == type; } @@ -165,7 +141,6 @@ abstract class Function implements Value default: return ""; } - // return isNotAvailable () ? "NA" : isError () ? "Error" : isNotANumber () ? "NaN" : ""; } @Override diff --git a/src/com/bytezone/diskbrowser/visicalc/If.java b/src/com/bytezone/diskbrowser/visicalc/If.java index f1dd9e3..a39eb94 100644 --- a/src/com/bytezone/diskbrowser/visicalc/If.java +++ b/src/com/bytezone/diskbrowser/visicalc/If.java @@ -36,7 +36,7 @@ class If extends Function expTrue.calculate (); - if (expTrue.is (ValueType.ERROR) || expTrue.is (ValueType.NA)) + if (expTrue.isValueType (ValueType.ERROR) || expTrue.isValueType (ValueType.NA)) valueType = expTrue.getValueType (); else value = expTrue.getValue (); @@ -49,7 +49,7 @@ class If extends Function expFalse.calculate (); - if (expFalse.is (ValueType.ERROR) || expFalse.is (ValueType.NA)) + if (expFalse.isValueType (ValueType.ERROR) || expFalse.isValueType (ValueType.NA)) valueType = expFalse.getValueType (); else value = expFalse.getValue (); diff --git a/src/com/bytezone/diskbrowser/visicalc/Lookup.java b/src/com/bytezone/diskbrowser/visicalc/Lookup.java index 438d7df..03b9e27 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Lookup.java +++ b/src/com/bytezone/diskbrowser/visicalc/Lookup.java @@ -22,15 +22,15 @@ class Lookup extends RangeFunction source = new Expression (parent, sourceText); source.calculate (); - if (source.is (ValueType.ERROR) || source.is (ValueType.NA)) + if (!source.isValueType (ValueType.VALUE)) { valueType = source.getValueType (); return this; } double sourceValue = source.getValue (); - Address target = null; + for (Address address : range) { Cell cell = parent.getCell (address); diff --git a/src/com/bytezone/diskbrowser/visicalc/Max.java b/src/com/bytezone/diskbrowser/visicalc/Max.java index 73316a5..a3b93db 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Max.java +++ b/src/com/bytezone/diskbrowser/visicalc/Max.java @@ -16,10 +16,10 @@ class Max extends RangeFunction for (Address address : range) { Cell cell = parent.getCell (address); - if (cell == null || cell.is (ValueType.NA)) + if (cell == null || cell.isValueType (ValueType.NA)) continue; - if (cell.is (ValueType.ERROR)) + if (cell.isValueType (ValueType.ERROR)) { valueType = ValueType.ERROR; break; diff --git a/src/com/bytezone/diskbrowser/visicalc/Min.java b/src/com/bytezone/diskbrowser/visicalc/Min.java index 51327b0..18f1d09 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Min.java +++ b/src/com/bytezone/diskbrowser/visicalc/Min.java @@ -16,10 +16,10 @@ class Min extends RangeFunction for (Address address : range) { Cell cell = parent.getCell (address); - if (cell == null || cell.is (ValueType.NA)) + if (cell == null || cell.isValueType (ValueType.NA)) continue; - if (cell.is (ValueType.ERROR)) + if (cell.isValueType (ValueType.ERROR)) { valueType = ValueType.ERROR; break; diff --git a/src/com/bytezone/diskbrowser/visicalc/Npv.java b/src/com/bytezone/diskbrowser/visicalc/Npv.java index 8a43408..03fdf5e 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Npv.java +++ b/src/com/bytezone/diskbrowser/visicalc/Npv.java @@ -27,10 +27,10 @@ public class Npv extends RangeFunction for (Address address : range) { Cell cell = parent.getCell (address); - if (cell == null || cell.is (ValueType.NA)) + if (cell == null || cell.isValueType (ValueType.NA)) continue; - if (cell.is (ValueType.ERROR)) + if (cell.isValueType (ValueType.ERROR)) { valueType = ValueType.ERROR; break; diff --git a/src/com/bytezone/diskbrowser/visicalc/Number.java b/src/com/bytezone/diskbrowser/visicalc/Number.java index e87c1fe..e4082d4 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Number.java +++ b/src/com/bytezone/diskbrowser/visicalc/Number.java @@ -42,7 +42,7 @@ class Number implements Value // return valueType == ValueType.NAN; // } @Override - public boolean is (ValueType type) + public boolean isValueType (ValueType type) { return valueType == type; } diff --git a/src/com/bytezone/diskbrowser/visicalc/Sheet.java b/src/com/bytezone/diskbrowser/visicalc/Sheet.java index 537f597..4e38e62 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sheet.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sheet.java @@ -164,7 +164,7 @@ public class Sheet { Map cells = order == 'R' ? rowOrderCells : columnOrderCells; for (Cell cell : cells.values ()) - if (cell.is (ValueType.VALUE)) + if (cell.isValueType (ValueType.VALUE)) cell.calculate (); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Sum.java b/src/com/bytezone/diskbrowser/visicalc/Sum.java index 073781e..dd6ff90 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sum.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sum.java @@ -16,10 +16,10 @@ class Sum extends RangeFunction for (Address address : range) { Cell cell = parent.getCell (address); - if (cell == null || cell.is (ValueType.NA)) + if (cell == null || cell.isValueType (ValueType.NA)) continue; - if (cell.is (ValueType.ERROR)) + if (cell.isValueType (ValueType.ERROR)) { valueType = ValueType.ERROR; break; diff --git a/src/com/bytezone/diskbrowser/visicalc/Value.java b/src/com/bytezone/diskbrowser/visicalc/Value.java index 88fa306..eb8e441 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Value.java +++ b/src/com/bytezone/diskbrowser/visicalc/Value.java @@ -7,20 +7,13 @@ interface Value VALUE, ERROR, NA, NAN } - public ValueType getValueType (); - public double getValue (); public String getText (); - // public boolean isValue (); - // - // public boolean isError (); - // - // public boolean isNotAvailable (); - // - // public boolean isNotANumber (); - public boolean is (ValueType valueType); + public boolean isValueType (ValueType valueType); + + public ValueType getValueType (); public Value calculate (); } \ No newline at end of file