java.lang.Object
org.apache.xml.dtm.ref.DTMAxisIteratorBase
org.apache.xalan.xsltc.dom.MatchingIterator
- All Implemented Interfaces:
- java.lang.Cloneable, org.apache.xml.dtm.DTMAxisIterator
- public final class MatchingIterator
- extends org.apache.xml.dtm.ref.DTMAxisIteratorBase
This is a special kind of iterator that takes a source iterator and a
node N. If initialized with a node M (the parent of N) it computes the
position of N amongst the children of M. This position can be obtained
by calling getPosition().
It is an iterator even though next() will never be called. It is used to
match patterns with a single predicate like:
BOOK[position() = last()]
In this example, the source iterator will return elements of type BOOK,
a call to position() will return the position of N. Notice that because
of the way the pattern matching is implemented, N will always be a node
in the source since (i) it is a BOOK or the test sequence would not be
considered and (ii) the source iterator is initialized with M which is
the parent of N. Also, and still in this example, a call to last() will
return the number of elements in the source (i.e. the number of BOOKs).
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_source
private org.apache.xml.dtm.DTMAxisIterator _source
- A reference to a source iterator.
_match
private final int _match
- The node to match.
MatchingIterator
public MatchingIterator(int match,
org.apache.xml.dtm.DTMAxisIterator source)
setRestartable
public void setRestartable(boolean isRestartable)
- Description copied from interface:
org.apache.xml.dtm.DTMAxisIterator
- Set if restartable.
cloneIterator
public org.apache.xml.dtm.DTMAxisIterator cloneIterator()
- Description copied from class:
org.apache.xml.dtm.ref.DTMAxisIteratorBase
- Returns a deep copy of this iterator. Cloned iterators may not be
restartable. The iterator being cloned may or may not become
non-restartable as a side effect of this operation.
setStartNode
public org.apache.xml.dtm.DTMAxisIterator setStartNode(int node)
- Description copied from interface:
org.apache.xml.dtm.DTMAxisIterator
- Set start to END should 'close' the iterator,
i.e. subsequent call to next() should return END.
reset
public org.apache.xml.dtm.DTMAxisIterator reset()
- Description copied from interface:
org.apache.xml.dtm.DTMAxisIterator
- Resets the iterator to the last start node.
next
public int next()
- Description copied from interface:
org.apache.xml.dtm.DTMAxisIterator
- Get the next node in the iteration.
getLast
public int getLast()
- Description copied from class:
org.apache.xml.dtm.ref.DTMAxisIteratorBase
- Returns the position of the last node within the iteration, as
defined by XPath. In a forward iterator, I believe this equals the number of nodes which this
iterator will yield. In a reverse iterator, I believe it should return
1 (since the "last" is the first produced.)
This may be an expensive operation when called the first time, since
it may have to iterate through a large part of the document to produce
its answer.
getPosition
public int getPosition()
setMark
public void setMark()
- Description copied from interface:
org.apache.xml.dtm.DTMAxisIterator
- Remembers the current node for the next call to gotoMark().
gotoMark
public void gotoMark()
- Description copied from interface:
org.apache.xml.dtm.DTMAxisIterator
- Restores the current node remembered by setMark().