henplus.view.util
Class SortedMatchIterator

java.lang.Object
  extended by henplus.view.util.SortedMatchIterator
All Implemented Interfaces:
Iterator

public class SortedMatchIterator
extends Object
implements Iterator

An Iterator returning end-truncated matching values from a sorted List.

This Iterator is initialized with a sorted Set, sorted Map or another Iterator that must be placed at the beginning of the matching area of a sorted set.

This Iterator is commonly used for TAB-completion..


Constructor Summary
SortedMatchIterator(String partialMatch, Iterator it)
          Return all Key-Elements from the given Iterator that have the common prefix given in 'partialMatch'.
SortedMatchIterator(String partialMatch, SortedMap map)
          Return all Key-Elements from the given SortedMap that have the common prefix given in 'partialMatch'.
SortedMatchIterator(String partialMatch, SortedSet set)
          Return all Key-Elements from the given SortedSet that have the common prefix given in 'partialMatch'.
 
Method Summary
protected  boolean exclude(String current)
          Override this method if you want to exclude certain values from the iterated values returned.
 boolean hasNext()
           
 Object next()
           
 void remove()
           
 void setPrefix(String prefix)
          If a prefix is set, then return the matching element with with this prefix prepended.
 void setSuffix(String suffix)
          If a suffix is set, then return the matching element with with this suffix appended.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedMatchIterator

public SortedMatchIterator(String partialMatch,
                           Iterator it)
Return all Key-Elements from the given Iterator that have the common prefix given in 'partialMatch'. The Iterator must provide a sorted sequence of the potential matches that is placed on the first match.

Parameters:
partialMatch - the prefix that should match
it - the Iterator positioned at the first partial match.

SortedMatchIterator

public SortedMatchIterator(String partialMatch,
                           SortedSet set)
Return all Key-Elements from the given SortedSet that have the common prefix given in 'partialMatch'.

Parameters:
partialMatch - the prefix that should match
set - the SortedSet from which the matches should be iterated.

SortedMatchIterator

public SortedMatchIterator(String partialMatch,
                           SortedMap map)
Return all Key-Elements from the given SortedMap that have the common prefix given in 'partialMatch'.

Parameters:
partialMatch - the prefix that should match
map - the SortedMap from its matching keys the matches should be iterated.
Method Detail

setPrefix

public void setPrefix(String prefix)
If a prefix is set, then return the matching element with with this prefix prepended.


setSuffix

public void setSuffix(String suffix)
If a suffix is set, then return the matching element with with this suffix appended.


exclude

protected boolean exclude(String current)
Override this method if you want to exclude certain values from the iterated values returned. By default, no value is excluded.


hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator

next

public Object next()
Specified by:
next in interface Iterator

remove

public void remove()
Specified by:
remove in interface Iterator


? 1997..2006 Henner Zeller