mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-07 11:30:39 +00:00
method header lines
This commit is contained in:
parent
6b3c7011d3
commit
846c975be6
@ -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 ());
|
||||
}
|
||||
|
@ -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<Value> 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<Value> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return values.iterator ();
|
||||
}
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Address implements Comparable<Address>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int MAX_ROWS = 255;
|
||||
private static final int MAX_COLUMNS = 64;
|
||||
@ -12,12 +14,16 @@ class Address implements Comparable<Address>
|
||||
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<Address>
|
||||
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<Address>
|
||||
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<Address>
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Cell implements Value, Comparable<Cell>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final String empty = " ";
|
||||
|
||||
@ -23,7 +25,9 @@ class Cell implements Value, Comparable<Cell>
|
||||
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<Cell>
|
||||
cellType = CellType.EMPTY;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void setFormat (String formatText)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (formatText.startsWith ("/T")) // lock titles
|
||||
return;
|
||||
@ -57,7 +63,9 @@ class Cell implements Value, Comparable<Cell>
|
||||
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<Cell>
|
||||
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<Cell>
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------//
|
||||
// ---------------------------------------------------------------------------------//
|
||||
// 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<Cell>
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@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<Cell>
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getType ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return "Cell " + address.getText ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int size ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return cellType == CellType.VALUE ? value.size () : 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<Value> 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<Cell>
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int compareTo (Cell o)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return address.compareTo (o.address);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String contents = "";
|
||||
String contents2 = "";
|
||||
|
@ -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;
|
||||
|
@ -4,7 +4,9 @@ import java.util.Iterator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
// Predicate
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Condition extends AbstractValue implements Iterable<Value>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
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<Value>
|
||||
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<Value>
|
||||
"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<Value>
|
||||
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<Value>
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<Value> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return values.iterator ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -4,11 +4,15 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ConditionList implements Iterable<Value>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ConditionList implements Iterable<Value>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<Value> 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<Value>
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Value get (int index)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return conditions.get (index);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public int size ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return conditions.size ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<Value> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return conditions.iterator ();
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -3,12 +3,16 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Expression extends AbstractValue
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<String> operators = new ArrayList<> ();
|
||||
private final List<String> 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));
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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));
|
||||
|
@ -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 ();
|
||||
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 ();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Pi extends ConstantFunction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Pi (Cell cell, String text)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
|
@ -6,7 +6,9 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Range implements Iterable<Address>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// 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<Address>
|
||||
|
||||
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<Address>
|
||||
throw new IllegalArgumentException (rangeText);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void populateRange ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
range.add (from);
|
||||
cell.getCell (from);
|
||||
@ -62,39 +68,53 @@ class Range implements Iterable<Address>
|
||||
from = tempFrom;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
static boolean isRange (String text)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return rangePattern.matcher (text).matches ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isHorizontal ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return isHorizontal;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isVertical ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return !isHorizontal;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<Address> 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)
|
||||
{
|
||||
|
@ -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<Integer, Cell> 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++)
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 ());
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
interface Value extends Iterable<Value>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
enum ValueType
|
||||
{
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -4,12 +4,16 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ValueList implements Iterable<Value>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ValueList implements Iterable<Value>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<Value> 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<Value>
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public boolean hasRange ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return hasRange;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Value get (int index)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return values.get (index);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public int size ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return values.size ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<Value> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return values.iterator ();
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user