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

51 lines
1.3 KiB
Java
Raw Normal View History

2016-03-07 04:37:01 +00:00
package com.bytezone.diskbrowser.visicalc;
2017-02-25 03:56:22 +00:00
import java.util.Iterator;
abstract class Function extends AbstractValue implements Iterable<Value>
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-18 00:24:05 +00:00
"@ISNA(", "@LOG10(", "@LOOKUP(", "@LN(", "@MIN(", "@MAX(", "@NA", "@NPV(", "@OR(",
2017-03-17 23:57:48 +00:00
"@PI", "@SIN(", "@SUM(", "@SQRT(", "@TAN(", "@TRUE" };
2016-03-14 08:58:54 +00:00
protected final Sheet parent;
2017-03-14 11:28:52 +00:00
protected final Cell cell;
2016-03-17 04:40:43 +00:00
protected String functionName;
2016-03-14 08:58:54 +00:00
protected String functionText;
2017-02-25 03:56:22 +00:00
protected String fullText;
2016-03-16 06:15:39 +00:00
Function (Cell cell, String text)
2016-03-09 10:38:53 +00:00
{
2017-02-25 03:56:22 +00:00
super ("Function");
this.parent = cell.getParent ();
2017-03-14 11:28:52 +00:00
this.cell = cell;
2017-02-25 03:56:22 +00:00
fullText = 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
{
functionName = "";
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
}
2017-02-25 03:56:22 +00:00
@Override
public Iterator<Value> iterator ()
{
return values.iterator ();
}
2016-03-09 10:38:53 +00:00
@Override
public String toString ()
{
2016-03-17 04:40:43 +00:00
return String.format ("Function: %s %s", functionName, functionText);
2016-03-09 10:38:53 +00:00
}
2016-03-07 04:37:01 +00:00
}