APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.dom

public final Class MatchingIterator

extends DTMAxisIteratorBase
Class Inheritance
Imports
com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary, com.sun.org.apache.xml.internal.dtm.DTMAxisIterator, com.sun.org.apache.xml.internal.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).
Authors
Jacek Ambroziak, Santiago Pericas-Geertsen

Field Summary

Modifier and TypeField and Description
private final int
_match

The node to match.

private DTMAxisIterator
_source

A reference to a source iterator.

Inherited from com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase:
_includeSelf_isRestartable_last_markedNode_position_startNode

Constructor Summary

AccessConstructor and Description
public
MatchingIterator(int match, DTMAxisIterator source)

Method Summary

Modifier and TypeMethod and Description
public DTMAxisIterator
public int
getLast()

Overrides com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.getLast.

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.getLast.

Returns the position of the last node within the iteration, as defined by XPath.

public int
public void
gotoMark()

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.gotoMark.

Restores the current node remembered by setMark().

public int
next()

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.next.

Get the next node in the iteration.

public DTMAxisIterator
public void
setMark()

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setMark.

Remembers the current node for the next call to gotoMark().

public void
public DTMAxisIterator
setStartNode(int node)

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setStartNode.

Set start to END should 'close' the iterator, i.e. subsequent call to next() should return END.

Inherited from com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase:
getAxisgetNodeByPositiongetStartNodeincludeSelfisDocOrderedisReverseresetPositionreturnNode

Field Detail

_matchback to summary
private final int _match

The node to match.

_sourceback to summary
private DTMAxisIterator _source

A reference to a source iterator.

Constructor Detail

MatchingIteratorback to summary
public MatchingIterator(int match, DTMAxisIterator source)

Method Detail

cloneIteratorback to summary
public DTMAxisIterator cloneIterator()

Overrides com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.cloneIterator.

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.cloneIterator.

Doc from com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.cloneIterator.

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.

getLastback to summary
public int getLast()

Overrides com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.getLast.

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.getLast.

Doc from com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.getLast.

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.

getPositionback to summary
public int getPosition()

Overrides com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.getPosition.

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.getPosition.

gotoMarkback to summary
public void gotoMark()

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.gotoMark.

Doc from com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.gotoMark.

Restores the current node remembered by setMark().

nextback to summary
public int next()

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.next.

Doc from com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.next.

Get the next node in the iteration.

resetback to summary
public DTMAxisIterator reset()

Overrides com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.reset.

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.reset.

Doc from com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.reset.

Resets the iterator to the last start node.

setMarkback to summary
public void setMark()

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setMark.

Doc from com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setMark.

Remembers the current node for the next call to gotoMark().

setRestartableback to summary
public void setRestartable(boolean isRestartable)

Overrides com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase.setRestartable.

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setRestartable.

Doc from com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setRestartable.

Set if restartable.

setStartNodeback to summary
public DTMAxisIterator setStartNode(int node)

Implements com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setStartNode.

Doc from com.sun.org.apache.xml.internal.dtm.DTMAxisIterator.setStartNode.

Set start to END should 'close' the iterator, i.e. subsequent call to next() should return END.