org.exist.xquery
Class LocationStep

java.lang.Object
  extended by org.exist.xquery.AbstractExpression
      extended by org.exist.xquery.Step
          extended by org.exist.xquery.LocationStep
All Implemented Interfaces:
Expression

public class LocationStep
extends Step

Processes all location path steps (like descendant::*, ancestor::XXX). The results of the first evaluation of the expression are cached for the lifetime of the object and only reloaded if the context sequence (as passed to the eval(Sequence, Item) method) has changed.


Field Summary
protected  boolean applyPredicate
           
protected  CachedResult cached
           
protected  DocumentSet currentDocs
           
protected  NodeSet currentSet
           
protected  boolean inUpdate
           
protected  UpdateListener listener
           
protected  boolean optimized
           
protected  Expression parent
           
protected  int parentDeps
           
protected  boolean preloadedData
           
protected  boolean useDirectAttrSelect
           
protected  boolean useDirectChildSelect
           
 
Fields inherited from class org.exist.xquery.Step
abbreviatedStep, axis, hasPositionalPredicate, inPredicate, LOG, predicates, staticReturnType, test
 
Fields inherited from class org.exist.xquery.AbstractExpression
column, context, contextDocSet, contextId, line, unordered
 
Fields inherited from interface org.exist.xquery.Expression
DOT_TEST, EXPRESSION_ID_INVALID, IGNORE_CONTEXT, IN_NODE_CONSTRUCTOR, IN_PREDICATE, IN_UPDATE, IN_WHERE_CLAUSE, NEED_INDEX_INFO, NO_CONTEXT_ID, NON_STREAMABLE, POSITIONAL_PREDICATE, SINGLE_STEP_EXECUTION, UNORDERED, USE_TREE_TRAVERSAL
 
Constructor Summary
LocationStep(XQueryContext context, int axis)
          Creates a new LocationStep instance.
LocationStep(XQueryContext context, int axis, NodeTest test)
          Creates a new LocationStep instance.
 
Method Summary
 void accept(ExpressionVisitor visitor)
          The method accept
 void analyze(AnalyzeContextInfo contextInfo)
          Statically analyze the expression and its subexpressions.
protected  Sequence applyPredicate(Sequence outerSequence, Sequence contextSequence)
          The method applyPredicate
 Sequence eval(Sequence contextSequence, Item contextItem)
          The method eval
protected  Sequence getAncestors(XQueryContext context, Sequence contextSequence)
          The method getAncestors
protected  Sequence getAttributes(XQueryContext context, Sequence contextSequence)
          The method getAttributes
protected  Sequence getChildren(XQueryContext context, Sequence contextSequence)
          The method getChildren
 int getDependencies()
          Returns Dependency.DEFAULT_DEPENDENCIES.
protected  Sequence getDescendants(XQueryContext context, Sequence contextSequence)
          The method getDescendants
protected  DocumentSet getDocumentSet(NodeSet contextSet)
          The method getDocumentSet
protected  Sequence getFollowing(XQueryContext context, Sequence contextSequence)
          The method getFollowing
 Expression getParentExpression()
          The method getParent
protected  Sequence getParents(XQueryContext context, Sequence contextSequence)
          The method getParents
protected  Sequence getPreceding(XQueryContext context, Sequence contextSequence)
          The method getPreceding
protected  Sequence getSelf(XQueryContext context, Sequence contextSequence)
          The method getSelf
protected  Sequence getSiblings(XQueryContext context, Sequence contextSequence)
          The method getSiblings
protected  boolean hasPreloadedData()
          If the current path expression depends on local variables from a for expression, we can optimize by preloading entire element or attribute sets.
 java.lang.Boolean match(Sequence contextSequence, Item contextItem)
           
protected  boolean matchAttributes(XQueryContext context, Sequence contextSequence)
           
protected  java.lang.Boolean matchChildren(XQueryContext context, Sequence contextSequence)
           
