hussam.math.operations.parser
Class MyParser

java.lang.Object
extended by hussam.math.operations.parser.MyParser
All Implemented Interfaces:
OperationsParser

public class MyParser
extends java.lang.Object
implements OperationsParser

The default implementation for the OperationsParser interface.

Things to note down:
 1- Groups of expressions can be done using these charecter sets:
        { '(' , ')' , '[' , ']' , '{' , '}' }
 2- you can partition the arguments using these character sets:
        { ',' , '¡'}
 3- Logical Operations are: { '<' , '>' , '==' , '<=' , '>=' }
 4- Extended Logical Operations : { '!' , '&' , '|' }
 5- Assingment key: { '=' }

Since:
Version 3

Constructor Summary
MyParser()
           
 
Method Summary
 booleanisCloseParenthesis(char c)
          Returns true if this char indicated a close parenthesis such as ), ], } .
 booleanisCloseParenthesis(java.lang.String word)
          Returns true if this word indicates a close parenthesis such as ), ], } or even END.
 booleanisComma(char c)
          Returns true if the char acts like a partioner in a group.
 booleanisComma(java.lang.String word)
          returns true if this word act as a partition in a group, for example you can have the word AND as a partition for this group.
 booleanisFunction(java.lang.String word)
          Tests for Function name
 booleanisNumber(char c)
          returns true if this char is a Number.
 booleanisNumber(java.lang.String word)
          Tests for number String.
 booleanisOpenParenthesis(char c)
          Returns true if this char is an open Parenthesis. such as (, [, { etc.
 booleanisOpenParenthesis(java.lang.String word)
          Returns true if this String is an open Parenthesis. such as (, [, { or even Start, Begin etc.
 booleanisOperand(char c)
          This implemetation will test if the charected is set in the operands list in the OperatorFactoryDB plus it will test for group charecters.
 booleanisOperand(java.lang.String word)
          Tests for operand String.
 booleanisParenthesis(char c, char c1)
          Returns true of these two chars indicate a pair of parenthesis such as () , [], {}, <> or any other char!
 booleanisParenthesis(java.lang.String word, java.lang.String word1)
          Returns true if these two words indicate a block of code, like Start/End, Begin/Finish.
 booleanisVariable(char c)
          Returns true if this Char is a Variable.
 booleanisVariable(java.lang.String word)
          Tests for Variable name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyParser

public MyParser()
Method Detail

isNumber

public boolean isNumber(char c)
Description copied from interface: OperationsParser
returns true if this char is a Number.

Specified by:
isNumber in interface OperationsParser
Parameters:
c - The charectar
Returns:
True if the char is a number.

isOperand

public boolean isOperand(char c)
This implemetation will test if the charected is set in the operands list in the OperatorFactoryDB plus it will test for group charecters.

Specified by:
isOperand in interface OperationsParser
Parameters:
c - The charectar
Returns:
True if the char is an Operand.

isVariable

public boolean isVariable(char c)
Description copied from interface: OperationsParser
Returns true if this Char is a Variable.

Specified by:
isVariable in interface OperationsParser
Parameters:
c - The charectar
Returns:
True if the char is a Variable name.

isOperand

public boolean isOperand(java.lang.String word)
Description copied from interface: OperationsParser
Tests for operand String.

Specified by:
isOperand in interface OperationsParser
Parameters:
word - name.
Returns:
True if the String is an Operand.

isNumber

public boolean isNumber(java.lang.String word)
Description copied from interface: OperationsParser
Tests for number String.

Specified by:
isNumber in interface OperationsParser
Parameters:
word - name.
Returns:
True if the String is a Number.

isVariable

public boolean isVariable(java.lang.String word)
Description copied from interface: OperationsParser
Tests for Variable name.

Specified by:
isVariable in interface OperationsParser
Parameters:
word - name.
Returns:
True if the String is Variable Name.

isFunction

public boolean isFunction(java.lang.String word)
Description copied from interface: OperationsParser
Tests for Function name

Specified by:
isFunction in interface OperationsParser
Parameters:
word - name.
Returns:
True if the String is a Function name.

isOpenParenthesis

public boolean isOpenParenthesis(java.lang.String word)
Description copied from interface: OperationsParser
Returns true if this String is an open Parenthesis. such as (, [, { or even Start, Begin etc.

Specified by:
isOpenParenthesis in interface OperationsParser
Parameters:
word - the word to be evaluated.
Returns:
true if this indicated an open parenthesis.
See Also:
OperationsParser.isParenthesis(String, String)

isCloseParenthesis

public boolean isCloseParenthesis(java.lang.String word)
Description copied from interface: OperationsParser
Returns true if this word indicates a close parenthesis such as ), ], } or even END.

Specified by:
isCloseParenthesis in interface OperationsParser
Parameters:
word - The word to be evaluated.
Returns:
true if it is an openParenthesis.
See Also:
OperationsParser.isParenthesis(String, String)

isOpenParenthesis

public boolean isOpenParenthesis(char c)
Description copied from interface: OperationsParser
Returns true if this char is an open Parenthesis. such as (, [, { etc.

Specified by:
isOpenParenthesis in interface OperationsParser
Parameters:
c - the char to be evaluated.
Returns:
true if this indicates an open parenthesis char.
See Also:
OperationsParser.isParenthesis(char, char)

isCloseParenthesis

public boolean isCloseParenthesis(char c)
Description copied from interface: OperationsParser
Returns true if this char indicated a close parenthesis such as ), ], } .

Specified by:
isCloseParenthesis in interface OperationsParser
Parameters:
c - the char to be evaluated.
Returns:
true if this indicated a close parenthesis.
See Also:
OperationsParser.isParenthesis(char, char)

isParenthesis

public boolean isParenthesis(java.lang.String word,
                             java.lang.String word1)
Description copied from interface: OperationsParser
Returns true if these two words indicate a block of code, like Start/End, Begin/Finish. or even []/{}/<>!!

Specified by:
isParenthesis in interface OperationsParser
Parameters:
word - The open parenthesis.
word1 - the close parenthesis.
Returns:
true if these two words are an open and a close parenthesis.

isParenthesis

public boolean isParenthesis(char c,
                             char c1)
Description copied from interface: OperationsParser
Returns true of these two chars indicate a pair of parenthesis such as () , [], {}, <> or any other char!

Specified by:
isParenthesis in interface OperationsParser
Parameters:
c - The open parenthesis
c1 - the close parenthesis.
Returns:
true if the two chars indicate a parenthsis pair.

isComma

public boolean isComma(java.lang.String word)
Description copied from interface: OperationsParser
returns true if this word act as a partition in a group, for example you can have the word AND as a partition for this group.
{1 AND 5 AND 7}

Specified by:
isComma in interface OperationsParser
Parameters:
word - The word to be evaluated.
Returns:
true id the word acts like a comma.

isComma

public boolean isComma(char c)
Description copied from interface: OperationsParser
Returns true if the char acts like a partioner in a group. For Exmaple: the comma is a partitioner in this group.
{ 1,3,5,6,7}

Specified by:
isComma in interface OperationsParser
Parameters:
c - the char to be evaluated.
Returns:
true if this is a comma.