From 846c975be6e4d72d12f4d91260fd7e5a476e6fa2 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Mon, 10 Feb 2020 21:05:40 +1000 Subject: [PATCH] method header lines --- .../bytezone/diskbrowser/visicalc/Abs.java | 6 ++ .../diskbrowser/visicalc/AbstractValue.java | 32 ++++++++- .../bytezone/diskbrowser/visicalc/Acos.java | 8 ++- .../diskbrowser/visicalc/Address.java | 38 +++++++++++ .../bytezone/diskbrowser/visicalc/And.java | 8 ++- .../bytezone/diskbrowser/visicalc/Asin.java | 8 ++- .../bytezone/diskbrowser/visicalc/Atan.java | 8 ++- .../diskbrowser/visicalc/Average.java | 10 ++- .../diskbrowser/visicalc/BooleanFunction.java | 8 ++- .../bytezone/diskbrowser/visicalc/Cell.java | 68 +++++++++++++++++-- .../bytezone/diskbrowser/visicalc/Choose.java | 8 ++- .../diskbrowser/visicalc/Condition.java | 18 ++++- .../diskbrowser/visicalc/ConditionList.java | 14 +++- .../visicalc/ConditionListFunction.java | 8 ++- .../visicalc/ConstantFunction.java | 10 ++- .../bytezone/diskbrowser/visicalc/Cos.java | 8 ++- .../bytezone/diskbrowser/visicalc/Count.java | 8 ++- .../bytezone/diskbrowser/visicalc/Error.java | 6 +- .../bytezone/diskbrowser/visicalc/Exp.java | 8 ++- .../diskbrowser/visicalc/Expression.java | 30 +++++++- .../bytezone/diskbrowser/visicalc/False.java | 6 +- .../bytezone/diskbrowser/visicalc/Format.java | 10 ++- .../diskbrowser/visicalc/Function.java | 6 ++ src/com/bytezone/diskbrowser/visicalc/If.java | 12 +++- .../bytezone/diskbrowser/visicalc/Int.java | 8 ++- .../diskbrowser/visicalc/IsError.java | 8 ++- .../bytezone/diskbrowser/visicalc/IsNa.java | 8 ++- src/com/bytezone/diskbrowser/visicalc/Ln.java | 8 ++- .../bytezone/diskbrowser/visicalc/Log10.java | 8 ++- .../bytezone/diskbrowser/visicalc/Lookup.java | 10 ++- .../bytezone/diskbrowser/visicalc/Max.java | 8 ++- .../bytezone/diskbrowser/visicalc/Min.java | 8 ++- src/com/bytezone/diskbrowser/visicalc/Na.java | 8 ++- .../bytezone/diskbrowser/visicalc/Not.java | 8 ++- .../bytezone/diskbrowser/visicalc/Npv.java | 8 ++- .../bytezone/diskbrowser/visicalc/Number.java | 10 ++- src/com/bytezone/diskbrowser/visicalc/Or.java | 8 ++- src/com/bytezone/diskbrowser/visicalc/Pi.java | 4 ++ .../bytezone/diskbrowser/visicalc/Range.java | 22 +++++- .../bytezone/diskbrowser/visicalc/Sheet.java | 28 ++++++++ .../bytezone/diskbrowser/visicalc/Sin.java | 8 ++- .../bytezone/diskbrowser/visicalc/Sqrt.java | 8 ++- .../bytezone/diskbrowser/visicalc/Sum.java | 8 ++- .../bytezone/diskbrowser/visicalc/Tan.java | 8 ++- .../bytezone/diskbrowser/visicalc/True.java | 6 +- .../bytezone/diskbrowser/visicalc/Value.java | 2 + .../diskbrowser/visicalc/ValueFunction.java | 10 ++- .../diskbrowser/visicalc/ValueList.java | 16 ++++- .../visicalc/ValueListFunction.java | 10 ++- 49 files changed, 528 insertions(+), 56 deletions(-) diff --git a/src/com/bytezone/diskbrowser/visicalc/Abs.java b/src/com/bytezone/diskbrowser/visicalc/Abs.java index a544f40..b5d5f4c 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Abs.java +++ b/src/com/bytezone/diskbrowser/visicalc/Abs.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// public class Abs extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Abs (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@ABS(") : text; } + // ---------------------------------------------------------------------------------// @Override double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.abs (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/AbstractValue.java b/src/com/bytezone/diskbrowser/visicalc/AbstractValue.java index 2e4c21d..9ba6d36 100644 --- a/src/com/bytezone/diskbrowser/visicalc/AbstractValue.java +++ b/src/com/bytezone/diskbrowser/visicalc/AbstractValue.java @@ -4,7 +4,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public abstract class AbstractValue implements Value +// -----------------------------------------------------------------------------------// +abstract class AbstractValue implements Value +// -----------------------------------------------------------------------------------// { protected static final String FMT2 = "| %-9.9s : %-70.70s|%n"; protected static final String FMT4 = "| %-9.9s : %-50.50s %-8.8s %-10.10s|%n"; @@ -22,69 +24,91 @@ public abstract class AbstractValue implements Value protected ValueResult valueResult = ValueResult.VALID; protected List values = new ArrayList<> (); - public AbstractValue (Cell cell, String text) + // ---------------------------------------------------------------------------------// + AbstractValue (Cell cell, String text) + // ---------------------------------------------------------------------------------// { this.cell = cell; this.fullText = text; } + // ---------------------------------------------------------------------------------// @Override public String getFullText () + // ---------------------------------------------------------------------------------// { return fullText; } + // ---------------------------------------------------------------------------------// @Override public ValueType getValueType () + // ---------------------------------------------------------------------------------// { return valueType; } + // ---------------------------------------------------------------------------------// @Override public ValueResult getValueResult () + // ---------------------------------------------------------------------------------// { return valueResult; } + // ---------------------------------------------------------------------------------// @Override public boolean isValid () + // ---------------------------------------------------------------------------------// { return valueResult == ValueResult.VALID; } + // ---------------------------------------------------------------------------------// @Override public double getDouble () + // ---------------------------------------------------------------------------------// { assert valueType == ValueType.NUMBER; return value; } + // ---------------------------------------------------------------------------------// @Override public boolean getBoolean () + // ---------------------------------------------------------------------------------// { assert valueType == ValueType.BOOLEAN; return bool; } + // ---------------------------------------------------------------------------------// @Override public int size () + // ---------------------------------------------------------------------------------// { return values.size (); } + // ---------------------------------------------------------------------------------// @Override public String getText () + // ---------------------------------------------------------------------------------// { return valueResult == ValueResult.VALID ? getValueText (this) : valueResult + ""; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { // System.out.println ("calculate not overridden: " + cell); } + // ---------------------------------------------------------------------------------// protected void attach (StringBuilder text, String title, String textValue, Value value) + // ---------------------------------------------------------------------------------// { text.append (String.format (FMT4, title, textValue, value.getValueType (), getValueText (value))); @@ -92,7 +116,9 @@ public abstract class AbstractValue implements Value text.append (v); } + // ---------------------------------------------------------------------------------// protected String getValueText (Value value) + // ---------------------------------------------------------------------------------// { if (value.getValueType () == ValueType.NUMBER) return value.getDouble () + ""; @@ -101,8 +127,10 @@ public abstract class AbstractValue implements Value return "??*??"; } + // ---------------------------------------------------------------------------------// @Override public Iterator iterator () + // ---------------------------------------------------------------------------------// { return values.iterator (); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Acos.java b/src/com/bytezone/diskbrowser/visicalc/Acos.java index 36b5073..57b3976 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Acos.java +++ b/src/com/bytezone/diskbrowser/visicalc/Acos.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Acos extends ValueFunction +// -----------------------------------------------------------------------------------// +class Acos extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Acos (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@ACOS(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.acos (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Address.java b/src/com/bytezone/diskbrowser/visicalc/Address.java index 4e618ae..69549d4 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Address.java +++ b/src/com/bytezone/diskbrowser/visicalc/Address.java @@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc; import java.util.Arrays; +// -----------------------------------------------------------------------------------// class Address implements Comparable
+// -----------------------------------------------------------------------------------// { private static final int MAX_ROWS = 255; private static final int MAX_COLUMNS = 64; @@ -12,12 +14,16 @@ class Address implements Comparable
private int columnKey; private String text; + // ---------------------------------------------------------------------------------// public Address (String column, String row) + // ---------------------------------------------------------------------------------// { set (column, row); } + // ---------------------------------------------------------------------------------// public Address (int column, int row) + // ---------------------------------------------------------------------------------// { assert column <= MAX_COLUMNS; assert row <= MAX_ROWS; @@ -34,7 +40,9 @@ class Address implements Comparable
text = col + (row + 1); } + // ---------------------------------------------------------------------------------// public Address (String address) + // ---------------------------------------------------------------------------------// { assert address.length () >= 2; if (address.charAt (1) < 'A') @@ -43,13 +51,17 @@ class Address implements Comparable
set (address.substring (0, 2), address.substring (2)); } + // ---------------------------------------------------------------------------------// public boolean matches (String addressText) + // ---------------------------------------------------------------------------------// { Address address = new Address (addressText); return this.rowMatches (address) && this.columnMatches (address); } + // ---------------------------------------------------------------------------------// private void set (String sCol, String sRow) + // ---------------------------------------------------------------------------------// { if (sCol.length () == 1) column = sCol.charAt (0) - 'A'; @@ -73,75 +85,101 @@ class Address implements Comparable
} } + // ---------------------------------------------------------------------------------// boolean rowMatches (Address other) + // ---------------------------------------------------------------------------------// { return row == other.row; } + // ---------------------------------------------------------------------------------// boolean columnMatches (Address other) + // ---------------------------------------------------------------------------------// { return column == other.column; } + // ---------------------------------------------------------------------------------// int getRow () + // ---------------------------------------------------------------------------------// { return row; } + // ---------------------------------------------------------------------------------// int getColumn () + // ---------------------------------------------------------------------------------// { return column; } + // ---------------------------------------------------------------------------------// Address nextRow () + // ---------------------------------------------------------------------------------// { Address next = new Address (column, row + 1); return next; } + // ---------------------------------------------------------------------------------// Address nextColumn () + // ---------------------------------------------------------------------------------// { Address next = new Address (column + 1, row); return next; } // copied from Appleworks Cell + // ---------------------------------------------------------------------------------// static String getCellName (int row, int column) + // ---------------------------------------------------------------------------------// { char c1 = (char) ('A' + column / 26 - 1); char c2 = (char) ('A' + column % 26); return "" + (c1 == '@' ? "" : c1) + c2 + row; } + // ---------------------------------------------------------------------------------// public String getText () + // ---------------------------------------------------------------------------------// { return text; } + // ---------------------------------------------------------------------------------// int getRowKey () + // ---------------------------------------------------------------------------------// { return rowKey; } + // ---------------------------------------------------------------------------------// int getColumnKey () + // ---------------------------------------------------------------------------------// { return columnKey; } + // ---------------------------------------------------------------------------------// public String getDetails () + // ---------------------------------------------------------------------------------// { return String.format ("Row:%3d Col:%3d rKey:%5d cKey:%5d", row, column, rowKey, columnKey); } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { return String.format ("%-6s Row:%3d Col:%3d Key:%4d", text, row, column, rowKey); } + // ---------------------------------------------------------------------------------// @Override public int compareTo (Address o) + // ---------------------------------------------------------------------------------// { return rowKey - o.rowKey; } diff --git a/src/com/bytezone/diskbrowser/visicalc/And.java b/src/com/bytezone/diskbrowser/visicalc/And.java index 8b0308c..b31bb59 100644 --- a/src/com/bytezone/diskbrowser/visicalc/And.java +++ b/src/com/bytezone/diskbrowser/visicalc/And.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class And extends ConditionListFunction +// -----------------------------------------------------------------------------------// { - public And (Cell cell, String text) + // ---------------------------------------------------------------------------------// + And (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@AND(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { valueResult = ValueResult.VALID; diff --git a/src/com/bytezone/diskbrowser/visicalc/Asin.java b/src/com/bytezone/diskbrowser/visicalc/Asin.java index 21ea49e..2d079a3 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Asin.java +++ b/src/com/bytezone/diskbrowser/visicalc/Asin.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Asin extends ValueFunction +// -----------------------------------------------------------------------------------// +class Asin extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Asin (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@ASIN(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.asin (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Atan.java b/src/com/bytezone/diskbrowser/visicalc/Atan.java index f2757cd..cf658ac 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Atan.java +++ b/src/com/bytezone/diskbrowser/visicalc/Atan.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Atan extends ValueFunction +// -----------------------------------------------------------------------------------// +class Atan extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Atan (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@ATAN(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.atan (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Average.java b/src/com/bytezone/diskbrowser/visicalc/Average.java index abf59b5..78db5f1 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Average.java +++ b/src/com/bytezone/diskbrowser/visicalc/Average.java @@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc; import com.bytezone.diskbrowser.visicalc.Cell.CellType; -public class Average extends ValueListFunction +// -----------------------------------------------------------------------------------// +class Average extends ValueListFunction +// -----------------------------------------------------------------------------------// { - public Average (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Average (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@AVERAGE(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { double total = 0.0; int totalChecked = 0; diff --git a/src/com/bytezone/diskbrowser/visicalc/BooleanFunction.java b/src/com/bytezone/diskbrowser/visicalc/BooleanFunction.java index e402d20..0808fae 100644 --- a/src/com/bytezone/diskbrowser/visicalc/BooleanFunction.java +++ b/src/com/bytezone/diskbrowser/visicalc/BooleanFunction.java @@ -1,10 +1,14 @@ package com.bytezone.diskbrowser.visicalc; -public class BooleanFunction extends Function +// -----------------------------------------------------------------------------------// +class BooleanFunction extends Function +// -----------------------------------------------------------------------------------// { protected Value source; + // ---------------------------------------------------------------------------------// BooleanFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -13,8 +17,10 @@ public class BooleanFunction extends Function valueType = ValueType.BOOLEAN; } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "BooleanFunction"; } diff --git a/src/com/bytezone/diskbrowser/visicalc/Cell.java b/src/com/bytezone/diskbrowser/visicalc/Cell.java index 0939435..f1c8761 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Cell.java +++ b/src/com/bytezone/diskbrowser/visicalc/Cell.java @@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc; import java.util.Iterator; +// -----------------------------------------------------------------------------------// class Cell implements Value, Comparable +// -----------------------------------------------------------------------------------// { private static final String empty = " "; @@ -23,7 +25,9 @@ class Cell implements Value, Comparable LABEL, FILLER, VALUE, EMPTY } - public Cell (Sheet parent, Address address) + // ---------------------------------------------------------------------------------// + Cell (Sheet parent, Address address) + // ---------------------------------------------------------------------------------// { this.parent = parent; this.address = address; @@ -31,7 +35,9 @@ class Cell implements Value, Comparable cellType = CellType.EMPTY; } + // ---------------------------------------------------------------------------------// void setFormat (String formatText) + // ---------------------------------------------------------------------------------// { if (formatText.startsWith ("/T")) // lock titles return; @@ -57,7 +63,9 @@ class Cell implements Value, Comparable System.out.printf ("Unexpected format [%s]%n", formatText); } + // ---------------------------------------------------------------------------------// void setValue (String valueText) + // ---------------------------------------------------------------------------------// { assert cellType == CellType.EMPTY; @@ -84,28 +92,38 @@ class Cell implements Value, Comparable setTestData (0); } + // ---------------------------------------------------------------------------------// void reset () + // ---------------------------------------------------------------------------------// { calculated = false; } + // ---------------------------------------------------------------------------------// Value getExpressionValue (String text) + // ---------------------------------------------------------------------------------// { return new Expression (this, text).reduce (); } + // ---------------------------------------------------------------------------------// boolean isCellType (CellType cellType) + // ---------------------------------------------------------------------------------// { return this.cellType == cellType; } + // ---------------------------------------------------------------------------------// Address getAddress () + // ---------------------------------------------------------------------------------// { return address; } + // ---------------------------------------------------------------------------------// // format cell value for output String getFormattedText (int colWidth, char globalFormat) + // ---------------------------------------------------------------------------------// { char fmtChar = cellFormat != ' ' ? cellFormat : globalFormat; @@ -159,36 +177,46 @@ class Cell implements Value, Comparable } } - // --------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// // Sheet convenience methods - // --------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// Cell getCell (Address address) + // ---------------------------------------------------------------------------------// { return parent.getCell (address); } + // ---------------------------------------------------------------------------------// Cell getCell (String addressText) + // ---------------------------------------------------------------------------------// { return parent.getCell (addressText); } + // ---------------------------------------------------------------------------------// boolean cellExists (Address address) + // ---------------------------------------------------------------------------------// { return parent.cellExists (address); } + // ---------------------------------------------------------------------------------// Function getFunction (String text) + // ---------------------------------------------------------------------------------// { return parent.getFunction (this, text); } - // --------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// // Value interface methods - // --------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { if (cellType == CellType.VALUE && !calculated) { @@ -197,44 +225,58 @@ class Cell implements Value, Comparable } } + // ---------------------------------------------------------------------------------// @Override public boolean isValid () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.isValid () : true; } + // ---------------------------------------------------------------------------------// @Override public ValueType getValueType () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.getValueType () : ValueType.NUMBER; } + // ---------------------------------------------------------------------------------// @Override public ValueResult getValueResult () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.getValueResult () : ValueResult.VALID; } + // ---------------------------------------------------------------------------------// @Override public double getDouble () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.getDouble () : 0; } + // ---------------------------------------------------------------------------------// @Override public boolean getBoolean () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.getBoolean () : false; } + // ---------------------------------------------------------------------------------// @Override public String getText () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.getText () : "???"; } + // ---------------------------------------------------------------------------------// @Override public String getFullText () + // ---------------------------------------------------------------------------------// { switch (cellType) { @@ -251,29 +293,37 @@ class Cell implements Value, Comparable } } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "Cell " + address.getText (); } + // ---------------------------------------------------------------------------------// @Override public int size () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.size () : 0; } + // ---------------------------------------------------------------------------------// @Override public Iterator iterator () + // ---------------------------------------------------------------------------------// { return cellType == CellType.VALUE ? value.iterator () : null; } - // --------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// // end of Value interface methods - // --------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// + // ---------------------------------------------------------------------------------// private void setTestData (int choice) + // ---------------------------------------------------------------------------------// { // FUTURE.VC if (choice == 1) @@ -320,14 +370,18 @@ class Cell implements Value, Comparable } } + // ---------------------------------------------------------------------------------// @Override public int compareTo (Cell o) + // ---------------------------------------------------------------------------------// { return address.compareTo (o.address); } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { String contents = ""; String contents2 = ""; diff --git a/src/com/bytezone/diskbrowser/visicalc/Choose.java b/src/com/bytezone/diskbrowser/visicalc/Choose.java index da37489..195200d 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Choose.java +++ b/src/com/bytezone/diskbrowser/visicalc/Choose.java @@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc; import com.bytezone.diskbrowser.visicalc.Cell.CellType; -public class Choose extends ValueListFunction +// -----------------------------------------------------------------------------------// +class Choose extends ValueListFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Choose (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@CHOOSE(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { Value source = list.get (0); valueResult = ValueResult.VALID; diff --git a/src/com/bytezone/diskbrowser/visicalc/Condition.java b/src/com/bytezone/diskbrowser/visicalc/Condition.java index e985c2a..fe772b7 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Condition.java +++ b/src/com/bytezone/diskbrowser/visicalc/Condition.java @@ -4,7 +4,9 @@ import java.util.Iterator; import java.util.regex.Pattern; // Predicate +// -----------------------------------------------------------------------------------// class Condition extends AbstractValue implements Iterable +// -----------------------------------------------------------------------------------// { private static final Pattern cellAddress = Pattern.compile ("[A-B]?[A-Z][0-9]{1,3}"); private static final String[] comparators = { "<>", "<=", ">=", "=", "<", ">" }; @@ -16,7 +18,9 @@ class Condition extends AbstractValue implements Iterable private Value conditionExpression; private Value valueExpression; - public Condition (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Condition (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -52,8 +56,10 @@ class Condition extends AbstractValue implements Iterable "No comparator and not a function or address: " + text); } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { valueResult = ValueResult.VALID; @@ -97,19 +103,25 @@ class Condition extends AbstractValue implements Iterable System.out.printf ("Unexpected comparator result [%s]%n", comparator); } + // ---------------------------------------------------------------------------------// @Override public String getFullText () + // ---------------------------------------------------------------------------------// { return fullText; } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "Condition"; } + // ---------------------------------------------------------------------------------// static boolean isCondition (String text) + // ---------------------------------------------------------------------------------// { int ptr = 0; int depth = 0; @@ -129,14 +141,18 @@ class Condition extends AbstractValue implements Iterable return false; } + // ---------------------------------------------------------------------------------// @Override public Iterator iterator () + // ---------------------------------------------------------------------------------// { return values.iterator (); } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); diff --git a/src/com/bytezone/diskbrowser/visicalc/ConditionList.java b/src/com/bytezone/diskbrowser/visicalc/ConditionList.java index 8521376..7d95687 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ConditionList.java +++ b/src/com/bytezone/diskbrowser/visicalc/ConditionList.java @@ -4,11 +4,15 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class ConditionList implements Iterable +// -----------------------------------------------------------------------------------// +class ConditionList implements Iterable +// -----------------------------------------------------------------------------------// { private final List conditions = new ArrayList<> (); - public ConditionList (Cell cell, String text) + // ---------------------------------------------------------------------------------// + ConditionList (Cell cell, String text) + // ---------------------------------------------------------------------------------// { String remainder = text; @@ -30,18 +34,24 @@ public class ConditionList implements Iterable } } + // ---------------------------------------------------------------------------------// public Value get (int index) + // ---------------------------------------------------------------------------------// { return conditions.get (index); } + // ---------------------------------------------------------------------------------// public int size () + // ---------------------------------------------------------------------------------// { return conditions.size (); } + // ---------------------------------------------------------------------------------// @Override public Iterator iterator () + // ---------------------------------------------------------------------------------// { return conditions.iterator (); } diff --git a/src/com/bytezone/diskbrowser/visicalc/ConditionListFunction.java b/src/com/bytezone/diskbrowser/visicalc/ConditionListFunction.java index d43b6a4..79d0f10 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ConditionListFunction.java +++ b/src/com/bytezone/diskbrowser/visicalc/ConditionListFunction.java @@ -1,10 +1,14 @@ package com.bytezone.diskbrowser.visicalc; -public class ConditionListFunction extends Function +// -----------------------------------------------------------------------------------// +class ConditionListFunction extends Function +// -----------------------------------------------------------------------------------// { protected final ConditionList conditions; + // ---------------------------------------------------------------------------------// ConditionListFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -15,8 +19,10 @@ public class ConditionListFunction extends Function valueType = ValueType.BOOLEAN; } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "CLF"; } diff --git a/src/com/bytezone/diskbrowser/visicalc/ConstantFunction.java b/src/com/bytezone/diskbrowser/visicalc/ConstantFunction.java index 4be0890..d6a012c 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ConstantFunction.java +++ b/src/com/bytezone/diskbrowser/visicalc/ConstantFunction.java @@ -1,14 +1,20 @@ package com.bytezone.diskbrowser.visicalc; -public abstract class ConstantFunction extends Function +// -----------------------------------------------------------------------------------// +abstract class ConstantFunction extends Function +// -----------------------------------------------------------------------------------// { - public ConstantFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// + ConstantFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "ConstantFunction"; } diff --git a/src/com/bytezone/diskbrowser/visicalc/Cos.java b/src/com/bytezone/diskbrowser/visicalc/Cos.java index b2b425e..3d82d0d 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Cos.java +++ b/src/com/bytezone/diskbrowser/visicalc/Cos.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Cos extends ValueFunction +// ---------------------------------------------------------------------------------// +class Cos extends ValueFunction +// ---------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Cos (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@COS(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.cos (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Count.java b/src/com/bytezone/diskbrowser/visicalc/Count.java index c1ce11f..439f759 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Count.java +++ b/src/com/bytezone/diskbrowser/visicalc/Count.java @@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc; import com.bytezone.diskbrowser.visicalc.Cell.CellType; +// -----------------------------------------------------------------------------------// class Count extends ValueListFunction +// -----------------------------------------------------------------------------------// { - public Count (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Count (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@COUNT(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { value = 0; diff --git a/src/com/bytezone/diskbrowser/visicalc/Error.java b/src/com/bytezone/diskbrowser/visicalc/Error.java index 03c256a..7fc3834 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Error.java +++ b/src/com/bytezone/diskbrowser/visicalc/Error.java @@ -1,8 +1,12 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Error extends ConstantFunction +// -----------------------------------------------------------------------------------// { - public Error (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Error (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); diff --git a/src/com/bytezone/diskbrowser/visicalc/Exp.java b/src/com/bytezone/diskbrowser/visicalc/Exp.java index 0d48331..c35f212 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Exp.java +++ b/src/com/bytezone/diskbrowser/visicalc/Exp.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Exp extends ValueFunction +// -----------------------------------------------------------------------------------// +class Exp extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Exp (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@EXP(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.exp (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Expression.java b/src/com/bytezone/diskbrowser/visicalc/Expression.java index aa45c07..bc44f39 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Expression.java +++ b/src/com/bytezone/diskbrowser/visicalc/Expression.java @@ -3,12 +3,16 @@ package com.bytezone.diskbrowser.visicalc; import java.util.ArrayList; import java.util.List; +// -----------------------------------------------------------------------------------// class Expression extends AbstractValue +// -----------------------------------------------------------------------------------// { private final List operators = new ArrayList<> (); private final List signs = new ArrayList<> (); - public Expression (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Expression (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -97,26 +101,34 @@ class Expression extends AbstractValue valueType = values.get (0).getValueType (); } + // ---------------------------------------------------------------------------------// Value reduce () + // ---------------------------------------------------------------------------------// { return values.size () == 1 && signs.get (0).equals ("(+)") ? values.get (0) : this; } + // ---------------------------------------------------------------------------------// Value get (int index) + // ---------------------------------------------------------------------------------// { if (index < 0 || index >= values.size ()) throw new IllegalArgumentException (); return values.get (index); } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "Expression"; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { assert values.size () > 0; @@ -191,7 +203,9 @@ class Expression extends AbstractValue } } + // ---------------------------------------------------------------------------------// private String balanceBrackets (String input) + // ---------------------------------------------------------------------------------// { String line = input.trim (); @@ -224,7 +238,9 @@ class Expression extends AbstractValue } // called for functions and expressions + // ---------------------------------------------------------------------------------// private String getBalancedText (String text) + // ---------------------------------------------------------------------------------// { int ptr = text.indexOf ('('); // find first left parenthesis if (ptr < 0) @@ -248,7 +264,9 @@ class Expression extends AbstractValue // reads text up to the next comma that is not part of a function // text does not include the outer brackets or calling function name + // ---------------------------------------------------------------------------------// static String getParameter (String text) + // ---------------------------------------------------------------------------------// { int depth = 0; int ptr = 0; @@ -269,7 +287,9 @@ class Expression extends AbstractValue } // receives a string starting with the function name + // ---------------------------------------------------------------------------------// private String getFunctionCall (String text) + // ---------------------------------------------------------------------------------// { if (text.charAt (0) != '@') throw new IllegalArgumentException ("Bad function name: " + text); @@ -285,7 +305,9 @@ class Expression extends AbstractValue throw new IllegalArgumentException ("Bad function name: " + text); } + // ---------------------------------------------------------------------------------// private String getNumberText (String text) + // ---------------------------------------------------------------------------------// { int ptr = 0; while (++ptr < text.length ()) @@ -297,7 +319,9 @@ class Expression extends AbstractValue return text.substring (0, ptr); } + // ---------------------------------------------------------------------------------// private String getAddressText (String text) + // ---------------------------------------------------------------------------------// { int ptr = 0; while (++ptr < text.length ()) @@ -309,7 +333,9 @@ class Expression extends AbstractValue return text.substring (0, ptr); } + // ---------------------------------------------------------------------------------// public String fullText () + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); @@ -326,8 +352,10 @@ class Expression extends AbstractValue return text.toString (); } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); text.append (String.format ("%s%n", LINE)); diff --git a/src/com/bytezone/diskbrowser/visicalc/False.java b/src/com/bytezone/diskbrowser/visicalc/False.java index 95a2a10..35471b8 100644 --- a/src/com/bytezone/diskbrowser/visicalc/False.java +++ b/src/com/bytezone/diskbrowser/visicalc/False.java @@ -1,8 +1,12 @@ package com.bytezone.diskbrowser.visicalc; -public class False extends ConstantFunction +// -----------------------------------------------------------------------------------// +class False extends ConstantFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// False (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); diff --git a/src/com/bytezone/diskbrowser/visicalc/Format.java b/src/com/bytezone/diskbrowser/visicalc/Format.java index ba5c44b..f56037f 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Format.java +++ b/src/com/bytezone/diskbrowser/visicalc/Format.java @@ -1,17 +1,23 @@ package com.bytezone.diskbrowser.visicalc; -public class Format +// -----------------------------------------------------------------------------------// +class Format +// -----------------------------------------------------------------------------------// { private static final String OVERFLOW = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; private static final String HISTOGRAM = "***********************************"; private static final String UNKNOWN = "???????????????????????????????????"; + // ---------------------------------------------------------------------------------// private Format () + // ---------------------------------------------------------------------------------// { } + // ---------------------------------------------------------------------------------// static String format (Value value, char formatChar, int colWidth) + // ---------------------------------------------------------------------------------// { double actualValue = value.getDouble (); if (actualValue == -0.0) @@ -96,7 +102,9 @@ public class Format } } + // ---------------------------------------------------------------------------------// static String justify (String text, int colWidth, char format) + // ---------------------------------------------------------------------------------// { // right justify if (format == 'R' || format == '$' || format == 'I') diff --git a/src/com/bytezone/diskbrowser/visicalc/Function.java b/src/com/bytezone/diskbrowser/visicalc/Function.java index 9e1b45d..8dd04f3 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Function.java +++ b/src/com/bytezone/diskbrowser/visicalc/Function.java @@ -1,6 +1,8 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// abstract class Function extends AbstractValue +// -----------------------------------------------------------------------------------// { static final String[] functionList = { "@ABS(", "@ACOS(", "@AND(", "@ASIN(", "@ATAN(", "@AVERAGE(", "@COUNT(", @@ -11,7 +13,9 @@ abstract class Function extends AbstractValue protected final String functionName; protected final String functionText; + // ---------------------------------------------------------------------------------// Function (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -29,8 +33,10 @@ abstract class Function extends AbstractValue } } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); text.append (String.format ("%s%n", LINE)); diff --git a/src/com/bytezone/diskbrowser/visicalc/If.java b/src/com/bytezone/diskbrowser/visicalc/If.java index 634068c..a12f8f1 100644 --- a/src/com/bytezone/diskbrowser/visicalc/If.java +++ b/src/com/bytezone/diskbrowser/visicalc/If.java @@ -1,6 +1,8 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class If extends Function +// -----------------------------------------------------------------------------------// { private final String conditionText; private final String textTrue; @@ -10,7 +12,9 @@ class If extends Function private final Value expTrue; private final Value expFalse; - public If (Cell cell, String text) + // ---------------------------------------------------------------------------------// + If (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -42,8 +46,10 @@ class If extends Function valueType = expTrue.getValueType (); } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { valueResult = ValueResult.VALID; @@ -73,14 +79,18 @@ class If extends Function } } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "If"; } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); diff --git a/src/com/bytezone/diskbrowser/visicalc/Int.java b/src/com/bytezone/diskbrowser/visicalc/Int.java index 8b8aa6f..befa462 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Int.java +++ b/src/com/bytezone/diskbrowser/visicalc/Int.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Int extends ValueFunction +// -----------------------------------------------------------------------------------// +class Int extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Int (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@INT(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return (int) source.getDouble (); } diff --git a/src/com/bytezone/diskbrowser/visicalc/IsError.java b/src/com/bytezone/diskbrowser/visicalc/IsError.java index 1fdfda0..a7c3905 100644 --- a/src/com/bytezone/diskbrowser/visicalc/IsError.java +++ b/src/com/bytezone/diskbrowser/visicalc/IsError.java @@ -1,16 +1,22 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class IsError extends BooleanFunction +// -----------------------------------------------------------------------------------// { - public IsError (Cell cell, String text) + // ---------------------------------------------------------------------------------// + IsError (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@ISERROR(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { source.calculate (); bool = source.getValueResult () == ValueResult.ERROR; diff --git a/src/com/bytezone/diskbrowser/visicalc/IsNa.java b/src/com/bytezone/diskbrowser/visicalc/IsNa.java index 4bfa7bf..2652375 100644 --- a/src/com/bytezone/diskbrowser/visicalc/IsNa.java +++ b/src/com/bytezone/diskbrowser/visicalc/IsNa.java @@ -1,16 +1,22 @@ package com.bytezone.diskbrowser.visicalc; -public class IsNa extends BooleanFunction +// -----------------------------------------------------------------------------------// +class IsNa extends BooleanFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// IsNa (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@ISNA(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { source.calculate (); bool = source.getValueResult () == ValueResult.NA; diff --git a/src/com/bytezone/diskbrowser/visicalc/Ln.java b/src/com/bytezone/diskbrowser/visicalc/Ln.java index bf75657..2a23d41 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Ln.java +++ b/src/com/bytezone/diskbrowser/visicalc/Ln.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Ln extends ValueFunction +// -----------------------------------------------------------------------------------// +class Ln extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Ln (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@LN(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.log (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Log10.java b/src/com/bytezone/diskbrowser/visicalc/Log10.java index 3a90462..cd5ac16 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Log10.java +++ b/src/com/bytezone/diskbrowser/visicalc/Log10.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Log10 extends ValueFunction +// ---------------------------------------------------------------------------------// +class Log10 extends ValueFunction +// ---------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Log10 (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@LOG10(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.log10 (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Lookup.java b/src/com/bytezone/diskbrowser/visicalc/Lookup.java index 8e88f1e..f938e59 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Lookup.java +++ b/src/com/bytezone/diskbrowser/visicalc/Lookup.java @@ -1,16 +1,22 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Lookup extends ValueListFunction +// -----------------------------------------------------------------------------------// { - public Lookup (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Lookup (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@LOOKUP(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { Value source = list.get (0); // first Value is the value to look up valueResult = ValueResult.VALID; @@ -55,7 +61,9 @@ class Lookup extends ValueListFunction } // is the range horizontal or vertical? + // ---------------------------------------------------------------------------------// private boolean isVertical () + // ---------------------------------------------------------------------------------// { Cell firstCell = (Cell) list.get (1); Cell lastCell = (Cell) list.get (list.size () - 1); diff --git a/src/com/bytezone/diskbrowser/visicalc/Max.java b/src/com/bytezone/diskbrowser/visicalc/Max.java index 89cb3e9..a5e215f 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Max.java +++ b/src/com/bytezone/diskbrowser/visicalc/Max.java @@ -1,16 +1,22 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Max extends ValueListFunction +// -----------------------------------------------------------------------------------// { - public Max (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Max (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@MAX(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { value = Double.MIN_VALUE; int totalChecked = 0; diff --git a/src/com/bytezone/diskbrowser/visicalc/Min.java b/src/com/bytezone/diskbrowser/visicalc/Min.java index 33bdd0c..8c7532e 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Min.java +++ b/src/com/bytezone/diskbrowser/visicalc/Min.java @@ -1,16 +1,22 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Min extends ValueListFunction +// -----------------------------------------------------------------------------------// { - public Min (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Min (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@MIN(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { value = Double.MAX_VALUE; int totalChecked = 0; diff --git a/src/com/bytezone/diskbrowser/visicalc/Na.java b/src/com/bytezone/diskbrowser/visicalc/Na.java index bea49ac..78c564e 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Na.java +++ b/src/com/bytezone/diskbrowser/visicalc/Na.java @@ -1,8 +1,12 @@ package com.bytezone.diskbrowser.visicalc; -public class Na extends ConstantFunction +// -----------------------------------------------------------------------------------// +class Na extends ConstantFunction +// -----------------------------------------------------------------------------------// { - public Na (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Na (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); diff --git a/src/com/bytezone/diskbrowser/visicalc/Not.java b/src/com/bytezone/diskbrowser/visicalc/Not.java index a2bb4de..630f3c7 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Not.java +++ b/src/com/bytezone/diskbrowser/visicalc/Not.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Not extends BooleanFunction +// -----------------------------------------------------------------------------------// +class Not extends BooleanFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Not (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@NOT(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { source.calculate (); diff --git a/src/com/bytezone/diskbrowser/visicalc/Npv.java b/src/com/bytezone/diskbrowser/visicalc/Npv.java index 83afe73..beac449 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Npv.java +++ b/src/com/bytezone/diskbrowser/visicalc/Npv.java @@ -2,17 +2,23 @@ package com.bytezone.diskbrowser.visicalc; import com.bytezone.diskbrowser.visicalc.Cell.CellType; -public class Npv extends ValueListFunction +// -----------------------------------------------------------------------------------// +class Npv extends ValueListFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Npv (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@NPV(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { value = 0; valueResult = ValueResult.VALID; diff --git a/src/com/bytezone/diskbrowser/visicalc/Number.java b/src/com/bytezone/diskbrowser/visicalc/Number.java index 2b8b344..5e16bfa 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Number.java +++ b/src/com/bytezone/diskbrowser/visicalc/Number.java @@ -1,8 +1,12 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Number extends AbstractValue +// -----------------------------------------------------------------------------------// { - public Number (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Number (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -19,14 +23,18 @@ class Number extends AbstractValue } } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "Constant"; } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); text.append (String.format ("%s%n", LINE)); diff --git a/src/com/bytezone/diskbrowser/visicalc/Or.java b/src/com/bytezone/diskbrowser/visicalc/Or.java index 6c612b1..db68c0e 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Or.java +++ b/src/com/bytezone/diskbrowser/visicalc/Or.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Or extends ConditionListFunction +// -----------------------------------------------------------------------------------// { - public Or (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Or (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@OR(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { valueResult = ValueResult.VALID; diff --git a/src/com/bytezone/diskbrowser/visicalc/Pi.java b/src/com/bytezone/diskbrowser/visicalc/Pi.java index 114bc97..c6b5209 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Pi.java +++ b/src/com/bytezone/diskbrowser/visicalc/Pi.java @@ -1,8 +1,12 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Pi extends ConstantFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Pi (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); diff --git a/src/com/bytezone/diskbrowser/visicalc/Range.java b/src/com/bytezone/diskbrowser/visicalc/Range.java index 3ea81c2..1f5b0cd 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Range.java +++ b/src/com/bytezone/diskbrowser/visicalc/Range.java @@ -6,7 +6,9 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +// -----------------------------------------------------------------------------------// class Range implements Iterable
+// -----------------------------------------------------------------------------------// { // private static final Pattern cellAddress = Pattern.compile ("[A-B]?[A-Z][0-9]{1,3}"); private static final Pattern rangePattern = @@ -19,7 +21,9 @@ class Range implements Iterable
private boolean isHorizontal; - public Range (Cell cell, String rangeText) + // ---------------------------------------------------------------------------------// + Range (Cell cell, String rangeText) + // ---------------------------------------------------------------------------------// { this.cell = cell; @@ -35,7 +39,9 @@ class Range implements Iterable
throw new IllegalArgumentException (rangeText); } + // ---------------------------------------------------------------------------------// private void populateRange () + // ---------------------------------------------------------------------------------// { range.add (from); cell.getCell (from); @@ -62,39 +68,53 @@ class Range implements Iterable
from = tempFrom; } + // ---------------------------------------------------------------------------------// static boolean isRange (String text) + // ---------------------------------------------------------------------------------// { return rangePattern.matcher (text).matches (); } + // ---------------------------------------------------------------------------------// boolean isHorizontal () + // ---------------------------------------------------------------------------------// { return isHorizontal; } + // ---------------------------------------------------------------------------------// boolean isVertical () + // ---------------------------------------------------------------------------------// { return !isHorizontal; } + // ---------------------------------------------------------------------------------// @Override public Iterator
iterator () + // ---------------------------------------------------------------------------------// { return range.iterator (); } + // ---------------------------------------------------------------------------------// public int size () + // ---------------------------------------------------------------------------------// { return range.size (); } + // ---------------------------------------------------------------------------------// public Address get (int index) + // ---------------------------------------------------------------------------------// { return index < 0 || index >= range.size () ? null : range.get (index); } + // ---------------------------------------------------------------------------------// @Override public String toString () + // ---------------------------------------------------------------------------------// { if (from == null || to == null) { diff --git a/src/com/bytezone/diskbrowser/visicalc/Sheet.java b/src/com/bytezone/diskbrowser/visicalc/Sheet.java index b276194..97a4599 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sheet.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sheet.java @@ -10,7 +10,9 @@ import java.util.regex.Pattern; import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.visicalc.Cell.CellType; +// -----------------------------------------------------------------------------------// public class Sheet +// -----------------------------------------------------------------------------------// { private static final Pattern addressPattern = Pattern.compile ("([AB]?[A-Z])([0-9]{1,3}):"); @@ -146,7 +148,9 @@ public class Sheet // /X!/X>A3:>A7: A3:top-left cell in window, A7:cell to place cursor + // ---------------------------------------------------------------------------------// public Sheet (byte[] buffer) + // ---------------------------------------------------------------------------------// { int last = buffer.length; while (buffer[--last] == 0) // ignore trailing zeroes @@ -182,7 +186,9 @@ public class Sheet } } + // ---------------------------------------------------------------------------------// private void calculate (char order) + // ---------------------------------------------------------------------------------// { Map cells = order == 'R' ? rowOrderCells : columnOrderCells; for (Cell cell : cells.values ()) @@ -190,7 +196,9 @@ public class Sheet cell.calculate (); } + // ---------------------------------------------------------------------------------// private int getLineLength (byte[] buffer, int offset) + // ---------------------------------------------------------------------------------// { int ptr = offset; while (buffer[ptr] != END_OF_LINE_TOKEN) @@ -198,7 +206,9 @@ public class Sheet return ptr - offset; } + // ---------------------------------------------------------------------------------// private void processLine (String line) + // ---------------------------------------------------------------------------------// { Cell currentCell = null; @@ -259,7 +269,9 @@ public class Sheet currentCell.setValue (line); // expression } + // ---------------------------------------------------------------------------------// private void addCell (Cell cell) + // ---------------------------------------------------------------------------------// { rowOrderCells.put (cell.getAddress ().getRowKey (), cell); columnOrderCells.put (cell.getAddress ().getColumnKey (), cell); @@ -271,12 +283,16 @@ public class Sheet maxColumn = Math.max (maxColumn, cell.getAddress ().getColumn ()); } + // ---------------------------------------------------------------------------------// Cell getCell (String addressText) + // ---------------------------------------------------------------------------------// { return getCell (new Address (addressText)); } + // ---------------------------------------------------------------------------------// Cell getCell (Address address) + // ---------------------------------------------------------------------------------// { Cell cell = rowOrderCells.get (address.getRowKey ()); if (cell == null) @@ -287,17 +303,23 @@ public class Sheet return cell; } + // ---------------------------------------------------------------------------------// boolean cellExists (Address address) + // ---------------------------------------------------------------------------------// { return rowOrderCells.get (address.getRowKey ()) != null; } + // ---------------------------------------------------------------------------------// public int size () + // ---------------------------------------------------------------------------------// { return rowOrderCells.size (); } + // ---------------------------------------------------------------------------------// private void doFormat (String line) + // ---------------------------------------------------------------------------------// { switch (line.charAt (1)) { @@ -313,7 +335,9 @@ public class Sheet } } + // ---------------------------------------------------------------------------------// private void setGlobal (String line) + // ---------------------------------------------------------------------------------// { switch (line.charAt (2)) { @@ -338,7 +362,9 @@ public class Sheet } } + // ---------------------------------------------------------------------------------// public String getTextDisplay (boolean debug) + // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); String longLine; @@ -497,7 +523,9 @@ public class Sheet return text.toString (); } + // ---------------------------------------------------------------------------------// Function getFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// { int functionId = -1; for (int i = 0; i < Function.functionList.length; i++) diff --git a/src/com/bytezone/diskbrowser/visicalc/Sin.java b/src/com/bytezone/diskbrowser/visicalc/Sin.java index 4f0c4c9..94256c8 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sin.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sin.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Sin extends ValueFunction +// -----------------------------------------------------------------------------------// +class Sin extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Sin (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@SIN(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.sin (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Sqrt.java b/src/com/bytezone/diskbrowser/visicalc/Sqrt.java index 6e8b1c9..3e3fafc 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sqrt.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sqrt.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Sqrt extends ValueFunction +// -----------------------------------------------------------------------------------// +class Sqrt extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Sqrt (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@SQRT(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.sqrt (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/Sum.java b/src/com/bytezone/diskbrowser/visicalc/Sum.java index 11c0f27..4991942 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sum.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sum.java @@ -1,16 +1,22 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// class Sum extends ValueListFunction +// -----------------------------------------------------------------------------------// { - public Sum (Cell cell, String text) + // ---------------------------------------------------------------------------------// + Sum (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@SUM(") : text; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { value = 0; valueResult = ValueResult.VALID; diff --git a/src/com/bytezone/diskbrowser/visicalc/Tan.java b/src/com/bytezone/diskbrowser/visicalc/Tan.java index f5ba621..c2a8123 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Tan.java +++ b/src/com/bytezone/diskbrowser/visicalc/Tan.java @@ -1,15 +1,21 @@ package com.bytezone.diskbrowser.visicalc; -public class Tan extends ValueFunction +// -----------------------------------------------------------------------------------// +class Tan extends ValueFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// Tan (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); assert text.startsWith ("@TAN(") : text; } + // ---------------------------------------------------------------------------------// @Override public double calculateValue () + // ---------------------------------------------------------------------------------// { return Math.tan (source.getDouble ()); } diff --git a/src/com/bytezone/diskbrowser/visicalc/True.java b/src/com/bytezone/diskbrowser/visicalc/True.java index 005b34f..8a72f07 100644 --- a/src/com/bytezone/diskbrowser/visicalc/True.java +++ b/src/com/bytezone/diskbrowser/visicalc/True.java @@ -1,8 +1,12 @@ package com.bytezone.diskbrowser.visicalc; -public class True extends ConstantFunction +// -----------------------------------------------------------------------------------// +class True extends ConstantFunction +// -----------------------------------------------------------------------------------// { + // ---------------------------------------------------------------------------------// True (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); diff --git a/src/com/bytezone/diskbrowser/visicalc/Value.java b/src/com/bytezone/diskbrowser/visicalc/Value.java index d219b3c..f942a07 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Value.java +++ b/src/com/bytezone/diskbrowser/visicalc/Value.java @@ -1,6 +1,8 @@ package com.bytezone.diskbrowser.visicalc; +// -----------------------------------------------------------------------------------// interface Value extends Iterable +// -----------------------------------------------------------------------------------// { enum ValueType { diff --git a/src/com/bytezone/diskbrowser/visicalc/ValueFunction.java b/src/com/bytezone/diskbrowser/visicalc/ValueFunction.java index 47c091f..fdedd94 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ValueFunction.java +++ b/src/com/bytezone/diskbrowser/visicalc/ValueFunction.java @@ -1,12 +1,16 @@ package com.bytezone.diskbrowser.visicalc; -public abstract class ValueFunction extends Function +// -----------------------------------------------------------------------------------// +abstract class ValueFunction extends Function +// -----------------------------------------------------------------------------------// { protected Value source; abstract double calculateValue (); + // ---------------------------------------------------------------------------------// ValueFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -15,8 +19,10 @@ public abstract class ValueFunction extends Function valueType = ValueType.NUMBER; } + // ---------------------------------------------------------------------------------// @Override public void calculate () + // ---------------------------------------------------------------------------------// { valueResult = ValueResult.VALID; @@ -34,8 +40,10 @@ public abstract class ValueFunction extends Function valueResult = ValueResult.ERROR; } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "ValueFunction"; } diff --git a/src/com/bytezone/diskbrowser/visicalc/ValueList.java b/src/com/bytezone/diskbrowser/visicalc/ValueList.java index e46e3c4..467f3e8 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ValueList.java +++ b/src/com/bytezone/diskbrowser/visicalc/ValueList.java @@ -4,12 +4,16 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class ValueList implements Iterable +// -----------------------------------------------------------------------------------// +class ValueList implements Iterable +// -----------------------------------------------------------------------------------// { private final List values = new ArrayList<> (); private boolean hasRange; - public ValueList (Cell cell, String text) + // ---------------------------------------------------------------------------------// + ValueList (Cell cell, String text) + // ---------------------------------------------------------------------------------// { String remainder = text; @@ -33,23 +37,31 @@ public class ValueList implements Iterable } } + // ---------------------------------------------------------------------------------// public boolean hasRange () + // ---------------------------------------------------------------------------------// { return hasRange; } + // ---------------------------------------------------------------------------------// public Value get (int index) + // ---------------------------------------------------------------------------------// { return values.get (index); } + // ---------------------------------------------------------------------------------// public int size () + // ---------------------------------------------------------------------------------// { return values.size (); } + // ---------------------------------------------------------------------------------// @Override public Iterator iterator () + // ---------------------------------------------------------------------------------// { return values.iterator (); } diff --git a/src/com/bytezone/diskbrowser/visicalc/ValueListFunction.java b/src/com/bytezone/diskbrowser/visicalc/ValueListFunction.java index 51c34e1..87760e0 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ValueListFunction.java +++ b/src/com/bytezone/diskbrowser/visicalc/ValueListFunction.java @@ -1,11 +1,15 @@ package com.bytezone.diskbrowser.visicalc; -public abstract class ValueListFunction extends Function +// -----------------------------------------------------------------------------------// +abstract class ValueListFunction extends Function +// -----------------------------------------------------------------------------------// { protected final ValueList list; protected final boolean isRange; - public ValueListFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// + ValueListFunction (Cell cell, String text) + // ---------------------------------------------------------------------------------// { super (cell, text); @@ -17,8 +21,10 @@ public abstract class ValueListFunction extends Function values.add (v); } + // ---------------------------------------------------------------------------------// @Override public String getType () + // ---------------------------------------------------------------------------------// { return "ValueListFunction"; }