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
private  boolean cellB
          true if e.g. a{8}...
private  java.lang.String fieldName
          name for struct
private  boolean limitSwitch
          Boolean indicator if limits are active
private  OperandToken[] limitTokens
          The limits of this variable (e.g. a(2,3:5) )
private  java.lang.String name
          The variable name
 
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)
          return the data of the variable
 boolean equals(OperandToken _data)
          Implement the equals operator to find a VariableToken with the correct name
 OperandToken evaluate(Token[] operands, GlobalValues globals)
          evaluate the token
 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(GlobalValues globals)
          get the variable that this token references
 boolean isCell()
          check if variable is a cell array
 boolean isLimited()
           
 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()
           
 
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, 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
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private java.lang.String name
The variable name


fieldName

private java.lang.String fieldName
name for struct


limitTokens

private OperandToken[] limitTokens
The limits of this variable (e.g. a(2,3:5) )


limitSwitch

private boolean limitSwitch
Boolean indicator if limits are active


cellB

private boolean cellB
true if e.g. a{8}...

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,
                             GlobalValues globals)
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()
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


equals

public boolean equals(java.lang.Object obj)
return the data of the variable

Overrides:
equals in class java.lang.Object

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(GlobalValues globals)
get the variable that this token references


FOOTER

BOTTOM