org.apache.xpath.axes

Class WalkerFactory

public class WalkerFactory extends Object

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 intBITMASK_TRAVERSES_OUTSIDE_SUBTREE
If any of these bits are on, the expression may likely traverse outside the given subtree.
static intBITS_COUNT
First 8 bits are the number of top-level location steps.
static intBITS_RESERVED
4 bits are reserved for future use.
static intBIT_ANCESTOR
Bit is on if any of the walkers contain an ancestor step.
static intBIT_ANCESTOR_OR_SELF
Bit is on if any of the walkers contain an ancestor-or-self step.
static intBIT_ANY_DESCENDANT_FROM_ROOT
Found "//foo" pattern
static intBIT_ATTRIBUTE
Bit is on if any of the walkers contain an attribute step.
static intBIT_BACKWARDS_SELF
Bit is on if any of the walkers can go backwards in document order from the context node.
static intBIT_CHILD
Bit is on if any of the walkers contain a child step.
static intBIT_DESCENDANT
Bit is on if any of the walkers contain a descendant step.
static intBIT_DESCENDANT_OR_SELF
Bit is on if any of the walkers contain a descendant-or-self step.
static intBIT_FILTER
Bit is on if any of the walkers contain a filter (i.e. id(), extension function, etc.) step.
static intBIT_FOLLOWING
Bit is on if any of the walkers contain a following step.
static intBIT_FOLLOWING_SIBLING
Bit is on if any of the walkers contain a following-sibiling step.
static intBIT_MATCH_PATTERN
Bit is on if the expression is a match pattern.
static intBIT_NAMESPACE
Bit is on if any of the walkers contain a namespace step.
static intBIT_NODETEST_ANY
Bit is on if any of the walkers contain an node() test.
static intBIT_PARENT
Bit is on if any of the walkers contain a parent step.
static intBIT_PRECEDING
Bit is on if any of the walkers contain a preceding step.
static intBIT_PRECEDING_SIBLING
Bit is on if any of the walkers contain a preceding-sibling step.
static intBIT_PREDICATE
Bit is on if the expression contains a top-level predicate.
static intBIT_ROOT
Bit is on if any of the walkers contain a root step.
static intBIT_SELF
Bit is on if any of the walkers contain a self step.
Method Summary
static booleancanCrissCross(int analysis)
static booleancanSkipSubtrees(int analysis)
static voiddiagnoseIterator(String name, int analysis, Compiler compiler)
static intgetAnalysisBitFromAxes(int axis)
Get a corresponding BIT_XXX from an axis.
static StringgetAnalysisString(int analysis)
static intgetAxisFromStep(Compiler compiler, int stepOpCodePos)
Special purpose function to see if we can optimize the pattern for a DescendantIterator.
static intgetStepCount(int analysis)
static booleanhasPredicate(int analysis)
static booleanisAbsolute(int analysis)
static booleanisDownwardAxisOfMany(int axis)
Tell if the given axis goes downword.
static booleanisNaturalDocOrder(int analysis)
Tell if the pattern can be 'walked' with the iteration steps in natural document order, without duplicates.
static booleanisOneStep(int analysis)
static booleanisSet(int analysis, int bits)
static booleanisWild(int analysis)
static booleanmightBeProximate(Compiler compiler, int opPos, int stepType)
Tell if the predicates need to have proximity knowledge.
static DTMIteratornewDTMIterator(Compiler compiler, int opPos, boolean isTopLevel)
Create a new LocPathIterator iterator.
static booleanwalksAncestors(int analysis)
static booleanwalksAttributes(int analysis)
static booleanwalksChildren(int analysis)
static booleanwalksChildrenAndExtraAndSelfOnly(int analysis)
static booleanwalksChildrenOnly(int analysis)
static booleanwalksDescendants(int analysis)
static booleanwalksDescendantsAndExtraAndSelfOnly(int analysis)
static booleanwalksDownExtraOnly(int analysis)
static booleanwalksDownOnly(int analysis)
static booleanwalksExtraNodes(int analysis)
static booleanwalksExtraNodesOnly(int analysis)
static booleanwalksFilteredList(int analysis)
static booleanwalksFollowingOnlyMaybeAbsolute(int analysis)
static booleanwalksInDocOrder(int analysis)
static booleanwalksNamespaces(int analysis)
static booleanwalksSelfOnly(int analysis)
static booleanwalksSideways(int analysis)
static booleanwalksSubtree(int analysis)
static booleanwalksSubtreeOnly(int analysis)
static booleanwalksSubtreeOnlyFromRootOrContext(int analysis)
static booleanwalksSubtreeOnlyMaybeAbsolute(int analysis)
static booleanwalksUp(int analysis)
static booleanwalksUpOnly(int analysis)

Field Detail

BITMASK_TRAVERSES_OUTSIDE_SUBTREE

public static final int BITMASK_TRAVERSES_OUTSIDE_SUBTREE
If any of these bits are on, the expression may likely traverse outside the given subtree.

BITS_COUNT

public static final int BITS_COUNT
First 8 bits are the number of top-level location steps. Hopefully there will never be more that 255 location steps!!!

BITS_RESERVED

public static final int BITS_RESERVED
4 bits are reserved for future use.

BIT_ANCESTOR

public static final int BIT_ANCESTOR
Bit is on if any of the walkers contain an ancestor step.

BIT_ANCESTOR_OR_SELF

public static final int BIT_ANCESTOR_OR_SELF
Bit is on if any of the walkers contain an ancestor-or-self step.

BIT_ANY_DESCENDANT_FROM_ROOT

public static final int BIT_ANY_DESCENDANT_FROM_ROOT
Found "//foo" pattern

BIT_ATTRIBUTE

public static final int BIT_ATTRIBUTE
Bit is on if any of the walkers contain an attribute step.

BIT_BACKWARDS_SELF

public static final int BIT_BACKWARDS_SELF
Bit is on if any of the walkers can go backwards in document order from the context node.

BIT_CHILD

public static final int BIT_CHILD
Bit is on if any of the walkers contain a child step.

BIT_DESCENDANT

public static final int BIT_DESCENDANT
Bit is on if any of the walkers contain a descendant step.

BIT_DESCENDANT_OR_SELF

public static final int BIT_DESCENDANT_OR_SELF
Bit is on if any of the walkers contain a descendant-or-self step.

BIT_FILTER

public static final int BIT_FILTER
Bit is on if any of the walkers contain a filter (i.e. id(), extension function, etc.) step.

BIT_FOLLOWING

public static final int BIT_FOLLOWING
Bit is on if any of the walkers contain a following step.

BIT_FOLLOWING_SIBLING

public static final int BIT_FOLLOWING_SIBLING
Bit is on if any of the walkers contain a following-sibiling step.

BIT_MATCH_PATTERN

public static final int BIT_MATCH_PATTERN
Bit is on if the expression is a match pattern.

BIT_NAMESPACE

public static final int BIT_NAMESPACE
Bit is on if any of the walkers contain a namespace step.

BIT_NODETEST_ANY

public static final int BIT_NODETEST_ANY
Bit is on if any of the walkers contain an node() test. This is really only useful if the count is 1.

BIT_PARENT

public static final int BIT_PARENT
Bit is on if any of the walkers contain a parent step.

BIT_PRECEDING

public static final int BIT_PRECEDING
Bit is on if any of the walkers contain a preceding step.

BIT_PRECEDING_SIBLING

public static final int BIT_PRECEDING_SIBLING
Bit is on if any of the walkers contain a preceding-sibling step.

BIT_PREDICATE

public static final int BIT_PREDICATE
Bit is on if the expression contains a top-level predicate.

BIT_ROOT

public static final int BIT_ROOT
Bit is on if any of the walkers contain a root step.

BIT_SELF

public static final int BIT_SELF
Bit is on if any of the walkers contain a self step.

Method Detail

canCrissCross

public static boolean canCrissCross(int analysis)

canSkipSubtrees

public static boolean canSkipSubtrees(int analysis)

diagnoseIterator

public static void diagnoseIterator(String name, int analysis, Compiler compiler)

getAnalysisBitFromAxes

