public abstract class Path extends Expression
Expression.PointerIterator, Expression.ValueIterator
NOT_A_NUMBER, ONE, ZERO
Modifier and Type | Method and Description |
---|---|
protected boolean |
areBasicPredicates(Expression[] predicates)
Learn whether the elements of the specified array are "basic" predicates.
|
protected EvalContext |
buildContextChain(EvalContext context,
int stepCount,
boolean createInitialContext)
Build a context from a chain of contexts.
|
boolean |
computeContextDependent()
Implemented by subclasses and result is cached by isContextDependent()
|
protected EvalContext |
createContextForStep(EvalContext context,
int axis,
NodeTest nodeTest)
Different axes are serviced by different contexts.
|
protected EvalContext |
evalSteps(EvalContext context)
Given a root context, walks a path therefrom and builds a context
that contains all nodes matching the path.
|
protected Pointer |
getSingleNodePointerForSteps(EvalContext context)
Given a root context, walks a path therefrom and finds the
pointer to the first element matching the path.
|
Step[] |
getSteps()
Get the steps.
|
boolean |
isSimplePath()
Recognizes paths formatted as
foo/bar[3]/baz[@name = 'biz'] . |
protected boolean |
isSimpleStep(Step step)
A Step is "simple" if it takes one of these forms: "
|
protected Pointer |
searchForPath(EvalContext context)
The idea here is to return a NullPointer rather than null if that's at
all possible.
|
compute, computeValue, isContextDependent, iterate, iteratePointers
public boolean computeContextDependent()
Expression
computeContextDependent
in class Expression
public boolean isSimplePath()
foo/bar[3]/baz[@name = 'biz']
.
The evaluation of such "simple" paths is optimized and
streamlined.true
if this path is simpleprotected boolean isSimpleStep(Step step)
step
- the step to checkprotected boolean areBasicPredicates(Expression[] predicates)
predicates
- the Expression[] to checkprotected Pointer getSingleNodePointerForSteps(EvalContext context)
context
- evaluation contextprotected Pointer searchForPath(EvalContext context)
However, a path like "//key" would still produce null, because we have no way of knowing where "key" would be if it existed.
To accomplish this, we first try the path itself. If it does not find anything, we chop off last step of the path, as long as it is a simple one like child:: or attribute:: and try to evaluate the truncated path. If it finds exactly one node - create a NullPointer and return. If it fails, chop off another step and repeat. If it finds more than one location - return null.
context
- evaluation contextprotected EvalContext evalSteps(EvalContext context)
context
- evaluation contextprotected EvalContext buildContextChain(EvalContext context, int stepCount, boolean createInitialContext)
context
- evaluation contextstepCount
- number of steps to descendcreateInitialContext
- whether to create the initial contextprotected EvalContext createContextForStep(EvalContext context, int axis, NodeTest nodeTest)
context
- evaluation contextaxis
- codenodeTest
- node testCopyright © 2001–2015 The Apache Software Foundation. All rights reserved.