Xalan-Java 2.7.1: Class LocPathIterator

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xpath.axes
Class LocPathIterator

    java.lang.Object
      |
      +--org.apache.xpath.Expression
            |
            +--org.apache.xpath.patterns.NodeTest
                  |
                  +--org.apache.xpath.axes.PredicatedNodeTest
                        |
                        +--org.apache.xpath.axes.LocPathIterator

Direct Known Subclasses:
  BasicTestIterator, ChildIterator, DescendantIterator, FilterExprIteratorSimple, MatchPatternIterator, SelfIteratorNoPredicate, UnionPathIterator, WalkingIterator

public abstract class LocPathIterator
extends PredicatedNodeTest
implements java.lang.Cloneable, DTMIterator, java.io.Serializable, PathComponent

This class extends NodeSetDTM, which implements NodeIterator, and fetches nodes one at a time in document order based on a XPath

See Also:
  Serialized Form
Usage:
  **For advanced use only**

Field Summary
`int` | `m_lastFetched` The last node that was fetched, usually by nextNode.

Fields inherited from class org.apache.xpath.patterns.NodeTest
`SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_OTHER, SCORE_QNAME, SHOW_BYFUNCTION, SUPPORTS_PRE_STRIPPING, WILD`

Method Summary
`void` | `allowDetachToRelease(boolean allowRelease)` Specify if it's OK for detach to release the iterator for reuse.
`DTMIterator` | `asIterator(XPathContext xctxt, int contextNode)` Given an select expression and a context, evaluate the XPath and return the resulting iterator.
`int` | `asNode(XPathContext xctxt)` Return the first node out of the nodeset, if this expression is a nodeset expression.
`boolean` | `bool(XPathContext xctxt)` Evaluate this operation directly to a boolean.
`void` | `callVisitors(ExpressionOwner owner, XPathVisitor visitor)`
`DTMIterator` | `cloneWithReset()` Get a cloned Iterator that is reset to the beginning of the query.
`void` | `detach()` Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
`XObject` | `execute(XPathContext xctxt)` Execute this iterator, meaning create a clone that can store state, and initialize it for fast execution from the current runtime state.
`void` | `executeCharsToContentHandler(XPathContext xctxt, ContentHandler handler)` Execute an expression in the XPath runtime context, and return the result of the expression.
`int` | `getAnalysisBits()` Get the analysis bits for this walker, as defined in the WalkerFactory.
`int` | `getAxis()` Returns the axis being iterated, if it is known.
`int` | `getContext()` The node context for the iterator.
`int` | `getCurrentContextNode()` The node context from where the expression is being executed from (i.e.
`int` | `getCurrentNode()` Return the last fetched node.
`int` | `getCurrentPos()` Get the current position, which is one less than the next nextNode() call will retrieve.
`DTM` | `getDTM(int nodeHandle)` Get an instance of a DTM that "owns" a node handle.
`DTMManager` | `getDTMManager()` Get an instance of the DTMManager.
`boolean` | `getExpandEntityReferences()` The value of this flag determines whether the children of entity reference nodes are visible to the iterator.
`DTMFilter` | `getFilter()` The filter used to screen nodes.
`boolean` | `getFoundLast()` Tells if we've found the last node yet.
`boolean` | `getIsTopLevel()` Get if this is an iterator at the upper level of the XPath.
`int` | `getLastPos(XPathContext xctxt)`
`int` | `getLength()` The number of nodes in the list.
`PrefixResolver` | `getPrefixResolver()` Return the saved reference to the prefix resolver that was in effect when this iterator was created.
`int` | `getRoot()` The root node of the Iterator, as specified when it was created.
`int` | `getWhatToShow()` This attribute determines which node types are presented via the iterator.
`XPathContext` | `getXPathContext()` The XPath execution context we are operating on.
`void` | `incrementCurrentPos()` Increment the current position in the node set.
`boolean` | `isDocOrdered()` Returns true if all the nodes in the iteration well be returned in document order.
`boolean` | `isFresh()` Tells if this NodeSetDTM is "fresh", in other words, if the first nextNode() that is called will return the first node in the set.
`boolean` | `isMutable()` Tells if this iterator can have nodes added to it or set via the `setItem(int node, int index)` method.
`boolean` | `isNodesetExpr()` Tell if the expression is a nodeset expression.
`int` | `item(int index)` Returns the `index` th item in the collection.
`abstract int` | `nextNode()` Returns the next node in the set and advances the position of the iterator in the set.
`int` | `previousNode()` Returns the previous node in the set and moves the position of the iterator backwards in the set.
`void` | `reset()` Reset the iterator.
`void` | `runTo(int index)` If an index is requested, NodeSetDTM will call this method to run the iterator to the index.
`void` | `setCurrentContextNode(int n)` Set the current context node for this iterator.
`void` | `setCurrentPos(int i)` Set the current position in the node set.
`void` | `setEnvironment(java.lang.Object environment)` Set the environment in which this iterator operates, which should provide: a node (the context node...
`void` | `setIsTopLevel(boolean b)` Set if this is an iterator at the upper level of the XPath.
`void` | `setItem(int node, int index)` Sets the node at the specified index of this vector to be the specified node.
`void` | `setRoot(int context, java.lang.Object environment)` Initialize the context values for this expression after it is cloned.
`void` | `setShouldCacheNodes(boolean b)` If setShouldCacheNodes(true) is called, then nodes will be cached.
`int` | `size()` Get the length of the cached nodes.

Methods inherited from class org.apache.xpath.axes.PredicatedNodeTest
`acceptNode, callPredicateVisitors, canTraverseOutsideSubtree, clone, deepEquals, fixupVariables, getLocPathIterator, getPredicate, getPredicateCount, getPredicateIndex, getProximityPosition, getProximityPosition, initProximityPosition, isReverseAxes, resetProximityPositions, setLocPathIterator, setPredicateCount`

Methods inherited from class org.apache.xpath.patterns.NodeTest
`debugWhatToShow, execute, execute, getDefaultScore, getLocalName, getNamespace, getNodeTypeTest, getStaticScore, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShow`

Methods inherited from class org.apache.xpath.Expression
`asIteratorRaw, assertion, error, execute, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isStableNumber, num, warn, xstr`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_lastFetched

    public transient int m_lastFetched

  The last node that was fetched, usually by nextNode.

Method Detail

### getAnalysisBits

    public int getAnalysisBits()

  Get the analysis bits for this walker, as defined in the WalkerFactory.
  Specified by:
    getAnalysisBits in interface PathComponent
  Returns:
    One of WalkerFactory#BIT_DESCENDANT, etc.

### setEnvironment

    public void setEnvironment(java.lang.Object environment)

  Set the environment in which this iterator operates, which should provide: a node (the context node... same value as "root" defined below) a pair of non-zero positive integers (the context position and the context size) a set of variable bindings a function library the set of namespace declarations in scope for the expression.

  At this time the exact implementation of this environment is application dependent. Probably a proper interface will be created fairly soon.

  Parameters:
    `environment` - The environment object.

### getDTM

    public DTM getDTM(int nodeHandle)

  Get an instance of a DTM that "owns" a node handle. Since a node iterator may be passed without a DTMManager, this allows the caller to easily get the DTM using just the iterator.
  Specified by:
    getDTM in interface DTMIterator
  Parameters:
    `nodeHandle` - the nodeHandle.
  Returns:
    a non-null DTM reference.

### getDTMManager

    public DTMManager getDTMManager()

  Get an instance of the DTMManager. Since a node iterator may be passed without a DTMManager, this allows the caller to easily get the DTMManager using just the iterator.
  Specified by:
    getDTMManager in interface DTMIterator
  Returns:
    a non-null DTMManager reference.

### execute

    public XObject execute(XPathContext xctxt)
                    throws TransformerException

  Execute this iterator, meaning create a clone that can store state, and initialize it for fast execution from the current runtime state. When this is called, no actual query from the current context node is performed.
  Parameters:
    `xctxt` - The XPath execution context.
  Returns:
    An XNodeSet reference that holds this iterator.
  Throws:
    TransformerException -
  Overrides:
    execute in class NodeTest

### executeCharsToContentHandler

    public void executeCharsToContentHandler(XPathContext xctxt,
                                             ContentHandler handler)
                                      throws TransformerException,
                                             SAXException

  Execute an expression in the XPath runtime context, and return the result of the expression.
  Parameters:
    `xctxt` - The XPath runtime context.
    `handler` - The target content handler.
  Returns:
    The result of the expression in the form of a `XObject`.
  Throws:
    TransformerException - if a runtime exception occurs.
    SAXException -
  Overrides:
    executeCharsToContentHandler in class Expression

### asIterator

    public DTMIterator asIterator(XPathContext xctxt,
                                  int contextNode)
                           throws TransformerException

  Given an select expression and a context, evaluate the XPath and return the resulting iterator.
  Parameters:
    `xctxt` - The execution context.
    `contextNode` - The node that "." expresses.
  Throws:
    TransformerException - thrown if the active ProblemListener decides the error condition is severe enough to halt processing.
    TransformerException -
  Overrides:
    asIterator in class Expression
  Usage:
    **Experimental**

### isNodesetExpr

    public boolean isNodesetExpr()

  Tell if the expression is a nodeset expression.
  Returns:
    true if the expression can be represented as a nodeset.
  Overrides:
    isNodesetExpr in class Expression

### asNode

    public int asNode(XPathContext xctxt)
               throws TransformerException

  Return the first node out of the nodeset, if this expression is a nodeset expression. This is the default implementation for nodesets. Derived classes should try and override this and return a value without having to do a clone operation.
  Parameters:
    `xctxt` - The XPath runtime context.
  Returns:
    the first node out of the nodeset, or DTM.NULL.
  Overrides:
    asNode in class Expression

### bool

    public boolean bool(XPathContext xctxt)
                 throws TransformerException

  Evaluate this operation directly to a boolean.
  Parameters:
    `xctxt` - The runtime execution context.
  Returns:
    The result of the operation as a boolean.
  Throws:
    TransformerException -
  Overrides:
    bool in class Expression

### setIsTopLevel

    public void setIsTopLevel(boolean b)

  Set if this is an iterator at the upper level of the XPath.
  Parameters:
    `b` - true if this location path is at the top level of the expression.
  Usage:
    **For advanced use only**

### getIsTopLevel

    public boolean getIsTopLevel()

  Get if this is an iterator at the upper level of the XPath.
  Returns:
    true if this location path is at the top level of the expression.
  Usage:
    **For advanced use only**

### setRoot

    public void setRoot(int context,
                        java.lang.Object environment)

  Initialize the context values for this expression after it is cloned.
  Specified by:
    setRoot in interface DTMIterator
  Parameters:
    `context` - The XPath runtime context for this transformation.

### getCurrentPos

    public final int getCurrentPos()

  Get the current position, which is one less than the next nextNode() call will retrieve. i.e. if you call getCurrentPos() and the return is 0, the next fetch will take place at index 1.
  Specified by:
    getCurrentPos in interface DTMIterator
  Returns:
    A value greater than or equal to zero that indicates the next node position to fetch.

### setShouldCacheNodes

    public void setShouldCacheNodes(boolean b)

  If setShouldCacheNodes(true) is called, then nodes will be cached. They are not cached by default.
  Specified by:
    setShouldCacheNodes in interface DTMIterator
  Parameters:
    `b` - True if this iterator should cache nodes.

### isMutable

    public boolean isMutable()

  Tells if this iterator can have nodes added to it or set via the `setItem(int node, int index)` method.
  Specified by:
    isMutable in interface DTMIterator
  Returns:
    True if the nodelist can be mutated.

### setCurrentPos

    public void setCurrentPos(int i)

  Set the current position in the node set.
  Specified by:
    setCurrentPos in interface DTMIterator
  Parameters:
    `i` - Must be a valid index greater than or equal to zero and less than m_cachedNodes.size().

### incrementCurrentPos

    public void incrementCurrentPos()

  Increment the current position in the node set.

### size

    public int size()

  Get the length of the cached nodes.

  Note: for the moment at least, this only returns the size of the nodes that have been fetched to date, it doesn't attempt to run to the end to make sure we have found everything. This should be reviewed.

  Returns:
    The size of the current cache list.

### item

    public int item(int index)

  Returns the `index` th item in the collection. If `index` is greater than or equal to the number of nodes in the list, this returns `null` .
  Specified by:
    item in interface DTMIterator
  Parameters:
    `index` - Index into the collection.
  Returns:
    The node at the `index` th position in the `NodeList` , or `null` if that is not a valid index.

### setItem

    public void setItem(int node,
                        int index)

  Sets the node at the specified index of this vector to be the specified node. The previous component at that position is discarded.

  The index must be a value greater than or equal to 0 and less than the current size of the vector. The iterator must be in cached mode.

  Meant to be used for sorted iterators.

  Specified by:
    setItem in interface DTMIterator
  Parameters:
    `node` - Node to set
    `index` - Index of where to set the node

### getLength

    public int getLength()

  The number of nodes in the list. The range of valid child node indices is 0 to `length-1` inclusive.
  Specified by:
    getLength in interface DTMIterator
  Returns:
    The number of nodes in the list, always greater or equal to zero.

### isFresh

    public boolean isFresh()

  Tells if this NodeSetDTM is "fresh", in other words, if the first nextNode() that is called will return the first node in the set.
  Specified by:
    isFresh in interface DTMIterator
  Returns:
    true of nextNode has not been called.

### previousNode

    public int previousNode()

  Returns the previous node in the set and moves the position of the iterator backwards in the set.
  Specified by:
    previousNode in interface DTMIterator
  Returns:
    The previous `Node` in the set being iterated over, or`null` if there are no more members in that set.

### getWhatToShow

    public int getWhatToShow()

  This attribute determines which node types are presented via the iterator. The available set of constants is defined in the `NodeFilter` interface.

  This is somewhat useless at this time, since it doesn't really return information that tells what this iterator will show. It is here only to fullfill the DOM NodeIterator interface.

  Specified by:
    getWhatToShow in interface DTMIterator
  Returns:
    For now, always NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_ENTITY_REFERENCE.
  Overrides:
    getWhatToShow in class NodeTest
  See Also:
    `NodeIterator`

### getFilter

    public DTMFilter getFilter()

  The filter used to screen nodes. Not used at this time, this is here only to fullfill the DOM NodeIterator interface.
  Returns:
    Always null.
  See Also:
    `NodeIterator`

### getRoot

    public int getRoot()

  The root node of the Iterator, as specified when it was created.
  Specified by:
    getRoot in interface DTMIterator
  Returns:
    The "root" of this iterator, which, in XPath terms, is the node context for this iterator.

### getExpandEntityReferences

    public boolean getExpandEntityReferences()

  The value of this flag determines whether the children of entity reference nodes are visible to the iterator. If false, they will be skipped over.
  To produce a view of the document that has entity references expanded and does not expose the entity reference node itself, use the whatToShow flags to hide the entity reference node and set expandEntityReferences to true when creating the iterator. To produce a view of the document that has entity reference nodes but no entity expansion, use the whatToShow flags to show the entity reference node and set expandEntityReferences to false.
  Specified by:
    getExpandEntityReferences in interface DTMIterator
  Returns:
    Always true, since entity reference nodes are not visible in the XPath model.

### allowDetachToRelease

    public void allowDetachToRelease(boolean allowRelease)

  Specify if it's OK for detach to release the iterator for reuse.
  Specified by:
    allowDetachToRelease in interface DTMIterator
  Parameters:
    `allowRelease` - true if it is OK for detach to release this iterator for pooling.

### detach

    public void detach()

  Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. After`detach` has been invoked, calls to `nextNode` or`previousNode` will raise the exception INVALID_STATE_ERR.
  Specified by:
    detach in interface DTMIterator

### reset

    public void reset()

  Reset the iterator.
  Specified by:
    reset in interface DTMIterator

### cloneWithReset

    public DTMIterator cloneWithReset()
                               throws java.lang.CloneNotSupportedException

  Get a cloned Iterator that is reset to the beginning of the query.
  Specified by:
    cloneWithReset in interface DTMIterator
  Returns:
    A cloned NodeIterator set of the start of the query.
  Throws:
    java.lang.CloneNotSupportedException -

### nextNode

    public abstract int nextNode()

  Returns the next node in the set and advances the position of the iterator in the set. After a NodeIterator is created, the first call to nextNode() returns the first node in the set.
  Specified by:
    nextNode in interface DTMIterator
  Returns:
    The next `Node` in the set being iterated over, or `null` if there are no more members in that set.

### getCurrentNode

    public int getCurrentNode()

  Return the last fetched node. Needed to support the UnionPathIterator.
  Specified by:
    getCurrentNode in interface DTMIterator
  Returns:
    The last fetched node, or null if the last fetch was null.

### runTo

    public void runTo(int index)

  If an index is requested, NodeSetDTM will call this method to run the iterator to the index. By default this sets m_next to the index. If the index argument is -1, this signals that the iterator should be run to the end.
  Specified by:
    runTo in interface DTMIterator
  Parameters:
    `index` - The index to run to, or -1 if the iterator should run to the end.

### getFoundLast

    public final boolean getFoundLast()

  Tells if we've found the last node yet.
  Returns:
    true if the last nextNode returned null.

### getXPathContext

    public final XPathContext getXPathContext()

  The XPath execution context we are operating on.
  Returns:
    XPath execution context this iterator is operating on, or null if setRoot has not been called.

### getContext

    public final int getContext()

  The node context for the iterator.
  Returns:
    The node context, same as getRoot().

### getCurrentContextNode

    public final int getCurrentContextNode()

  The node context from where the expression is being executed from (i.e. for current() support).
  Returns:
    The top-level node context of the entire expression.

### setCurrentContextNode

    public final void setCurrentContextNode(int n)

  Set the current context node for this iterator.
  Parameters:
    `n` - Must be a non-null reference to the node context.

### getPrefixResolver

    public final PrefixResolver getPrefixResolver()

  Return the saved reference to the prefix resolver that was in effect when this iterator was created.
  Returns:
    The prefix resolver or this iterator, which may be null.

### callVisitors

    public void callVisitors(ExpressionOwner owner,
                             XPathVisitor visitor)

  Overrides:
    callVisitors in class NodeTest
  See Also:
    `XPathVisitable.callVisitors(ExpressionOwner, XPathVisitor)`

### isDocOrdered

    public boolean isDocOrdered()

  Returns true if all the nodes in the iteration well be returned in document order.
  Specified by:
    isDocOrdered in interface DTMIterator
  Returns:
    true as a default.

### getAxis

    public int getAxis()

  Returns the axis being iterated, if it is known.
  Specified by:
    getAxis in interface DTMIterator
  Returns:
    Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.

### getLastPos

    public int getLastPos(XPathContext xctxt)

  Overrides:
    getLastPos in class PredicatedNodeTest
  See Also:
    `PredicatedNodeTest.getLastPos(XPathContext)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 Apache XML Project. All Rights Reserved.