jmathlib.core.tokens
Class FunctionToken

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.FunctionToken
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ErrorCodes, TokenConstants

public class FunctionToken
extends OperandToken

Class used to represent any functions used in the expression

See Also:
Serialized Form

Field Summary
 boolean evaluationLockB
           
 
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
FunctionToken(java.lang.String _name)
          constructor for function tokens
FunctionToken(java.lang.String _name, OperandToken _firstParameter)
          constructor for function tokens
FunctionToken(java.lang.String _name, OperandToken[] _parameters)
          constructor for function tokens
 
Method Summary
 boolean equals(java.lang.Object obj)
          Tests if an object is equal to this function
 OperandToken evaluate(Token[] _operands)
          Executes the function referenced by this token
 java.lang.String getName()
          Getter method,
 OperandToken getOperand(int index)
          Return one of the operands
 OperandToken[] getOperands()
          Return all operands
 boolean isEvaluated()
          Getter method,
 boolean isScript()
          Getter method,
 void setNoOfLeftHandArguments(int _number)
          Sets the number of left-hand arguments of the function (e.g.)
 void setOperand(OperandToken _operand)
          Set first operand of this function
 void setOperands(OperandToken[] _operands)
          Set operands of this function
 java.lang.String toString()
          Convert the object into 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
 
Methods inherited from class jmathlib.core.interpreter.RootObject
clone, getContextList, getDebug, getFunctionManager, getGlobalVariables, getGraphicsManager, getInterpreter, getPluginsManager, getVariable, getVariables, getWorkingDirectory, setConstants, setDebug, setWorkingDirectory, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

evaluationLockB

public boolean evaluationLockB
Constructor Detail

FunctionToken

public FunctionToken(java.lang.String _name)
constructor for function tokens

Parameters:
_name - = the name of the function

FunctionToken

public FunctionToken(java.lang.String _name,
                     OperandToken _firstParameter)
constructor for function tokens

Parameters:
_name - = the name of the function
_param - = the first argument

FunctionToken

public FunctionToken(java.lang.String _name,
                     OperandToken[] _parameters)
constructor for function tokens

Parameters:
_name - = the name of the function
_param - = the parameters of the function
Method Detail

setNoOfLeftHandArguments

public void setNoOfLeftHandArguments(int _number)
Sets the number of left-hand arguments of the function (e.g.) [a,b,c]=some_function will return set a "3"

Parameters:
_number - = the number of left hand arguments

getOperand

public OperandToken getOperand(int index)
Return one of the operands

Parameters:
index - = index of operand
Returns:
operand = requested operand

getOperands

public OperandToken[] getOperands()
Return all operands

Returns:
operands = all operands of this function

setOperands

public void setOperands(OperandToken[] _operands)
Set operands of this function

Parameters:
_operands - = operands of this function

setOperand

public void setOperand(OperandToken _operand)
Set first operand of this function

Parameters:
_operand - = first operand of this function

evaluate

public OperandToken evaluate(Token[] _operands)
Executes the function referenced by this token

Specified by:
evaluate in class Token
Parameters:
operands - = the functions operands
Returns:
the result of the function as an OperandToken

isScript

public boolean isScript()
Getter method,

Returns:
true is the function is not a function but an m-script file

isEvaluated

public boolean isEvaluated()
Getter method,

Returns:
true is the function has been evaluated

getName

public java.lang.String getName()
Getter method,

Returns:
the functions name

equals

public boolean equals(java.lang.Object obj)
Tests if an object is equal to this function

Overrides:
equals in class java.lang.Object
Parameters:
obj - = object to test if obj is an instance of Function or Function token then it compares the name of obj to the functions name otherwise it calls the superclasses version
Returns:
true if they are equal

toString

public java.lang.String toString()
Description copied from class: RootObject
Convert the object into a string

Specified by:
toString in class Token
Returns:
the function as a string