net.sf.saxon.sort
Class SortedIterator
java.lang.Object
net.sf.saxon.sort.SortedIterator
- LastPositionFinder, LookaheadIterator, SequenceIterator, Sortable
public class SortedIterator
extends java.lang.Object
Class to do a sorted iteration
protected void | buildArray() - Create an array holding the items to be sorted and the values of their sort keys
|
int | compare(int a, int b) - Compare two items in sorted sequence
(needed to implement the Sortable interface)
|
Item | current()
|
SequenceIterator | getAnother()
|
int | getLastPosition() - Get the last position (that is, the number of items in the sequence).
|
int | getProperties() - Get properties of this iterator, as a bit-significant integer.
|
boolean | hasNext() - Determine whether there are more items to come.
|
Item | next() - Get the next item, in sorted order
|
int | position()
|
void | setHostLanguage(int language) - Set the host language
|
void | swap(int a, int b) - Swap two items (needed to implement the Sortable interface)
|
nodeKeys
protected Object[] nodeKeys
position
protected int position
recordSize
protected int recordSize
SortedIterator
public SortedIterator(XPathContext context,
SequenceIterator base,
SortKeyEvaluator sortKeyEvaluator,
AtomicComparer[] comparators)
Create a sorted iterator
context
- the dynamic XPath evaluation contextbase
- an iterator over the sequence to be sortedsortKeyEvaluator
- an object that allows the n'th sort key for a given item to be evaluatedcomparators
- an array of AtomicComparers, one for each sort key, for comparing sort key values
buildArray
protected void buildArray()
throws XPathException
Create an array holding the items to be sorted and the values of their sort keys
compare
public int compare(int a,
int b)
Compare two items in sorted sequence
(needed to implement the Sortable interface)
- compare in interface Sortable
- <0 if obj[a]0 if obj[a]>obj[b]
getLastPosition
public int getLastPosition()
throws XPathException
Get the last position (that is, the number of items in the sequence). This method is
non-destructive: it does not change the state of the iterator.
The result is undefined if the next() method of the iterator has already returned null.
This method must not be called unless the result of getProperties() on the iterator
includes the bit setting
SequenceIterator.LAST_POSITION_FINDER
- getLastPosition in interface LastPositionFinder
getProperties
public int getProperties()
Get properties of this iterator, as a bit-significant integer.
- getProperties in interface SequenceIterator
hasNext
public boolean hasNext()
Determine whether there are more items to come. Note that this operation
is stateless and it is not necessary (or usual) to call it before calling
next(). It is used only when there is an explicit need to tell if we
are at the last element.
This method must not be called unless the result of getProperties() on the iterator
includes the bit setting
SequenceIterator.LOOKAHEAD
- hasNext in interface LookaheadIterator
- true if there are more items in the sequence
setHostLanguage
public void setHostLanguage(int language)
Set the host language
swap
public void swap(int a,
int b)
Swap two items (needed to implement the Sortable interface)
- swap in interface Sortable