spreadsheet
Class Function
java.lang.Object
|
+--spreadsheet.Function
- Direct Known Subclasses:
- AddFunction, AverageFunction, DivideFunction, MinusFunction, MultiplyFunction, PiFunction, StdevFunction
- public abstract class Function
- extends java.lang.Object
- implements java.io.Serializable, java.lang.Cloneable
- See Also:
- Serialized Form
Constructor Summary |
Function(Spreadsheet ss)
Needs the spreadsheet in case expression contains references to
other spreadsheet cells
Must declare as 'public' for external subclasses to package to
be allowed to use. |
Method Summary |
protected abstract float |
calculate()
Every subclass must define calculate (Enumeration en) |
float |
calculateFunction(java.util.Enumeration args)
Calculates the given function given an enumeration of arguments
because we can have nested functions, like (+ (+ 1 2) (+ 3 4)) we need
to evaluate each function in its own object. |
boolean |
hasMoreArguments()
|
float |
nextArgument()
Returns the next argument for this function |
java.lang.String |
nextStringArgument()
Returns the next argument for this function as a String |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Function
public Function(Spreadsheet ss)
- Needs the spreadsheet in case expression contains references to
other spreadsheet cells
Must declare as 'public' for external subclasses to package to
be allowed to use.
hasMoreArguments
public boolean hasMoreArguments()
nextArgument
public float nextArgument()
throws FunctionException
- Returns the next argument for this function
- Throws:
- FunctionException - if an argument is an unknown function
nextStringArgument
public java.lang.String nextStringArgument()
throws FunctionException
- Returns the next argument for this function as a String
- Throws:
- FunctionException - if an argument is an unknown function
calculate
protected abstract float calculate()
throws FunctionException
- Every subclass must define calculate (Enumeration en)
- Throws:
- FunctionException - if an argument is an unknown function
calculateFunction
public float calculateFunction(java.util.Enumeration args)
throws FunctionException
- Calculates the given function given an enumeration of arguments
because we can have nested functions, like (+ (+ 1 2) (+ 3 4)) we need
to evaluate each function in its own object.
- Throws:
- FunctionException - if an argument is an unknown function