dmolony-DiskBrowser/src/com/bytezone/diskbrowser/visicalc/Function.java

52 lines
1.9 KiB
Java
Raw Permalink Normal View History

2016-03-07 04:37:01 +00:00
package com.bytezone.diskbrowser.visicalc;
2020-02-10 11:05:40 +00:00
// -----------------------------------------------------------------------------------//
2017-03-20 01:45:14 +00:00
abstract class Function extends AbstractValue
2020-02-10 11:05:40 +00:00
// -----------------------------------------------------------------------------------//
2016-03-07 04:37:01 +00:00
{
2017-03-17 23:57:48 +00:00
static final String[] functionList =
{ "@ABS(", "@ACOS(", "@AND(", "@ASIN(", "@ATAN(", "@AVERAGE(", "@COUNT(",
"@CHOOSE(", "@COS(", "@ERROR", "@EXP(", "@FALSE", "@IF(", "@INT(", "@ISERROR(",
2017-03-25 21:58:10 +00:00
"@ISNA(", "@LOG10(", "@LOOKUP(", "@LN(", "@MIN(", "@MAX(", "@NA", "@NOT(",
"@NPV(", "@OR(", "@PI", "@SIN(", "@SUM(", "@SQRT(", "@TAN(", "@TRUE" };
2017-03-17 23:57:48 +00:00
2017-03-20 01:45:14 +00:00
protected final String functionName;
protected final String functionText;
2017-03-19 01:03:57 +00:00
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
Function (Cell cell, String text)
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2016-03-09 10:38:53 +00:00
{
2017-03-23 13:30:41 +00:00
super (cell, text);
2016-03-11 01:52:22 +00:00
// get function's parameter string
2016-03-10 02:39:23 +00:00
int pos = text.indexOf ('(');
2016-03-14 08:58:54 +00:00
if (pos >= 0)
2016-03-17 04:40:43 +00:00
{
functionName = text.substring (0, pos);
2016-03-16 06:15:39 +00:00
functionText = text.substring (pos + 1, text.length () - 1);
2016-03-17 04:40:43 +00:00
}
2016-03-16 06:15:39 +00:00
else
2016-03-17 04:40:43 +00:00
{
2017-03-20 01:45:14 +00:00
functionName = text;
2016-03-16 06:15:39 +00:00
functionText = "";
2016-03-17 04:40:43 +00:00
}
2016-03-16 06:15:39 +00:00
}
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2016-03-09 10:38:53 +00:00
@Override
public String toString ()
2020-02-10 11:05:40 +00:00
// ---------------------------------------------------------------------------------//
2016-03-09 10:38:53 +00:00
{
2017-03-23 13:30:41 +00:00
StringBuilder text = new StringBuilder ();
2017-03-24 02:00:11 +00:00
text.append (String.format ("%s%n", LINE));
text.append (
String.format (FMT4, "Function", getFullText (), valueType, getValueText (this)));
for (Value value : values)
{
text.append (String.format (FMT4, value.getType (), value.getFullText (),
value.getValueType (), getValueText (value)));
}
2017-03-23 13:30:41 +00:00
return text.toString ();
2016-03-09 10:38:53 +00:00
}
2016-03-07 04:37:01 +00:00
}