jmathlib.core.tokens
Class IfThenOperatorToken

java.lang.Object
  extended by jmathlib.core.interpreter.RootObject
      extended by jmathlib.core.tokens.Token
          extended by jmathlib.core.tokens.OperandToken
              extended by jmathlib.core.tokens.CommandToken
                  extended by jmathlib.core.tokens.IfThenOperatorToken
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, ErrorCodes, TokenConstants

public class IfThenOperatorToken
extends CommandToken
implements java.util.Collection

Used to implement if-then-else operations within an expression

See Also:
Serialized Form

Field Summary
(package private)  java.util.ArrayList conditions
          a list of the conditions
 
Fields inherited from class jmathlib.core.tokens.Token
priority
 
Fields inherited from interface jmathlib.core.constants.TokenConstants
ADDSUB_PRIORITY, AND_PRIORITY, ANDAND_PRIORITY, ASSIGN_PRIORITY, BRACKET_PRIORITY, COMPARE_PRIORITY, CONCAT, MATRIX, MULDIV_PRIORITY, OR_PRIORITY, OROR_PRIORITY, PARAMETER, POWER_PRIORITY, RELATION_PRIORITY, SINGLE, ttDelimiter, ttNotSet, ttOperand, ttOperator
 
Fields inherited from interface jmathlib.core.constants.ErrorCodes
ERR_BRACKET_OPEN, ERR_BRACKET_ORDER, ERR_FUNCTION_NOT_FOUND, ERR_FUNCTION_NOT_IMPLEMENTED, ERR_INSUFFICIENT_PARAMETERS, ERR_INVALID_PARAMETER, ERR_LVALUE_REQUIRED, ERR_MATRIX_SINGULAR, ERR_NOT_SQUARE_MATRIX, ERR_OPNOTSUPPORTED, ERR_TOO_MANY_PARAMETERS, ERR_USER_ERROR, ERR_VARIABLE_NOTDEFINED, OK, OK_FUNCTION_PROCESS
 
Constructor Summary
IfThenOperatorToken(OperandToken _ifRelation, OperandToken _ifCode)
          Constructor setting ifRelation and ifCode
IfThenOperatorToken(OperandToken _ifRelation, OperandToken _ifCode, OperandToken _elseCode)
          Constructor setting ifRelation and ifCode and elseCode
 
Method Summary
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 void addCondition(OperandToken _ifRelation, OperandToken _ifCode)
          Add another relation to the if expression
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 OperandToken evaluate(Token[] operands, GlobalValues globals)
          evaluates the operator
 Expression getElseCode()
           
 Expression getIfCode()
           
 Expression getIfRelation()
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
          return an iterator for traversing the condition objects
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 int size()
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] wtf)
           
 java.lang.String toString()
          Convert the operator to a string
 
Methods inherited from class jmathlib.core.tokens.OperandToken
add, asArray, Children, ctranspose, derivative, divide, expand, factorial, integral, isLeaf, isNull, isNumeric, leftDivide, mpower, mPower, multiply, negate, power, scalarDivide, scalarLeftDivide, scalarMultiply, simplify, subst, subtract, transpose
 
Methods inherited from class jmathlib.core.tokens.Token
isDisplayResult, setDisplayResult, toMathMlString, toString
 
Methods inherited from class jmathlib.core.interpreter.RootObject
clone, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

conditions

java.util.ArrayList conditions
a list of the conditions

Constructor Detail

IfThenOperatorToken

public IfThenOperatorToken(OperandToken _ifRelation,
                           OperandToken _ifCode)
Constructor setting ifRelation and ifCode

Parameters:
_ifRelation - = the test relation
_ifCode - = the code to execute if the test is true

IfThenOperatorToken

public IfThenOperatorToken(OperandToken _ifRelation,
                           OperandToken _ifCode,
                           OperandToken _elseCode)
Constructor setting ifRelation and ifCode and elseCode

Parameters:
_ifRelation - = the test relation
_ifCode - = the code to execute if the test is true
_elseCode - = the code to execute if the test is false
Method Detail

addCondition

public void addCondition(OperandToken _ifRelation,
                         OperandToken _ifCode)
Add another relation to the if expression

Parameters:
_ifRelation - = the test
_ifCode - = the code to execute

getIfRelation

public Expression getIfRelation()

getIfCode

public Expression getIfCode()

getElseCode

public Expression getElseCode()

evaluate

public OperandToken evaluate(Token[] operands,
                             GlobalValues globals)
evaluates the operator

Overrides:
evaluate in class CommandToken
Parameters:
operands - = the operators operands
-
Returns:
the result of the test as an OperandToken

toString

public java.lang.String toString()
Convert the operator to a string

Overrides:
toString in class CommandToken
Returns:
the operator as a string

iterator

public java.util.Iterator iterator()
return an iterator for traversing the condition objects

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] wtf)
Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection

clear

public void clear()
Specified by:
clear in interface java.util.Collection

size

public int size()
Specified by:
size in interface java.util.Collection

FOOTER

BOTTOM