Class ExpressionPath
- java.lang.Object
-
- org.apache.commons.jxpath.ri.compiler.Expression
-
- org.apache.commons.jxpath.ri.compiler.Path
-
- org.apache.commons.jxpath.ri.compiler.ExpressionPath
-
public class ExpressionPath extends Path
An element of the parse tree that represents an expression path, which is a path that starts with an expression like a function call:getFoo(.) /bar
.- Version:
- $Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
- Author:
- Dmitri Plotnikov
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
basic
private boolean
basicKnown
private Expression
expression
private Expression[]
predicates
-
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE, ZERO
-
-
Constructor Summary
Constructors Constructor Description ExpressionPath(Expression expression, Expression[] predicates, Step[] steps)
Create a new ExpressionPath.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
compute(EvalContext context)
Evaluates the expression.boolean
computeContextDependent()
Returns true if the root expression or any of the predicates or the path steps are context dependent.java.lang.Object
computeValue(EvalContext context)
Evaluates the expression.protected java.lang.Object
expressionPath(EvalContext evalContext, boolean firstMatch)
Walks an expression path (a path that starts with an expression)Expression
getExpression()
Get the expression.Expression[]
getPredicates()
Predicates are the expressions in brackets that may follow the root expression of the path.boolean
isSimpleExpressionPath()
Recognized paths formatted as$x[3]/foo[2]
.java.lang.String
toString()
-
Methods inherited from class org.apache.commons.jxpath.ri.compiler.Path
areBasicPredicates, buildContextChain, createContextForStep, evalSteps, getSingleNodePointerForSteps, getSteps, isSimplePath, isSimpleStep, searchForPath
-
Methods inherited from class org.apache.commons.jxpath.ri.compiler.Expression
isContextDependent, iterate, iteratePointers
-
-
-
-
Field Detail
-
expression
private Expression expression
-
predicates
private Expression[] predicates
-
basicKnown
private boolean basicKnown
-
basic
private boolean basic
-
-
Constructor Detail
-
ExpressionPath
public ExpressionPath(Expression expression, Expression[] predicates, Step[] steps)
Create a new ExpressionPath.- Parameters:
expression
- Expressionpredicates
- to executesteps
- navigation
-
-
Method Detail
-
getExpression
public Expression getExpression()
Get the expression.- Returns:
- Expression
-
getPredicates
public Expression[] getPredicates()
Predicates are the expressions in brackets that may follow the root expression of the path.- Returns:
- Expression[]
-
computeContextDependent
public boolean computeContextDependent()
Returns true if the root expression or any of the predicates or the path steps are context dependent.- Overrides:
computeContextDependent
in classPath
- Returns:
- boolean
-
isSimpleExpressionPath
public boolean isSimpleExpressionPath()
Recognized paths formatted as$x[3]/foo[2]
. The evaluation of such "simple" paths is optimized and streamlined.- Returns:
- boolean
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compute
public java.lang.Object compute(EvalContext context)
Description copied from class:Expression
Evaluates the expression. If the result is a node set, returns the first element of the node set.- Specified by:
compute
in classExpression
- Parameters:
context
- evaluation context- Returns:
- Object
-
computeValue
public java.lang.Object computeValue(EvalContext context)
Description copied from class:Expression
Evaluates the expression. If the result is a node set, returns the first element of the node set.- Specified by:
computeValue
in classExpression
- Parameters:
context
- evaluation context- Returns:
- Object
-
expressionPath
protected java.lang.Object expressionPath(EvalContext evalContext, boolean firstMatch)
Walks an expression path (a path that starts with an expression)- Parameters:
evalContext
- base contextfirstMatch
- whether to return the first match found- Returns:
- Object found
-
-