lt.monarch.math
Class LogicalTokenizer

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

public class LogicalTokenizer
extends AbstractTokenizer

Tokenizer for the logical expression (formula). Delimiters for this tokenizer are <, >, <=, >=, =, ==, !=, !, (, ), &&, ||, ##

## symbol corresponds to xor operator.

&& - and operator.

|| - or operator.

! - not operator.

< - less operator.

> - more operator.


Field Summary
Modifier and Type Field and Description
 
Fields inherited from class lt.monarch.math.AbstractTokenizer
token
 
Constructor Summary
Constructor and Description
LogicalTokenizer(java.lang.String formula)
          Logical 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 isExpression()
          Checks if the token is numerical formula (not logical)
 boolean isNegation()
          Checks if the last token is negation
 boolean isOperator()
          Checks if current token is operator
 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

LogicalTokenizer

public LogicalTokenizer(java.lang.String formula)
                 throws java.lang.Exception
Logical tokenizer constructor

Parameters:
formula - logical expression (formula)
Throws:
java.lang.Exception - throws exception if cannot tokenize the string
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

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.

getPreviousToken

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

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

dispose

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

Specified by:
dispose in class AbstractTokenizer

isExpression

public boolean isExpression()
Checks if the token is numerical formula (not logical)

Returns:
true if it has numeric value

isOperator

public boolean isOperator()
Checks if current token is operator

Returns:
true if current token is operator

isNegation

public boolean isNegation()
Checks if the last token is negation

Returns:
true if negation is the last token

finalize

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