lt.monarch.math
Class FormulaTokenizer

java.lang.Object
  extended by lt.monarch.math.AbstractTokenizer
      extended by lt.monarch.math.FormulaTokenizer

public class FormulaTokenizer
extends AbstractTokenizer

Formula tokenizer class, which splits the formula into tokens and helps to determine if the token is a number, operator, function, varibale or constant.


Field Summary
Modifier and Type Field and Description
 
Fields inherited from class lt.monarch.math.AbstractTokenizer
token
 
Constructor Summary
Constructor and Description
FormulaTokenizer(java.lang.String formula)
          Formula tokenizer constructor
 
Method Summary
Modifier and Type Method and Description
 void dispose()
          Disposes the tokenizer
protected  void finalize()
           
 int getPosition()
          Returns the position of the tokenizer.
 java.lang.String getPreviousToken()
          Return the previous token.
 boolean hasMoreTokens()
          Checks if the string has more tokens
 boolean isConstant()
          Checks if the last token is the constant.
 boolean isFunction()
          Checks if the last token is the function.
 boolean isNumber()
          Checks if the last token is the number.
 boolean isOperator()
          Checks if the last token is the operator.
 boolean isVariable()
          Checks if the token is the variable.
 java.lang.String nextToken()
          Returns next token
 
Methods inherited from class lt.monarch.math.AbstractTokenizer
isLeftBracket, isRightBracket
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormulaTokenizer

public FormulaTokenizer(java.lang.String formula)
Formula tokenizer constructor

Parameters:
formula - Formula string which has to be tokenized.
Method Detail

hasMoreTokens

public boolean hasMoreTokens()
Description copied from class: AbstractTokenizer
Checks if the string has more tokens

Specified by:
hasMoreTokens in class AbstractTokenizer
Returns:
true if has more tokens

nextToken

public java.lang.String nextToken()
Description copied from class: AbstractTokenizer
Returns next token

Specified by:
nextToken in class AbstractTokenizer
Returns:
Next token

isOperator

public boolean isOperator()
Checks if the last token is the operator.

Returns:
True is the last token is operator.

isNumber

public boolean isNumber()
Checks if the last token is the number.

Returns:
True is the last token is number.

isFunction

public boolean isFunction()
Checks if the last token is the function.

Returns:
True is the last token is function.

isConstant

public boolean isConstant()
Checks if the last token is the constant.

Returns:
True is the last token is constant.

isVariable

public boolean isVariable()
Checks if the token is the variable.

Returns:
True if the token is variable.

getPreviousToken

public java.lang.String getPreviousToken()
Description copied from class: AbstractTokenizer
Return the previous token.

Specified by:
getPreviousToken in class AbstractTokenizer
Returns:
Previous token.

getPosition

public int getPosition()
Description copied from class: AbstractTokenizer
Returns the position of the tokenizer.

Specified by:
getPosition in class AbstractTokenizer
Returns:
The position of the tokenizer in the original string.

dispose

public void dispose()
Description copied from class: AbstractTokenizer
Disposes the tokenizer

Specified by:
dispose in class AbstractTokenizer

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable