|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xpath.axes.WalkerFactory
This class is both a factory for XPath location path expressions, which are built from the opcode map output, and an analysis engine for the location path expressions in order to provide optimization hints.
Field Summary | |
static int |
BIT_ANCESTOR
Bit is on if any of the walkers contain an ancestor step. |
static int |
BIT_ANCESTOR_OR_SELF
Bit is on if any of the walkers contain an ancestor-or-self step. |
static int |
BIT_ANY_DESCENDANT_FROM_ROOT
Found "//foo" pattern |
static int |
BIT_ATTRIBUTE
Bit is on if any of the walkers contain an attribute step. |
static int |
BIT_BACKWARDS_SELF
Bit is on if any of the walkers can go backwards in document order from the context node. |
static int |
BIT_CHILD
Bit is on if any of the walkers contain a child step. |
static int |
BIT_DESCENDANT
Bit is on if any of the walkers contain a descendant step. |
static int |
BIT_DESCENDANT_OR_SELF
Bit is on if any of the walkers contain a descendant-or-self step. |
static int |
BIT_FILTER
Bit is on if any of the walkers contain a filter (i.e. id(), extension function, etc.) step. |
static int |
BIT_FOLLOWING
Bit is on if any of the walkers contain a following step. |
static int |
BIT_FOLLOWING_SIBLING
Bit is on if any of the walkers contain a following-sibiling step. |
static int |
BIT_MATCH_PATTERN
Bit is on if the expression is a match pattern. |
static int |
BIT_NAMESPACE
Bit is on if any of the walkers contain a namespace step. |
static int |
BIT_NODETEST_ANY
Bit is on if any of the walkers contain an node() test. |
static int |
BIT_PARENT
Bit is on if any of the walkers contain a parent step. |
static int |
BIT_PRECEDING
Bit is on if any of the walkers contain a preceding step. |
static int |
BIT_PRECEDING_SIBLING
Bit is on if any of the walkers contain a preceding-sibling step. |
static int |
BIT_PREDICATE
Bit is on if the expression contains a top-level predicate. |
static int |
BIT_ROOT
Bit is on if any of the walkers contain a root step. |
static int |
BIT_SELF
Bit is on if any of the walkers contain a self step. |
static int |
BITMASK_TRAVERSES_OUTSIDE_SUBTREE
If any of these bits are on, the expression may likely traverse outside the given subtree. |
static int |
BITS_COUNT
First 8 bits are the number of top-level location steps. |
static int |
BITS_RESERVED
4 bits are reserved for future use. |
(package private) static boolean |
DEBUG_ITERATOR_CREATION
Set to true for diagnostics about iterator creation |
(package private) static boolean |
DEBUG_PATTERN_CREATION
Set to true for diagnostics about walker creation |
(package private) static boolean |
DEBUG_WALKER_CREATION
Set to true for diagnostics about walker creation |
Constructor Summary | |
WalkerFactory()
|
Method Summary | |
private static int |
analyze(Compiler compiler,
int stepOpCodePos,
int stepIndex)
Analyze the location path and return 32 bits that give information about the location path as a whole. |
(package private) static boolean |
analyzePredicate(Compiler compiler,
int opPos,
int stepType)
Analyze a step and give information about it's predicates. |
static boolean |
canCrissCross(int analysis)
|
static boolean |
canSkipSubtrees(int analysis)
|
private static StepPattern |
createDefaultStepPattern(Compiler compiler,
int opPos,
MatchPatternIterator mpi,
int analysis,
StepPattern tail,
StepPattern head)
Create a StepPattern that is contained within a LocationPath. |
private static AxesWalker |
createDefaultWalker(Compiler compiler,
int opPos,
WalkingIterator lpi,
int analysis)
Create the proper Walker from the axes type. |
static void |
diagnoseIterator(String name,
int analysis,
Compiler compiler)
|
(package private) static boolean |
functionProximateOrContainsProximate(Compiler compiler,
int opPos)
|
static int |
getAnalysisBitFromAxes(int axis)
Get a corresponding BIT_XXX from an axis. |
static String |
getAnalysisString(int analysis)
|
static int |
getAxisFromStep(Compiler compiler,
int stepOpCodePos)
Special purpose function to see if we can optimize the pattern for a DescendantIterator. |
static int |
getStepCount(int analysis)
|
static boolean |
hasPredicate(int analysis)
|
static boolean |
isAbsolute(int analysis)
|
static boolean |
isDownwardAxisOfMany(int axis)
Tell if the given axis goes downword. |
private static boolean |
isNaturalDocOrder(Compiler compiler,
int stepOpCodePos,
int stepIndex,
int analysis)
Tell if the pattern can be 'walked' with the iteration steps in natural document order, without duplicates. |
static boolean |
isNaturalDocOrder(int analysis)
Tell if the pattern can be 'walked' with the iteration steps in natural document order, without duplicates. |
static boolean |
isOneStep(int analysis)
|
private static boolean |
isOptimizableForDescendantIterator(Compiler compiler,
int stepOpCodePos,
int stepIndex)
Special purpose function to see if we can optimize the pattern for a DescendantIterator. |
(package private) static boolean |
isProximateInnerExpr(Compiler compiler,
int opPos)
|
static boolean |
isSet(int analysis,
int bits)
|
static boolean |
isWild(int analysis)
|
(package private) static AxesWalker |
loadOneWalker(WalkingIterator lpi,
Compiler compiler,
int stepOpCodePos)
This method is for building an array of possible levels where the target element(s) could be found for a match. |
(package private) static StepPattern |
loadSteps(MatchPatternIterator mpi,
Compiler compiler,
int stepOpCodePos,
int stepIndex)
Read a LocationPath as a generalized match pattern. |
(package private) static AxesWalker |
loadWalkers(WalkingIterator lpi,
Compiler compiler,
int stepOpCodePos,
int stepIndex)
This method is for building an array of possible levels where the target element(s) could be found for a match. |
static boolean |
mightBeProximate(Compiler compiler,
int opPos,
int stepType)
Tell if the predicates need to have proximity knowledge. |
static DTMIterator |
newDTMIterator(Compiler compiler,
int opPos,
boolean isTopLevel)
Create a new LocPathIterator iterator. |
static boolean |
walksAncestors(int analysis)
|
static boolean |
walksAttributes(int analysis)
|
static boolean |
walksChildren(int analysis)
|
static boolean |
walksChildrenAndExtraAndSelfOnly(int analysis)
|
static boolean |
walksChildrenOnly(int analysis)
|
static boolean |
walksDescendants(int analysis)
|
static boolean |
walksDescendantsAndExtraAndSelfOnly(int analysis)
|
static boolean |
walksDownExtraOnly(int analysis)
|
static boolean |
walksDownOnly(int analysis)
|
static boolean |
walksExtraNodes(int analysis)
|
static boolean |
walksExtraNodesOnly(int analysis)
|
static boolean |
walksFilteredList(int analysis)
|
static boolean |
walksFollowingOnlyMaybeAbsolute(int analysis)
|
static boolean |
walksInDocOrder(int analysis)
|
static boolean |
walksNamespaces(int analysis)
|
static boolean |
walksSelfOnly(int analysis)
|
static boolean |
walksSideways(int analysis)
|
static boolean |
walksSubtree(int analysis)
|
static boolean |
walksSubtreeOnly(int analysis)
|
static boolean |
walksSubtreeOnlyFromRootOrContext(int analysis)
|
static boolean |
walksSubtreeOnlyMaybeAbsolute(int analysis)
|
static boolean |
walksUp(int analysis)
|
static boolean |
walksUpOnly(int analysis)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final boolean DEBUG_PATTERN_CREATION
static final boolean DEBUG_WALKER_CREATION
static final boolean DEBUG_ITERATOR_CREATION
public static final int BITS_COUNT
public static final int BITS_RESERVED
public static final int BIT_PREDICATE
public static final int BIT_ANCESTOR
public static final int BIT_ANCESTOR_OR_SELF
public static final int BIT_ATTRIBUTE
public static final int BIT_CHILD
public static final int BIT_DESCENDANT
public static final int BIT_DESCENDANT_OR_SELF
public static final int BIT_FOLLOWING
public static final int BIT_FOLLOWING_SIBLING
public static final int BIT_NAMESPACE
public static final int BIT_PARENT
public static final int BIT_PRECEDING
public static final int BIT_PRECEDING_SIBLING
public static final int BIT_SELF
public static final int BIT_FILTER
public static final int BIT_ROOT
public static final int BITMASK_TRAVERSES_OUTSIDE_SUBTREE
public static final int BIT_BACKWARDS_SELF
public static final int BIT_ANY_DESCENDANT_FROM_ROOT
public static final int BIT_NODETEST_ANY
public static final int BIT_MATCH_PATTERN
Constructor Detail |
public WalkerFactory()
Method Detail |
static AxesWalker loadOneWalker(WalkingIterator lpi, Compiler compiler, int stepOpCodePos) throws javax.xml.transform.TransformerException
lpi
- The owning location path iterator.compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.stepOpCodePos
- The opcode position for the step.
javax.xml.transform.TransformerException
static AxesWalker loadWalkers(WalkingIterator lpi, Compiler compiler, int stepOpCodePos, int stepIndex) throws javax.xml.transform.TransformerException
lpi
- The owning location path iterator object.compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.stepOpCodePos
- The opcode position for the step.stepIndex
- The top-level step index withing the iterator.
javax.xml.transform.TransformerException
public static boolean isSet(int analysis, int bits)
public static void diagnoseIterator(String name, int analysis, Compiler compiler)
public static DTMIterator newDTMIterator(Compiler compiler, int opPos, boolean isTopLevel) throws javax.xml.transform.TransformerException
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.opPos
- The position of the operation code for this itterator.
javax.xml.transform.TransformerException
public static int getAxisFromStep(Compiler compiler, int stepOpCodePos) throws javax.xml.transform.TransformerException
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.stepOpCodePos
- The opcode position for the step.
javax.xml.transform.TransformerException
public static int getAnalysisBitFromAxes(int axis)
axis
- One of Axis.ANCESTOR, etc.
static boolean functionProximateOrContainsProximate(Compiler compiler, int opPos)
static boolean isProximateInnerExpr(Compiler compiler, int opPos)
public static boolean mightBeProximate(Compiler compiler, int opPos, int stepType) throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
private static boolean isOptimizableForDescendantIterator(Compiler compiler, int stepOpCodePos, int stepIndex) throws javax.xml.transform.TransformerException
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.stepOpCodePos
- The opcode position for the step.stepIndex
- The top-level step index withing the iterator.
javax.xml.transform.TransformerException
private static int analyze(Compiler compiler, int stepOpCodePos, int stepIndex) throws javax.xml.transform.TransformerException
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.stepOpCodePos
- The opcode position for the step.stepIndex
- The top-level step index withing the iterator.
javax.xml.transform.TransformerException
public static boolean isDownwardAxisOfMany(int axis)
axis
- One of Axis.XXX.
static StepPattern loadSteps(MatchPatternIterator mpi, Compiler compiler, int stepOpCodePos, int stepIndex) throws javax.xml.transform.TransformerException
So, the selection "foo/daz[2]" is, in non-abreviated expanded syntax, "self::node()/following-sibling::foo/child::daz[position()=2]". Taking this as a match pattern for a probable node, it works out to "self::daz/parent::foo[child::daz[position()=2 and isPrevStepNode()] precedingSibling::node()[isContextNodeOfLocationPath()]", adding magic isPrevStepNode and isContextNodeOfLocationPath operations. Predicates in the location path have to be executed by the following step, because they have to know the context of their execution.
mpi
- The MatchPatternIterator to which the steps will be attached.compiler
- The compiler that holds the syntax tree/op map to
construct from.stepOpCodePos
- The current op code position within the opmap.stepIndex
- The top-level step index withing the iterator.
javax.xml.transform.TransformerException
private static StepPattern createDefaultStepPattern(Compiler compiler, int opPos, MatchPatternIterator mpi, int analysis, StepPattern tail, StepPattern head) throws javax.xml.transform.TransformerException
compiler
- The compiler that holds the syntax tree/op map to
construct from.mpi
- The MatchPatternIterator to which the steps will be attached.analysis
- 32 bits of analysis, from which the type of AxesWalker
may be influenced.tail
- The step that is the first step analyzed, but the last
step in the relative match linked list, i.e. the tail.
May be null.head
- The step that is the current head of the relative
match step linked list.
May be null.
javax.xml.transform.TransformerException
static boolean analyzePredicate(Compiler compiler, int opPos, int stepType) throws javax.xml.transform.TransformerException
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.opPos
- The opcode position for the step.stepType
- The type of step, one of OP_GROUP, etc.
javax.xml.transform.TransformerException
private static AxesWalker createDefaultWalker(Compiler compiler, int opPos, WalkingIterator lpi, int analysis)
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.opPos
- The opcode position for the step.lpi
- The owning location path iterator.analysis
- 32 bits of analysis, from which the type of AxesWalker
may be influenced.
RuntimeException
- if the input is bad.public static String getAnalysisString(int analysis)
public static boolean hasPredicate(int analysis)
public static boolean isWild(int analysis)
public static boolean walksAncestors(int analysis)
public static boolean walksAttributes(int analysis)
public static boolean walksNamespaces(int analysis)
public static boolean walksChildren(int analysis)
public static boolean walksDescendants(int analysis)
public static boolean walksSubtree(int analysis)
public static boolean walksSubtreeOnlyMaybeAbsolute(int analysis)
public static boolean walksSubtreeOnly(int analysis)
public static boolean walksFilteredList(int analysis)
public static boolean walksSubtreeOnlyFromRootOrContext(int analysis)
public static boolean walksInDocOrder(int analysis)
public static boolean walksFollowingOnlyMaybeAbsolute(int analysis)
public static boolean walksUp(int analysis)
public static boolean walksSideways(int analysis)
public static boolean walksExtraNodes(int analysis)
public static boolean walksExtraNodesOnly(int analysis)
public static boolean isAbsolute(int analysis)
public static boolean walksChildrenOnly(int analysis)
public static boolean walksChildrenAndExtraAndSelfOnly(int analysis)
public static boolean walksDescendantsAndExtraAndSelfOnly(int analysis)
public static boolean walksSelfOnly(int analysis)
public static boolean walksUpOnly(int analysis)
public static boolean walksDownOnly(int analysis)
public static boolean walksDownExtraOnly(int analysis)
public static boolean canSkipSubtrees(int analysis)
public static boolean canCrissCross(int analysis)
public static boolean isNaturalDocOrder(int analysis)
analysis
- The general analysis of the pattern.
javax.xml.transform.TransformerException
private static boolean isNaturalDocOrder(Compiler compiler, int stepOpCodePos, int stepIndex, int analysis) throws javax.xml.transform.TransformerException
compiler
- non-null reference to compiler object that has processed
the XPath operations into an opcode map.stepOpCodePos
- The opcode position for the step.stepIndex
- The top-level step index withing the iterator.analysis
- The general analysis of the pattern.
javax.xml.transform.TransformerException
public static boolean isOneStep(int analysis)
public static int getStepCount(int analysis)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |