GPO LinkSets provide an iterator() method. And this does,
as might be expected, return an object that implements the java.util.Iterator
interface.
But the object returned is also a Striterator.
The Striterator protocols can be used to apply various mapping functions to
the original set.
So, for example, a filter might be provided to return some specific property
of each object.
Or to test each object in some way.
Or to return some other associated object.
The idea behind this kind of processing, is that it is possible to define a set of
"striteration" transformations on a Striterator and then use the resulting
Striterator in other methods. For example :
Iterator gpos = linkSet.iterator();
while (gpos.hasNext() ) {
IGPOMap gpm = (IGPOMap) gpos.next();
IGPOMap trgt = (IGPOMap) gpm.get("assoc");
process(trgt);
}
Or using the Striterator protocols:
IGPOMapIterator gpos = linkSet.iterator();
gpos.resolve("assoc");
while (gpos.hasNext()) {
process(gpos.nextGPOMap());
}
But more clear should be this next variation:
IGPOMapIterator gpos = linkSet.iterator();
processAll(gpos.resolve("assoc"));
...
void processAll(IGPOMapIterator gpos) {
while (gpos.hasNext()) {
process(gpos.nextGPOMap());
}
}
Where the Striterator resolve protocol has been used
to transform the Striterator which is then passed to some other
method.
Any number of filters can be applied each adding further transformations
to the objects to be produced.