protected  void registerUpdateListener()
          The method registerUpdateListener
 void resetState(boolean postOptimization)
          Called to inform an expression that it should reset to its initial state.
 void setPreloadedData(DocumentSet docs, NodeSet nodes)
          The method setPreloadedData
 void setUseDirectAttrSelect(boolean useDirectAttrSelect)
          The method setUseDirectAttrSelect
 
Methods inherited from class org.exist.xquery.Step
addPredicate, dump, getAxis, getCardinality, getPredicates, getPrimaryAxis, getTest, hasPredicates, insertPredicate, isAbbreviated, returnsType, setAbbreviated, setAxis, setPrimaryAxis, setTest, toString
 
Methods inherited from class org.exist.xquery.AbstractExpression
allowMixNodesInReturn, eval, getColumn, getContext, getContextDocSet, getContextId, getExpressionId, getLine, getParent, getSource, getSubExpression, getSubExpressionCount, needsReset, setASTNode, setContextDocSet, setContextId, setLocation, simplify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentSet

protected NodeSet currentSet

currentDocs

protected DocumentSet currentDocs

listener

protected UpdateListener listener

parent

protected Expression parent

cached

protected CachedResult cached

parentDeps

protected int parentDeps

preloadedData

protected boolean preloadedData

optimized

protected boolean optimized

inUpdate

protected boolean inUpdate

useDirectAttrSelect

protected boolean useDirectAttrSelect

useDirectChildSelect

protected boolean useDirectChildSelect

applyPredicate

protected boolean applyPredicate
Constructor Detail

LocationStep

public LocationStep(XQueryContext context,
                    int axis)
Creates a new LocationStep instance.

Parameters:
context - a XQueryContext value
axis - an int value

LocationStep

public LocationStep(XQueryContext context,
                    int axis,
                    NodeTest test)
Creates a new LocationStep instance.

Parameters:
context - a XQueryContext value
axis - an int value
test - a NodeTest value
Method Detail

getDependencies

public int getDependencies()
Description copied from class: AbstractExpression
Returns Dependency.DEFAULT_DEPENDENCIES.

Specified by:
getDependencies in interface Expression
Overrides:
getDependencies in class AbstractExpression
Returns:
set of bit-flags
See Also:
Expression.getDependencies()

hasPreloadedData

protected boolean hasPreloadedData()
If the current path expression depends on local variables from a for expression, we can optimize by preloading entire element or attribute sets.

Returns:
Whether or not we can optimize

setPreloadedData

public void setPreloadedData(DocumentSet docs,
                             NodeSet nodes)
The method setPreloadedData

Parameters:
docs - a DocumentSet value
nodes - a NodeSet value

applyPredicate

protected Sequence applyPredicate(Sequence outerSequence,
                                  Sequence contextSequence)
                           throws XPathException
The method applyPredicate

Parameters:
outerSequence - a Sequence value
contextSequence - a Sequence value
Returns:
a Sequence value
Throws:
XPathException - if an error occurs

analyze

public void analyze(AnalyzeContextInfo contextInfo)
             throws XPathException
Description copied from interface: Expression
Statically analyze the expression and its subexpressions. During the static analysis phase, the query engine can detect unknown variables and some type errors.

Specified by:
analyze in interface Expression
Overrides:
analyze in class Step
Throws:
XPathException

eval

public Sequence eval(Sequence contextSequence,
                     Item contextItem)
              throws XPathException
The method eval

Specified by:
eval in interface Expression
Specified by:
eval in class Step
Parameters:
contextSequence - a Sequence value
contextItem - an Item value
Returns:
a Sequence value
Throws:
XPathException - if an error occurs

getSelf

protected Sequence getSelf(XQueryContext context,
                           Sequence contextSequence)
                    throws XPathException
The method getSelf

Parameters:
context - a XQueryContext value
contextSequence - a NodeSet value
Returns:
a Sequence value
Throws:
XPathException

