org.hawk.ds
Class Element

java.lang.Object
  extended by org.hawk.ds.Element
All Implemented Interfaces:
java.lang.Comparable

public class Element
extends java.lang.Object
implements java.lang.Comparable

This is a placeholder for perspective element in the input string.


Field Summary
static java.util.regex.Pattern ARRAY_EXISTENCE_PATTERN
          RegEx to parse variable in the expression.
protected  java.lang.String element
          Raw element data.
protected  boolean execFunction
          Boolean if this element is a exec function script.
protected  boolean execModule
          Boolean if this element is a exec module script.
protected  boolean isVariable
          Boolean to indiate if the element is variable.
protected  int pos
          Starting position of raw element data.
protected  boolean structAsgnmnt
          Boolean if this element is a exec module script.
protected  IScript value
           
static java.util.regex.Pattern VARIABLE_EXISTENCE_PATTERN
          RegEx to parse variable in the expression.
static java.util.regex.Pattern VARIABLE_PATTERN
          RegEx to parse variable in the expression.
 
Constructor Summary
protected Element(java.lang.String element, int pos)
           
 
Method Summary
 int compareTo(java.lang.Object herElement)
           
 boolean equals(java.lang.Object herElement)
           
 boolean flip()
          This flips "(" into ")" and vice versa.
 java.lang.String getElement()
           
static Element getElement(int pos)
           
 int getPos()
           
 int getPrecedence()
          This returns the precedence of operators supported in hawk.
 IScript getValue()
           
 int hashCode()
           
 boolean hasHigherPrecedence(Element otherOpr)
           
 boolean isClosingClubber()
          This checks for ")"
 boolean isClubber()
          This checks for the element is either "(" or ")"
 boolean isConstant()
           
 boolean isDouble()
           
 boolean isExecFunction()
           
 boolean isExecModule()
           
 boolean isIsVariable()
          This checks if the the element is variable...
 boolean isLeft(Element herElement)
          This checks if the element's position left to the other element
 boolean isOperand()
          This checks if the element is operand
 boolean isOperator()
          If this is a operator
 boolean isRight(Element herElement)
          This checks if the element's position right to the other element
 boolean isStartingClubber()
          This checks for "("
 boolean isString()
           
 boolean isStructAsgnmnt()
           
 boolean isVariable()
           
static void main(java.lang.String[] args)
           
static java.util.List<Element> parseElements(java.lang.String equation)
          This parses input equation into list of Element
static java.util.List<Element> reverse(java.util.List<Element> list)
          This returns the input list of elements .
 void setElement(java.lang.String element)
           
 void setExecFunction(boolean execFunction)
           
 void setExecModule(boolean execModule)
           
 void setIsVariable(boolean isVariable)
           
 void setPos(int pos)
           
 void setStructAsgnmnt(boolean structAsgnmnt)
           
 void setValue(IScript value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

element

protected java.lang.String element
Raw element data.


pos

protected int pos
Starting position of raw element data.


isVariable

protected boolean isVariable
Boolean to indiate if the element is variable.


execFunction

protected boolean execFunction
Boolean if this element is a exec function script.


execModule

protected boolean execModule
Boolean if this element is a exec module script.


structAsgnmnt

protected boolean structAsgnmnt
Boolean if this element is a exec module script.


value

protected IScript value

VARIABLE_PATTERN

public static final java.util.regex.Pattern VARIABLE_PATTERN
RegEx to parse variable in the expression.


VARIABLE_EXISTENCE_PATTERN

public static final java.util.regex.Pattern VARIABLE_EXISTENCE_PATTERN
RegEx to parse variable in the expression.


ARRAY_EXISTENCE_PATTERN

public static final java.util.regex.Pattern ARRAY_EXISTENCE_PATTERN
RegEx to parse variable in the expression.

Constructor Detail

Element

protected Element(java.lang.String element,
                  int pos)
Parameters:
element - element
pos - starting position of element
Method Detail

getValue

public IScript getValue()

setValue

public void setValue(IScript value)

getElement

public java.lang.String getElement()

setElement

public void setElement(java.lang.String element)

getPos

public int getPos()

setPos

public void setPos(int pos)

isOperator

public boolean isOperator()
If this is a operator

Returns:
returns true if this is an operator else false.

isStartingClubber

public boolean isStartingClubber()
This checks for "("

Returns:
returns true if the element is "(" else false

isClosingClubber

public boolean isClosingClubber()
This checks for ")"

Returns:
returns true if the element is ")" else false

flip

public boolean flip()
This flips "(" into ")" and vice versa.

Returns:
true if it is able to flip else false

isClubber

public boolean isClubber()
This checks for the element is either "(" or ")"

Returns:
returns true if element is either "(" or ")"

isOperand

public boolean isOperand()
This checks if the element is operand

Returns:
returns true if the element is

isIsVariable

public boolean isIsVariable()
This checks if the the element is variable... yet to be computed.

Returns:
true if the element is variable.

setIsVariable

public void setIsVariable(boolean isVariable)

isExecFunction

public boolean isExecFunction()

setExecFunction

public void setExecFunction(boolean execFunction)

isExecModule

public boolean isExecModule()

setExecModule

public void setExecModule(boolean execModule)

isStructAsgnmnt

public boolean isStructAsgnmnt()

setStructAsgnmnt

public void setStructAsgnmnt(boolean structAsgnmnt)

isVariable

public boolean isVariable()

isConstant

public boolean isConstant()

isDouble

public boolean isDouble()

isString

public boolean isString()

getElement

public static Element getElement(int pos)

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

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

compareTo

public int compareTo(java.lang.Object herElement)
Specified by:
compareTo in interface java.lang.Comparable

isLeft

public boolean isLeft(Element herElement)
This checks if the element's position left to the other element

Parameters:
herElement - the input element which is to be checked with this element for position
Returns:
returns true if the element's position is left to the other element

isRight

public boolean isRight(Element herElement)
This checks if the element's position right to the other element

Parameters:
herElement - the input element which is to be checked with this element for position
Returns:
returns true if the element's position is right to the other element

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

parseElements

public static java.util.List<Element> parseElements(java.lang.String equation)
                                             throws HawkException
This parses input equation into list of Element

Parameters:
equation - input equation to be parsed.
Returns:
returns list of element
Throws:
HawkException

reverse

public static java.util.List<Element> reverse(java.util.List<Element> list)
This returns the input list of elements . This does not modify the input list.

Parameters:
list - list of elements to be reversed.
Returns:
returns the reverse of the list.

getPrecedence

public int getPrecedence()
                  throws HawkException
This returns the precedence of operators supported in hawk.

Returns:
Throws:
HawkException

hasHigherPrecedence

public boolean hasHigherPrecedence(Element otherOpr)
                            throws HawkException
Throws:
HawkException