net.sf.molae.pipe.genimpl
Class KeySetIteratorBasedMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.genimpl.KeySetBasedMap<K,V>
          extended by net.sf.molae.pipe.genimpl.KeySetIteratorBasedMap<K,V>
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
ResourceBundleAsMap

public abstract class KeySetIteratorBasedMap<K,V>
extends KeySetBasedMap<K,V>

Base class for maps that are defined by a key set iterator and a mapping that defines the key for each value. An AbstactSet based skeleton implementaion of the keySet is provided. Inheriting classes must implement getKeySetIterator() and get(Object). To implement a modifiable map, the programmer must additionally override this class's put(Object,Object) method (which otherwise throws an UnsupportedOperationException), and the iterator returned by keySet().iterator() must additionally implement its remove method.


Nested Class Summary
protected  class KeySetIteratorBasedMap.KeySet
          Provides a standard implementation of the key set of the map.
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
KeySetIteratorBasedMap()
           
 
Method Summary
protected abstract  Iterator<K> getKeySetIterator()
          Returns the iterator of the key set.
 Set<K> keySet()
          Returns a set view of the keys contained in this map.
 int size()
          Returns the number of mappings in this map.
 
Methods inherited from class net.sf.molae.pipe.genimpl.KeySetBasedMap
clear, containsKey, entrySet, get, remove
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, put, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeySetIteratorBasedMap

public KeySetIteratorBasedMap()
Method Detail

getKeySetIterator

protected abstract Iterator<K> getKeySetIterator()
Returns the iterator of the key set.

Returns:
the iterator of the key set

size

public int size()
Returns the number of mappings in this map. This implementation uses the key set iterator to count the elements in this set.

Specified by:
size in interface Map<K,V>
Overrides:
size in class KeySetBasedMap<K,V>
Returns:
the number of mappings in this map

keySet

public Set<K> keySet()
Returns a set view of the keys contained in this map. This implementation returns an instance of the inner class KeySet.

Specified by:
keySet in interface Map<K,V>
Specified by:
keySet in class KeySetBasedMap<K,V>
Returns:
a set view of the keys contained in this map.