getAttributes

protected Sequence getAttributes(XQueryContext context,
                                 Sequence contextSequence)
                          throws XPathException
The method getAttributes

Parameters:
context - a XQueryContext value
contextSequence - a NodeSet value
Returns:
a NodeSet value
Throws:
XPathException

getChildren

protected Sequence getChildren(XQueryContext context,
                               Sequence contextSequence)
                        throws XPathException
The method getChildren

Parameters:
context - a XQueryContext value
contextSequence - the context sequence
Returns:
a NodeSet value
Throws:
XPathException

getDescendants

protected Sequence getDescendants(XQueryContext context,
                                  Sequence contextSequence)
                           throws XPathException
The method getDescendants

Parameters:
context - a XQueryContext value
contextSequence - the context sequence
Returns:
a NodeSet value
Throws:
XPathException

getSiblings

protected Sequence getSiblings(XQueryContext context,
                               Sequence contextSequence)
                        throws XPathException
The method getSiblings

Parameters:
context - a XQueryContext value
contextSequence - a NodeSet value
Returns:
a NodeSet value
Throws:
XPathException

getPreceding

protected Sequence getPreceding(XQueryContext context,
                                Sequence contextSequence)
                         throws XPathException
The method getPreceding

Parameters:
context - a XQueryContext value
contextSequence - a Sequence value
Returns:
a NodeSet value
Throws:
XPathException - if an error occurs

getFollowing

protected Sequence getFollowing(XQueryContext context,
                                Sequence contextSequence)
                         throws XPathException
The method getFollowing

Parameters:
context - a XQueryContext value
contextSequence - a Sequence value
Returns:
a NodeSet value
Throws:
XPathException - if an error occurs

getAncestors

protected Sequence getAncestors(XQueryContext context,
                                Sequence contextSequence)
                         throws XPathException
The method getAncestors

Parameters:
context - a XQueryContext value
contextSequence - a Sequence value
Returns:
a NodeSet value
Throws:
XPathException

getParents

protected Sequence getParents(XQueryContext context,
                              Sequence contextSequence)
                       throws XPathException
The method getParents

Parameters:
context - a XQueryContext value
contextSequence - a Sequence value
Returns:
a NodeSet value
Throws:
XPathException

getDocumentSet

protected DocumentSet getDocumentSet(NodeSet contextSet)
The method getDocumentSet

Parameters:
contextSet - a NodeSet value
Returns:
a DocumentSet value

getParentExpression

public Expression getParentExpression()
The method getParent

Returns:
an Expression value

setUseDirectAttrSelect

public void setUseDirectAttrSelect(boolean useDirectAttrSelect)
The method setUseDirectAttrSelect

Parameters:
useDirectAttrSelect - a boolean value

registerUpdateListener

protected void registerUpdateListener()
The method registerUpdateListener


accept

public void accept(ExpressionVisitor visitor)
The method accept

Specified by:
accept in interface Expression
Overrides:
accept in class AbstractExpression
Parameters:
visitor - an ExpressionVisitor value

resetState

public void resetState(boolean postOptimization)
Description copied from interface: Expression
Called to inform an expression that it should reset to its initial state. All cached data in the expression object should be dropped. For example, the xmldb:document() function calls this method whenever the input document set has changed.

Specified by:
resetState in interface Expression
Overrides:
resetState in class Step

match

public java.lang.Boolean match(Sequence contextSequence,
                               Item contextItem)
                        throws XPathException
Specified by:
match in interface Expression
Overrides:
match in class AbstractExpression
Throws:
XPathException

matchChildren

protected java.lang.Boolean matchChildren(XQueryContext context,
                                          Sequence contextSequence)
                                   throws XPathException
Throws:
XPathException

matchAttributes

protected boolean matchAttributes(XQueryContext context,
                                  Sequence contextSequence)
                           throws XPathException
Throws:
XPathException