|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xlattice.corexml.expr.ExprParser
public class ExprParser
XPath 1.0 expression parser. This class is best understood by reading it with the W3C XPath 1.0 specification in hand.
The parse() method accepts an expression in String form, tokenizes it using its lexer, and returns an unevaluated expression tree. The eval() method accepts an XPath expression tree and returns a result. The evaluation is done given the current context and context node. XPath return types do not map particularly well into Java types. This implementation is incomplete.
| Field Summary | |
|---|---|
protected org.xlattice.Context |
ctx
the context, hashed access to global variables |
protected Node |
node
the node expressions are evaluated in relation to |
static NodeTest |
NTEST_COMMENT
|
static NodeTest |
NTEST_ELEMENT
|
static NodeTest |
NTEST_NODE
|
static NodeTest |
NTEST_PI
|
static NodeTest |
NTEST_STAR
|
static NodeTest |
NTEST_TEXT
|
static NodeType |
NTYPE_COMMENT
|
static NodeType |
NTYPE_ELEMENT
|
static NodeType |
NTYPE_NODE
|
static NodeType |
NTYPE_PI
|
static NodeType |
NTYPE_TEXT
|
static Operator |
OP_DSLASH
|
static Operator |
OP_SLASH
|
static Operator |
OP_STAR
|
static Symbol |
SYM_COLON
|
static Symbol |
SYM_DCOLON
|
static Symbol |
SYM_DDOT
|
static Symbol |
SYM_DOT
|
static Symbol |
SYM_LBRACKET
|
static Symbol |
SYM_LPAREN
|
static Symbol |
SYM_RBRACKET
|
static Symbol |
SYM_RPAREN
|
static Symbol |
SYM_STAR
|
| Constructor Summary | |
|---|---|
ExprParser(Node n,
org.xlattice.Context c)
Create an expression parser. |
|
| Method Summary | |
|---|---|
static boolean |
booleanFunc(java.lang.Object o)
|
void |
cantCast(Expr e)
|
Bool |
castToBool(Expr e)
|
Literal |
castToLiteral(Expr e)
|
Numeric |
castToNumeric(Expr e)
|
(package private) NodeTest |
collectNodeTest()
Expect the next tokens from the lexer to represent a NodeTest. |
(package private) Step |
collectPredicates(Step step)
Given a step, collect any predicates following it. |
(package private) Step |
collectStep(AxisName aName,
boolean single)
Having encountered an axis name, collect the step. |
(package private) Step |
collectStep(NCName ncName,
boolean single)
Verify NCName followed by :*, then collect the step, defaulting it to one along the CHILD axis. |
(package private) Step |
collectStep(NodeType nodeType,
boolean single)
Having encountered a nodeType, collect the step, defaulting it to one along the CHILD axis. |
(package private) Step |
collectStep(QName qName,
boolean single)
Having encountered a QName, collect the step, defaulting it to one along the CHILD axis. |
(package private) Step |
collectStep(Symbol sym,
boolean single)
Having encountered a symbol, collect the step. |
(package private) LocationPath |
collectSteps(LocationPath lp,
boolean single,
boolean required)
Collect a series of steps and append them to the location path, which is returned. |
static java.lang.String |
concat(java.lang.String[] args)
This interface deviates from the specs, because Java 1.4 doesn't support variable length argument lists. |
static Numeric |
count(NodeSet nodes)
XPath NodeSet function 1, count. |
Expr |
eval(Expr e)
|
Expr |
eval(java.lang.String str)
|
(package private) Bool |
evalBoolBinary(BinaryExpr e)
|
(package private) Literal |
evalLiteralBinary(BinaryExpr e)
|
(package private) NodeSet |
evalLocationPath(LocationPath lp)
|
(package private) NodeSet |
evalNodeSetBinary(BinaryExpr e)
|
(package private) Numeric |
evalNumericBinary(BinaryExpr e)
|
(package private) void |
expect(Token t)
|
Node |
getNode()
|
Numeric |
id()
|
Numeric |
last()
|
java.lang.String |
localName()
|
static java.lang.String |
localName(NodeSet nodes)
|
java.lang.String |
name()
|
static java.lang.String |
name(NodeSet nodes)
|
java.lang.String |
namespaceUri()
|
static java.lang.String |
namespaceUri(NodeSet nodes)
|
static java.lang.Double |
number()
|
static java.lang.Double |
number(java.lang.Object o)
XPath numeric function 1, number() |
Expr |
parse(java.lang.String str)
Parse a String holding an XPath expression. |
(package private) LocationPath |
parseAbsLocationPath(Operator op)
Parse an absolute location path, having encountered an Operator token. |
(package private) BinaryExpr |
parseAdditiveExpr(Operator op,
Expr left)
|
(package private) BinaryExpr |
parseAndExpr(Operator op,
Expr left)
|
(package private) BinaryExpr |
parseEqualityExpr(Operator op,
Expr left)
|
(package private) BinaryExpr |
parseMultiplicativeExpr(Operator op,
Expr left)
|
(package private) BinaryExpr |
parseOrExpr(Operator op,
Expr left)
|
(package private) BinaryExpr |
parseRelationalExpr(Operator op,
Expr left)
|
(package private) LocationPath |
parseRelLocationPath(Token t)
Parse an absolute location path, having encountered the current token. |
(package private) LocationPath |
parseStep(Token t,
Expr soFar)
Parse a step beginning with Token, using the expression collected so far to build a location path. |
(package private) UnaryExpr |
parseUnaryExpr(Operator op)
Parse a unary expression with a leading minus. |
(package private) BinaryExpr |
parseUnionExpr(Operator op,
Expr left)
Called after seeing a '|' (BAR) |
Numeric |
position()
|
void |
setNode(Node newContextNode)
Change the context node, the node that expressions are evaluated in relation to. |
java.lang.String |
string()
Convert the context node. |
static java.lang.String |
string(Node node)
XPath String function 1, string(node). |
static java.lang.String |
string(java.lang.Object e)
Convert objects to Java Strings in accordance with the spec. |
(package private) Node |
takeStep(Node ctxNode,
NodeSet collected,
java.util.ArrayList steps)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Node node
protected final org.xlattice.Context ctx
public static final Operator OP_SLASH
public static final Operator OP_DSLASH
public static final Operator OP_STAR
public static final Symbol SYM_COLON
public static final Symbol SYM_DCOLON
public static final Symbol SYM_DOT
public static final Symbol SYM_DDOT
public static final Symbol SYM_LBRACKET
public static final Symbol SYM_LPAREN
public static final Symbol SYM_RBRACKET
public static final Symbol SYM_RPAREN
public static final Symbol SYM_STAR
public static final NodeType NTYPE_COMMENT
public static final NodeTest NTEST_COMMENT
public static final NodeType NTYPE_ELEMENT
public static final NodeTest NTEST_ELEMENT
public static final NodeType NTYPE_NODE
public static final NodeTest NTEST_NODE
public static final NodeType NTYPE_PI
public static final NodeTest NTEST_PI
public static final NodeType NTYPE_TEXT
public static final NodeTest NTEST_TEXT
public static final NodeTest NTEST_STAR
| Constructor Detail |
|---|
public ExprParser(Node n,
org.xlattice.Context c)
n - current nodec - current context| Method Detail |
|---|
public Node getNode()
public void setNode(Node newContextNode)
void expect(Token t)
throws CoreXmlException
CoreXmlException - if t not next Token from lexer
public Expr parse(java.lang.String str)
throws CoreXmlException
CoreXmlException
LocationPath parseAbsLocationPath(Operator op)
throws CoreXmlException
CoreXmlException
LocationPath parseRelLocationPath(Token t)
throws CoreXmlException
CoreXmlException
LocationPath collectSteps(LocationPath lp,
boolean single,
boolean required)
throws CoreXmlException
lp - location path inputsingle - collect only one steprequired - whether a step MUST be found
CoreXmlException
Step collectStep(AxisName aName,
boolean single)
throws CoreXmlException
CoreXmlException
Step collectStep(Symbol sym,
boolean single)
throws CoreXmlException
CoreXmlException
Step collectStep(NodeType nodeType,
boolean single)
throws CoreXmlException
CoreXmlException
Step collectStep(NCName ncName,
boolean single)
throws CoreXmlException
CoreXmlException
Step collectStep(QName qName,
boolean single)
throws CoreXmlException
CoreXmlException
NodeTest collectNodeTest()
throws CoreXmlException
CoreXmlException
Step collectPredicates(Step step)
throws CoreXmlException
CoreXmlException
LocationPath parseStep(Token t,
Expr soFar)
throws CoreXmlException
t - curent tokensoFar - expression seen so far, must be a LocationPath
CoreXmlException
UnaryExpr parseUnaryExpr(Operator op)
throws CoreXmlException
CoreXmlException
BinaryExpr parseUnionExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
BinaryExpr parseMultiplicativeExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
BinaryExpr parseAdditiveExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
BinaryExpr parseRelationalExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
BinaryExpr parseEqualityExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
BinaryExpr parseAndExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
BinaryExpr parseOrExpr(Operator op,
Expr left)
throws CoreXmlException
CoreXmlException
public Expr eval(java.lang.String str)
throws CoreXmlException
CoreXmlException
public Expr eval(Expr e)
throws CoreXmlException
CoreXmlException
NodeSet evalLocationPath(LocationPath lp)
throws CoreXmlException
CoreXmlException
Node takeStep(Node ctxNode,
NodeSet collected,
java.util.ArrayList steps)
throws CoreXmlException
CoreXmlException
Bool evalBoolBinary(BinaryExpr e)
throws CoreXmlException
CoreXmlException
Literal evalLiteralBinary(BinaryExpr e)
throws CoreXmlException
CoreXmlException
NodeSet evalNodeSetBinary(BinaryExpr e)
throws CoreXmlException
CoreXmlException
Numeric evalNumericBinary(BinaryExpr e)
throws CoreXmlException
CoreXmlException
public Bool castToBool(Expr e)
throws CoreXmlException
CoreXmlException
public Numeric castToNumeric(Expr e)
throws CoreXmlException
CoreXmlException
public Literal castToLiteral(Expr e)
throws CoreXmlException
CoreXmlException
public void cantCast(Expr e)
throws CoreXmlException
CoreXmlExceptionpublic static Numeric count(NodeSet nodes)
public Numeric id()
public Numeric last()
public java.lang.String name()
public static java.lang.String name(NodeSet nodes)
public java.lang.String localName()
public static java.lang.String localName(NodeSet nodes)
public java.lang.String namespaceUri()
public static java.lang.String namespaceUri(NodeSet nodes)
public Numeric position()
public static java.lang.String string(Node node)
public java.lang.String string()
public static java.lang.String string(java.lang.Object e)
public static java.lang.String concat(java.lang.String[] args)
public static boolean booleanFunc(java.lang.Object o)
public static java.lang.Double number(java.lang.Object o)
public static java.lang.Double number()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||