public static int getAnalysisBitFromAxes(int axis)
Get a corresponding BIT_XXX from an axis.

Parameters: axis One of Axis.ANCESTOR, etc.

Returns: One of BIT_ANCESTOR, etc.

getAnalysisString

public static String getAnalysisString(int analysis)

getAxisFromStep

public static int getAxisFromStep(Compiler compiler, int stepOpCodePos)
Special purpose function to see if we can optimize the pattern for a DescendantIterator.

Parameters: compiler non-null reference to compiler object that has processed the XPath operations into an opcode map. stepOpCodePos The opcode position for the step.

Returns: 32 bits as an integer that give information about the location path as a whole.

Throws: javax.xml.transform.TransformerException

getStepCount

public static int getStepCount(int analysis)

hasPredicate

public static boolean hasPredicate(int analysis)

isAbsolute

public static boolean isAbsolute(int analysis)

isDownwardAxisOfMany

public static boolean isDownwardAxisOfMany(int axis)
Tell if the given axis goes downword. Bogus name, if you can think of a better one, please do tell. This really has to do with inverting attribute axis.

Parameters: axis One of Axis.XXX.

Returns: true if the axis is not a child axis and does not go up from the axis root.

isNaturalDocOrder

public static boolean isNaturalDocOrder(int analysis)
Tell if the pattern can be 'walked' with the iteration steps in natural document order, without duplicates.

Parameters: analysis The general analysis of the pattern.

Returns: true if the walk can be done in natural order.

Throws: javax.xml.transform.TransformerException

isOneStep

public static boolean isOneStep(int analysis)

isSet

public static boolean isSet(int analysis, int bits)

isWild

public static boolean isWild(int analysis)

mightBeProximate

public static boolean mightBeProximate(Compiler compiler, int opPos, int stepType)
Tell if the predicates need to have proximity knowledge.

newDTMIterator

public static DTMIterator newDTMIterator(Compiler compiler, int opPos, boolean isTopLevel)
Create a new LocPathIterator iterator. The exact type of iterator returned is based on an analysis of the XPath operations.

Parameters: 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.

Returns: non-null reference to a LocPathIterator or derivative.

Throws: javax.xml.transform.TransformerException

walksAncestors

public static boolean walksAncestors(int analysis)

walksAttributes

public static boolean walksAttributes(int analysis)

walksChildren

public static boolean walksChildren(int analysis)

walksChildrenAndExtraAndSelfOnly

public static boolean walksChildrenAndExtraAndSelfOnly(int analysis)

walksChildrenOnly

public static boolean walksChildrenOnly(int analysis)

walksDescendants

public static boolean walksDescendants(int analysis)

walksDescendantsAndExtraAndSelfOnly

public static boolean walksDescendantsAndExtraAndSelfOnly(int analysis)

walksDownExtraOnly

public static boolean walksDownExtraOnly(int analysis)

walksDownOnly

public static boolean walksDownOnly(int analysis)

walksExtraNodes

public static boolean walksExtraNodes(int analysis)

walksExtraNodesOnly

public static boolean walksExtraNodesOnly(int analysis)

walksFilteredList

public static boolean walksFilteredList(int analysis)

walksFollowingOnlyMaybeAbsolute

public static boolean walksFollowingOnlyMaybeAbsolute(int analysis)

walksInDocOrder

public static boolean walksInDocOrder(int analysis)

walksNamespaces

public static boolean walksNamespaces(int analysis)

walksSelfOnly

public static boolean walksSelfOnly(int analysis)

walksSideways

public static boolean walksSideways(int analysis)

walksSubtree

public static boolean walksSubtree(int analysis)

walksSubtreeOnly

public static boolean walksSubtreeOnly(int analysis)

walksSubtreeOnlyFromRootOrContext

public static boolean walksSubtreeOnlyFromRootOrContext(int analysis)

walksSubtreeOnlyMaybeAbsolute

public static boolean walksSubtreeOnlyMaybeAbsolute(int analysis)

walksUp

public static boolean walksUp(int analysis)

walksUpOnly

public static boolean walksUpOnly(int analysis)
Copyright B) 2005 Apache XML Project. All Rights Reserved.