net.sf.molae.pipe.genimpl
Class KeySetIteratorBasedMap

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--net.sf.molae.pipe.genimpl.KeySetBasedMap
              |
              +--net.sf.molae.pipe.genimpl.KeySetIteratorBasedMap
All Implemented Interfaces:
Map
Direct Known Subclasses:
ResourceBundleAsMap

public abstract class KeySetIteratorBasedMap
extends KeySetBasedMap

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.


Inner Class Summary
protected  class KeySetIteratorBasedMap.KeySet
          Provides a standard implementation of the key set of the map.
 
Inner classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
KeySetIteratorBasedMap()
           
 
Method Summary
protected abstract  Iterator getKeySetIterator()
          Returns the iterator of the key set.
 Set 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
containsValue, equals, hashCode, isEmpty, put, putAll, toString, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeySetIteratorBasedMap

public KeySetIteratorBasedMap()
Method Detail

getKeySetIterator

protected abstract Iterator 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.
Overrides:
size in class KeySetBasedMap
Returns:
the number of mappings in this map

keySet

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