jmathlib.core.tokens
Class VariableToken

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.DataToken
                  extended by jmathlib.core.tokens.VariableToken
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ErrorCodes, TokenConstants

public class VariableToken
extends DataToken
implements ErrorCodes

Class representing any variables used in an expression

See Also:
Serialized Form

Field Summary
 
Fields inherited from class jmathlib.core.tokens.DataToken
dataType, noElem, sizeA, sizeX, sizeY
 
Fields inherited from class jmathlib.core.tokens.Token
priority
 
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
 
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
 
Constructor Summary
VariableToken(java.lang.String _name)
          constructor containing the variables name
VariableToken(java.lang.String _name, OperandToken[] _limits)
          constructor containing the variables name and limiting arguments
VariableToken(java.lang.String _name, OperandToken[] _limits, java.lang.String _type)
          constructor containing the variables name and limiting arguments
VariableToken(java.lang.String _name, java.lang.String _fieldName)
          constructor containing the variables name
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 boolean equals(OperandToken _data)
          Implement the equals operator to find a VariableToken with the correct name
 OperandToken evaluate(Token[] operands)
          evaluate the token
 OperandToken getData()
          return the data of the variable
 java.lang.String getFieldName()
          return the name of the variable
 OperandToken[] getLimits()
          return limits of this variable
 java.lang.String getName()
          return the name of the variable
 Variable getVariable()
          get the variable that this token references
 boolean isCell()
          check if variable is a cell array
 boolean isLimited()
           
 boolean isNumeric()
          Checks if this operand is a numeric value
 boolean isStruct()
          check if variable is a struct
 void setLimits(OperandToken[] _limits)
          set limits for variable (e.g. a(1,3:4) )
 java.lang.String toString()
          Convert the object into a string
 
Methods inherited from class jmathlib.core.tokens.DataToken
checkEqualDimensions, getDataType, getDimensions, getElement, getElement, getElementSized, getNumberOfElements, getSize, getSizeX, getSizeY, setElement, setElement, setSize
 
Methods inherited from class jmathlib.core.tokens.OperandToken
add, asArray, Children, ctranspose, derivative, divide, expand, factorial, integral, isLeaf, isNull, 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
 

Constructor Detail

VariableToken

public VariableToken(java.lang.String _name)
constructor containing the variables name

Parameters:
_name - = the name of the variable

VariableToken

public VariableToken(java.lang.String _name,
                     java.lang.String _fieldName)
constructor containing the variables name

Parameters:
_name - = the name of the variable
_var - = the variable being referenced

VariableToken

public VariableToken(java.lang.String _name,
                     OperandToken[] _limits)
constructor containing the variables name and limiting arguments

Parameters:
_name - = the name of the variable
_operands - = the limits of this variable (e.g. a(1,2:4) )

VariableToken

public VariableToken(java.lang.String _name,
                     OperandToken[] _limits,
                     java.lang.String _type)
constructor containing the variables name and limiting arguments

Parameters:
_name - = the name of the variable
_operands - = the limits of this variable (e.g. a(1,2:4) )
_type - = 'cell' if cell variable
Method Detail

isLimited

public boolean isLimited()
Returns:
true if the variable token has limits

setLimits

public void setLimits(OperandToken[] _limits)
set limits for variable (e.g. a(1,3:4) )

Parameters:
limits - = the limiting operands (DoubleNumberToken, ColonOperator)

getLimits

public OperandToken[] getLimits()
return limits of this variable


evaluate

public OperandToken evaluate(Token[] operands)
Description copied from class: Token
evaluate the token

Specified by:
evaluate in class Token
Parameters:
operands - = an array of RootObject containing the tokens operands
Returns:
the value of the data held within the variable if the variable has not been inisitalised then it returns the variable

equals

public boolean equals(OperandToken _data)
Implement the equals operator to find a VariableToken with the correct name

Parameters:
_data - = the object to match against
Returns:
true if the 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:
either the variable data as a string or the variable name

getName

public java.lang.String getName()
return the name of the variable


getFieldName

public java.lang.String getFieldName()
return the name of the variable


getData

public OperandToken getData()
return the data of the variable


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

isNumeric

public boolean isNumeric()
Checks if this operand is a numeric value

Overrides:
isNumeric in class OperandToken
Returns:
true if this is a number, false if it's an algebraic expression

isStruct

public boolean isStruct()
check if variable is a struct

Returns:

isCell

public boolean isCell()
check if variable is a cell array

Returns:

getVariable

public Variable getVariable()
get the variable that this token references