com.singularsys.jep.functions
Class Ele

java.lang.Object
  extended by com.singularsys.jep.functions.PostfixMathCommand
      extended by com.singularsys.jep.functions.Ele
All Implemented Interfaces:
LValueI, PostfixMathCommandI, java.io.Serializable

public class Ele
extends PostfixMathCommand
implements LValueI

Function which allows array access using the a[3] notation on left and right hand side. The first element is indexed with 1. a=[4,3,2,1]; a[2]; // Returns 2 a[2]=5; // Sets the 2nd element of a to 5. So a is now [4,5,2,1] b=[[1,2,3],[4,5,6]]; b[2][3]; // returns 6 b[2][3]=7; // sets 3rd element of 2nd row to 7 (only works with the configurable parser)

Author:
Richard Morris
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, numberOfParameters
 
Constructor Summary
Ele()
          Element access with mathematical convention, first element has index 1
Ele(boolean javaIndex)
          Element access with mathematical convention, first element has index 1
 
Method Summary
 boolean checkNumberOfParameters(int n)
          Checks the number of parameters of the function.
 void run(java.util.Stack<java.lang.Object> s)
          Run the function on the stack.
 void set(Evaluator pv, Node node, java.lang.Object value)
          Performs appropriate action to set an LValue.
 
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
checkStack, getNumberOfParameters, setCurNumberOfParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ele

public Ele()
Element access with mathematical convention, first element has index 1


Ele

public Ele(boolean javaIndex)
Element access with mathematical convention, first element has index 1

Parameters:
javaIndex -
Method Detail

checkNumberOfParameters

public boolean checkNumberOfParameters(int n)
Description copied from class: PostfixMathCommand
Checks the number of parameters of the function. Functions which set numberOfParameter=-1 should overload this method

Specified by:
checkNumberOfParameters in interface PostfixMathCommandI
Overrides:
checkNumberOfParameters in class PostfixMathCommand
Parameters:
n - number of parameters function will be called with.
Returns:
false if an illegal number of parameters is supplied, true otherwise.

set

public void set(Evaluator pv,
                Node node,
                java.lang.Object value)
         throws EvaluationException
Description copied from interface: LValueI
Performs appropriate action to set an LValue.

Specified by:
set in interface LValueI
Parameters:
pv - a pointer to the evaluator. The pv.eval() method can be used to evaluate the children of the node.
node - The top node for the LValue
value - the value obtained by evaluating the right hand side.
Throws:
EvaluationException

run

public void run(java.util.Stack<java.lang.Object> s)
         throws EvaluationException
Description copied from interface: PostfixMathCommandI
Run the function on the stack. Pops the arguments from the stack, and pushes the result on the top of the stack.

Specified by:
run in interface PostfixMathCommandI
Throws:
EvaluationException


Copyright © 2008 Singular Systems http://www.singularsys.com/jep