public class PostfixMathCommand extends java.lang.Object implements PostfixMathCommandI
It includes a numberOfParameters member, that is checked when parsing the expression. This member should be initialized to an appropriate value for all classes extending this class. If an arbitrary number of parameters should be allowed, initialize this member to -1.
Modifier and Type | Field and Description |
---|---|
protected int |
curNumberOfParameters
Number of parameters to be used for the next run() invocation.
|
protected int |
numberOfParameters
Number of parameters a the function requires.
|
Constructor and Description |
---|
PostfixMathCommand()
Creates a new PostfixMathCommand class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Checks the number of parameters of the function.
|
protected void |
checkStack(java.util.Stack inStack)
Check whether the stack is not null, throw a ParseException if it is.
|
int |
getNumberOfParameters()
Return the required number of parameters.
|
void |
run(java.util.Stack s)
Throws an exception because this method should never be called under
normal circumstances.
|
void |
setCurNumberOfParameters(int n)
Sets the number of current number of parameters used in the next call
of run().
|
protected int numberOfParameters
protected int curNumberOfParameters
public PostfixMathCommand()
protected void checkStack(java.util.Stack inStack) throws ParseException
ParseException
public int getNumberOfParameters()
getNumberOfParameters
in interface PostfixMathCommandI
public void setCurNumberOfParameters(int n)
setCurNumberOfParameters
in interface PostfixMathCommandI
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface PostfixMathCommandI
n
- number of parameters function will be called with.public void run(java.util.Stack s) throws ParseException
run
in interface PostfixMathCommandI
ParseException
http://www.singularsys.com/jep Copyright © 2007 Singular Systems