mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-26 23:51:57 +00:00
being assertive
This commit is contained in:
parent
76a220acd3
commit
eff78e0108
@ -8,6 +8,8 @@ public class Abs extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ABS(") : text;
|
||||
|
||||
source = new Expression (parent, cell, functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ public class Acos extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ACOS(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ class And extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@AND(") : text;
|
||||
|
||||
String remainder = functionText;
|
||||
while (true)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@ public class Asin extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ASIN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ public class Atan extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ATAN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ public class Average extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@AVERAGE(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
isRange = functionText.indexOf ("...") > 0;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ public class Choose extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@CHOOSE(") : text;
|
||||
|
||||
// int pos = functionText.indexOf (',');
|
||||
// sourceText = functionText.substring (0, pos);
|
||||
sourceText = Expression.getParameter (functionText);
|
||||
|
@ -8,6 +8,8 @@ public class Cos extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@COS(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ class Count extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@COUNT(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
isRange = functionText.indexOf ("...") > 0;
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ class Error extends Function
|
||||
public Error (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ERROR") : text;
|
||||
|
||||
valueType = ValueType.ERROR;
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ public class Exp extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@EXP(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ public class False extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.equals ("@FALSE") : text;
|
||||
|
||||
value = 0;
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ class If extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@IF(") : text;
|
||||
|
||||
conditionText = Expression.getParameter (functionText);
|
||||
textTrue =
|
||||
Expression.getParameter (functionText.substring (conditionText.length () + 1));
|
||||
|
@ -8,6 +8,8 @@ public class Int extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@INT(") : text;
|
||||
|
||||
source = new Expression (parent, cell, functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ class IsError extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ISERROR(") : text;
|
||||
|
||||
expression = new Expression (parent, cell, functionText).reduce ();
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ public class IsNa extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@ISNA(") : text;
|
||||
|
||||
expression = new Expression (parent, cell, functionText).reduce ();
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ public class Ln extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@LN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ public class Log10 extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@LOG10(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -11,17 +11,14 @@ class Lookup extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
// int pos = text.indexOf (',');
|
||||
assert text.startsWith ("@LOOKUP(") : text;
|
||||
|
||||
sourceText = Expression.getParameter (functionText);
|
||||
|
||||
// sourceText = text.substring (8, pos);
|
||||
source = new Expression (parent, cell, sourceText);
|
||||
values.add (source);
|
||||
|
||||
// rangeText = text.substring (pos + 1, text.length () - 1);
|
||||
rangeText = functionText.substring (sourceText.length () + 1);
|
||||
range = new Range (parent, cell, rangeText);
|
||||
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,6 +8,8 @@ class Max extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@MAX(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ class Min extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@MIN(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,9 @@ public class Na extends Function
|
||||
public Na (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.equals ("@NA") : text;
|
||||
|
||||
valueType = ValueType.NA;
|
||||
}
|
||||
}
|
@ -14,14 +14,14 @@ public class Npv extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
int pos = text.indexOf (',');
|
||||
valueText = text.substring (5, pos);
|
||||
rangeText = text.substring (pos + 1, text.length () - 1);
|
||||
assert text.startsWith ("@NPV(") : text;
|
||||
|
||||
valueText = Expression.getParameter (functionText);
|
||||
rateExp = new Expression (parent, cell, valueText);
|
||||
range = new Range (parent, cell, rangeText);
|
||||
|
||||
values.add (rateExp);
|
||||
|
||||
rangeText = functionText.substring (valueText.length () + 1);
|
||||
range = new Range (parent, cell, rangeText);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,14 +11,13 @@ class Or extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@OR(") : text;
|
||||
|
||||
String remainder = functionText;
|
||||
while (true)
|
||||
{
|
||||
String parameter = Expression.getParameter (remainder);
|
||||
// System.out.printf ("cond: [%s]%n", parameter);
|
||||
conditions.add (new Condition (parent, cell, parameter));
|
||||
// System.out.printf (" [%s]%n", remainder);
|
||||
// System.out.printf (" [%s]%n", parameter);
|
||||
if (remainder.length () == parameter.length ())
|
||||
break;
|
||||
remainder = remainder.substring (parameter.length () + 1);
|
||||
|
@ -7,6 +7,9 @@ class Pi extends Function
|
||||
super (cell, text);
|
||||
|
||||
value = Math.PI;
|
||||
|
||||
assert text.equals ("@PI") : text;
|
||||
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
}
|
@ -500,129 +500,118 @@ public class Sheet
|
||||
return new Error (cell, "@ERROR");
|
||||
}
|
||||
|
||||
String functionName = "";
|
||||
int functionId = -1;
|
||||
for (int i = 0; i < Function.functionList.length; i++)
|
||||
if (text.startsWith (Function.functionList[i]))
|
||||
{
|
||||
functionId = i;
|
||||
functionTotals[i]++;
|
||||
functionName = Function.functionList[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (text.charAt (1) == 'A')
|
||||
if (functionName.isEmpty ())
|
||||
{
|
||||
if (text.startsWith ("@ABS("))
|
||||
System.out.printf ("Unknown function: [%s]%n", text);
|
||||
return new Error (cell, "@ERROR");
|
||||
}
|
||||
|
||||
switch (functionId)
|
||||
{
|
||||
case 0:
|
||||
return new Abs (cell, text);
|
||||
|
||||
if (text.startsWith ("@ACOS("))
|
||||
case 1:
|
||||
return new Acos (cell, text);
|
||||
|
||||
if (text.startsWith ("@AND("))
|
||||
case 2:
|
||||
return new And (cell, text);
|
||||
|
||||
if (text.startsWith ("@ASIN("))
|
||||
case 3:
|
||||
return new Asin (cell, text);
|
||||
|
||||
if (text.startsWith ("@ATAN("))
|
||||
case 4:
|
||||
return new Atan (cell, text);
|
||||
|
||||
if (text.startsWith ("@AVERAGE("))
|
||||
case 5:
|
||||
return new Average (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'C')
|
||||
{
|
||||
if (text.startsWith ("@COUNT("))
|
||||
|
||||
case 6:
|
||||
return new Count (cell, text);
|
||||
|
||||
if (text.startsWith ("@CHOOSE("))
|
||||
case 7:
|
||||
return new Choose (cell, text);
|
||||
|
||||
if (text.startsWith ("@COS("))
|
||||
case 8:
|
||||
return new Cos (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'E')
|
||||
{
|
||||
if (text.startsWith ("@ERROR"))
|
||||
|
||||
case 9:
|
||||
return new Error (cell, text);
|
||||
|
||||
if (text.startsWith ("@EXP("))
|
||||
case 10:
|
||||
return new Exp (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'F')
|
||||
{
|
||||
if (text.startsWith ("@FALSE"))
|
||||
|
||||
case 11:
|
||||
return new False (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'I')
|
||||
{
|
||||
if (text.startsWith ("@IF("))
|
||||
|
||||
case 12:
|
||||
return new If (cell, text);
|
||||
|
||||
if (text.startsWith ("@INT("))
|
||||
case 13:
|
||||
return new Int (cell, text);
|
||||
|
||||
if (text.startsWith ("@ISERROR("))
|
||||
case 14:
|
||||
return new IsError (cell, text);
|
||||
|
||||
if (text.startsWith ("@ISNA("))
|
||||
case 15:
|
||||
return new IsNa (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'L')
|
||||
{
|
||||
if (text.startsWith ("@LOG10("))
|
||||
|
||||
case 16:
|
||||
return new Log10 (cell, text);
|
||||
|
||||
if (text.startsWith ("@LOOKUP("))
|
||||
case 17:
|
||||
return new Lookup (cell, text);
|
||||
|
||||
if (text.startsWith ("@LN("))
|
||||
case 18:
|
||||
return new Ln (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'M')
|
||||
{
|
||||
if (text.startsWith ("@MIN("))
|
||||
|
||||
case 19:
|
||||
return new Min (cell, text);
|
||||
|
||||
if (text.startsWith ("@MAX("))
|
||||
case 20:
|
||||
return new Max (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'N')
|
||||
{
|
||||
if (text.equals ("@NA"))
|
||||
|
||||
case 21:
|
||||
return new Na (cell, text);
|
||||
|
||||
if (text.startsWith ("@NPV("))
|
||||
case 22:
|
||||
return new Npv (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'O')
|
||||
{
|
||||
if (text.startsWith ("@OR("))
|
||||
|
||||
case 23:
|
||||
return new Or (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'P')
|
||||
{
|
||||
if (text.startsWith ("@PI"))
|
||||
|
||||
case 24:
|
||||
return new Pi (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'S')
|
||||
{
|
||||
if (text.startsWith ("@SIN("))
|
||||
|
||||
case 25:
|
||||
return new Sin (cell, text);
|
||||
|
||||
if (text.startsWith ("@SUM("))
|
||||
case 26:
|
||||
return new Sum (cell, text);
|
||||
|
||||
if (text.startsWith ("@SQRT("))
|
||||
case 27:
|
||||
return new Sqrt (cell, text);
|
||||
}
|
||||
else if (text.charAt (1) == 'T')
|
||||
{
|
||||
if (text.startsWith ("@TAN("))
|
||||
|
||||
case 28:
|
||||
return new Tan (cell, text);
|
||||
|
||||
if (text.startsWith ("@TRUE"))
|
||||
case 29:
|
||||
return new True (cell, text);
|
||||
}
|
||||
|
||||
System.out.printf ("Unknown function: [%s]%n", text);
|
||||
return new Error (cell, "@ERROR");
|
||||
default:
|
||||
System.out.printf ("Unknown function: [%s]%n", text);
|
||||
return new Error (cell, "@ERROR");
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ public class Sin extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@SIN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -7,7 +7,10 @@ public class Sqrt extends Function
|
||||
Sqrt (Cell cell, String text)
|
||||
{
|
||||
super (cell, text);
|
||||
source = new Expression (parent, cell, text.substring (5, text.length () - 1));
|
||||
|
||||
assert text.startsWith ("@SQRT(") : text;
|
||||
|
||||
source = new Expression (parent, cell, functionText);
|
||||
values.add (source);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ class Sum extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@SUM(") : text;
|
||||
|
||||
list = new ValueList (parent, cell, functionText);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ public class Tan extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.startsWith ("@TAN(") : text;
|
||||
|
||||
v = new Expression (parent, cell, functionText).reduce ();
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ public class True extends Function
|
||||
{
|
||||
super (cell, text);
|
||||
|
||||
assert text.equals ("@TRUE") : text;
|
||||
|
||||
value = 1;
|
||||
valueType = ValueType.VALUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user