|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.singularsys.jep.functions.PostfixMathCommand com.singularsys.jep.functions.ArrayFunctionBase
public abstract class ArrayFunctionBase
Base class for functions that operate on arrays such as Average, MinMax,
and VSum. The shared functionality such as array flattening is implemented
here. In the run() method, before calling calc(), Vectors and nested Vectors
are flattened so 1,[2,[3, 4]]
becomes [1, 2, 3, 4]
which is passed in to the calc method as a List<Object>.
Nested Class Summary | |
---|---|
static class |
ArrayFunctionBase.ZeroLengthErrorBehaviour
How to respond to a zero length array as argument |
Field Summary |
---|
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand |
---|
curNumberOfParameters, name, NaN, numberOfParameters |
Constructor Summary | |
---|---|
ArrayFunctionBase()
Default the number of parameters to any number of params (-1). |
Method Summary | |
---|---|
protected abstract java.lang.Object |
calc(java.util.List<java.lang.Object> l)
Abstract method for performing the array calculation. |
boolean |
checkNumberOfParameters(int n)
Must have one or more parameter |
ArrayFunctionBase.ZeroLengthErrorBehaviour |
getZeroLengthErrorBehaviour()
|
void |
run(java.util.Stack<java.lang.Object> stack)
Calls the calc method after concatenating all elements into list. |
void |
setZeroLengthErrorBehaviour(ArrayFunctionBase.ZeroLengthErrorBehaviour zeroLengthErrorBehaviour)
Sets how to respond to arguments with zero length arrays. |
protected void |
throwAtLeastOneExcep()
|
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand |
---|
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArrayFunctionBase()
Method Detail |
---|
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.
public void run(java.util.Stack<java.lang.Object> stack) throws EvaluationException
EvaluationException
protected abstract java.lang.Object calc(java.util.List<java.lang.Object> l) throws EvaluationException
l
- The list to operate on.
EvaluationException
protected void throwAtLeastOneExcep() throws EvaluationException
EvaluationException
public ArrayFunctionBase.ZeroLengthErrorBehaviour getZeroLengthErrorBehaviour()
public void setZeroLengthErrorBehaviour(ArrayFunctionBase.ZeroLengthErrorBehaviour zeroLengthErrorBehaviour)
zeroLengthErrorBehaviour
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |