clark.xpath
Class TreeConstructor

java.lang.Object
  |
  +--clark.xpath.TreeConstructor

public class TreeConstructor
extends java.lang.Object

This is the main parser of the XPath engine. The input point is the method parseUnionExpression(). The result of it is a complete tree representing the XPath expression.


Constructor Summary
TreeConstructor()
           
 
Method Summary
 clark.xpath.GeneralNode genAxTree(java.util.LinkedList list)
          Creates the tree from the list tokenizezed in parseRelativeLocationPath.
 clark.xpath.GeneralNode genUTree(java.util.LinkedList list)
          Creates the tree from the list tokenizezed in parseUnionExpression.
 clark.xpath.NodeTest getNodeTestCode(java.lang.String nt)
          Returns a NodeTest object, representing a node test in one axis.
 clark.xpath.GeneralNode parseAdditiveExpr(java.lang.String addExpr)
          Parses a string which is expected to be an Additive expression.
 clark.xpath.GeneralNode parseAndExpr(java.lang.String andExpr)
          Parses a string which is expected to be an AND expression.
 clark.xpath.GeneralNode parseEqualityExpr(java.lang.String eqExpr)
          Parses a string which is expected to be an Equality expression.
 clark.xpath.GeneralNode parseLocationPath(java.lang.String str)
          Parses Location Path.
 clark.xpath.GeneralNode parseMultiplicativeExpr(java.lang.String mulExpr)
          Parses a string which is expected to be a Multiplicative expression.
 clark.xpath.GeneralNode parsePathExpression(java.lang.String str)
          Parses Path Extresion.
 clark.xpath.GeneralNode parsePredicate(java.lang.String orExpr)
          Parses a string which is expected to be a predicate.
 clark.xpath.GeneralNode parsePrimaryExpression(java.lang.String primaryExpr)
          Parses a String expected to be a variable reference, '(' expression ')', text, number, function call.
 clark.xpath.GeneralNode parseRelationalExpr(java.lang.String relExpr)
          Parses a string which is expected to be a Relational expression.
 clark.xpath.GeneralNode parseRelativeLocationPath(java.lang.String str)
          Parses Relative Location Path.
 clark.xpath.GeneralNode parseStep(java.lang.String str)
          Parses Step Expression.
 clark.xpath.GeneralNode parseUnaryExpr(java.lang.String unaryExpr)
          Parses a string which is expected to be an Unary expression.
 clark.xpath.GeneralNode parseUnionExpression(java.lang.String str)
          Parses a string which is expected to be a Union Expression.
 java.util.LinkedList predToke(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeConstructor

public TreeConstructor()
Method Detail

parseUnionExpression

public clark.xpath.GeneralNode parseUnionExpression(java.lang.String str)
                                             throws ParseException
Parses a string which is expected to be a Union Expression. This method searches for an "|" symbol. Creates LinkedList from tokens separated by "|".

ParseException

genUTree

public clark.xpath.GeneralNode genUTree(java.util.LinkedList list)
                                 throws ParseException
Creates the tree from the list tokenizezed in parseUnionExpression. Calls the parsePathExpression method

ParseException

parsePathExpression

public clark.xpath.GeneralNode parsePathExpression(java.lang.String str)
                                            throws ParseException
Parses Path Extresion.

ParseException

parseLocationPath

public clark.xpath.GeneralNode parseLocationPath(java.lang.String str)
                                          throws ParseException
Parses Location Path.

ParseException

genAxTree

public clark.xpath.GeneralNode genAxTree(java.util.LinkedList list)
                                  throws ParseException
Creates the tree from the list tokenizezed in parseRelativeLocationPath. Calls the Parse Step method.

ParseException

parseRelativeLocationPath

public clark.xpath.GeneralNode parseRelativeLocationPath(java.lang.String str)
                                                  throws ParseException
Parses Relative Location Path. Searches for the symbol "/". Makes LinkedList from Tokens separated by "/".

ParseException

parseStep

public clark.xpath.GeneralNode parseStep(java.lang.String str)
                                  throws ParseException
Parses Step Expression. Searches for "::". Separates predicates

ParseException

predToke

public java.util.LinkedList predToke(java.lang.String str)
                              throws ParseException
ParseException

parsePredicate

public clark.xpath.GeneralNode parsePredicate(java.lang.String orExpr)
                                       throws ParseException
Parses a string which is expected to be a predicate. This method searches for an OR operator. If it can not recognize ORr operator, it assumes that it is an AND expression. If there is OR operator found, it is the rightmost occurance of it and then to the left of it, a new OR is searched for. To the right of it AND operator is expected.

ParseException

parseAndExpr

public clark.xpath.GeneralNode parseAndExpr(java.lang.String andExpr)
                                     throws ParseException
Parses a string which is expected to be an AND expression. This method searches for an AND operator. If it can not recognize AND operator, it assumes that it is an Equality expression. If there is AND operator found, it is the rightmost occurance of it and then to the left of it, a new AND is searched for. To the right of it '=' or '!=' operator is expected.

ParseException

parseEqualityExpr

public clark.xpath.GeneralNode parseEqualityExpr(java.lang.String eqExpr)
                                          throws ParseException
Parses a string which is expected to be an Equality expression. This method searches for '=' or '!=' operator. If it can not recognize any of them, it assumes that it is a Relational expression. If there is '=' or '!=' found, it is the rightmost occurance of it and then to the left of it, a new '=' or '!=' is searched for. To the right of it '<','<=','>=' or '>' operator is expected.

ParseException

parseRelationalExpr

public clark.xpath.GeneralNode parseRelationalExpr(java.lang.String relExpr)
                                            throws ParseException
Parses a string which is expected to be a Relational expression. This method searches for '>','>=','<' or '<=' operator. If it can not recognize any of them, it assumes that it is an additive expression. If there is '>', '>=', '<' or '<=' found, it is the rightmost occurance of it and then to the left of it, a new '>', '>=', '<' or '<=' is searched for. To the right of it '+' or '-' operator is expected.

ParseException

parseAdditiveExpr

public clark.xpath.GeneralNode parseAdditiveExpr(java.lang.String addExpr)
                                          throws ParseException
Parses a string which is expected to be an Additive expression. This method searches for '+' or '-' operator. If it can not recognize any of them, it assumes that it is a multiplicative expression. If there is '+' or '-' found, it is the rightmost occurance of it and then to the left of it, a new '+' or '-' is searched for. To the right of it '*', 'div' or 'mod' operator is expected.

ParseException

parseMultiplicativeExpr

public clark.xpath.GeneralNode parseMultiplicativeExpr(java.lang.String mulExpr)
                                                throws ParseException
Parses a string which is expected to be a Multiplicative expression. This method searches for '*', 'div' or 'mod' operator. If it can not recognize any of them, it assumes that it is an Unary expression. If there is '*', 'div' or 'mod' found, it is the rightmost occurance of it and then to the left of it, a new '*', 'div' or 'mod' is searched for.

ParseException

parseUnaryExpr

public clark.xpath.GeneralNode parseUnaryExpr(java.lang.String unaryExpr)
                                       throws ParseException
Parses a string which is expected to be an Unary expression. This method searches for '-' followed by another unary expression. If it can not fine '-', it assumes that it is an Union expression.

ParseException

parsePrimaryExpression

public clark.xpath.GeneralNode parsePrimaryExpression(java.lang.String primaryExpr)
                                               throws ParseException
Parses a String expected to be a variable reference, '(' expression ')', text, number, function call. If it is none of them -> an exception is thrown.

ParseException

getNodeTestCode

public clark.xpath.NodeTest getNodeTestCode(java.lang.String nt)
Returns a NodeTest object, representing a node test in one axis. The argument is the String representation of the node test.