net.sf.molae.pipe.cube
Class MapTree<E,T>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.basic.AbstractMapWithSet<List<E>,T>
          extended by net.sf.molae.pipe.cube.MapTree<E,T>
All Implemented Interfaces:
Map<List<E>,T>

public class MapTree<E,T>
extends AbstractMapWithSet<List<E>,T>

A tree with named edges. Every node is itself a map tree. It consists of a value and a map to children nodes where the key is the name of the edge and the value is the child node.

The map tree defines a new map of path/leaf pairs: Each map entry in the new map corresponds to a (sub) map tree. The key of the entry is the path to the leaf in form of a list of keys. The value of the entry is the value of the leaf.

Since:
1.1

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.molae.pipe.basic.AbstractMapWithSet
AbstractMapWithSet.EntrySet
 
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
MapTree()
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 T get(Object key)
          Returns the value to which this map maps the specified key.
protected  Iterator<Map.Entry<List<E>,T>> getEntrySetIterator()
          Returns the iterator of the entry set.
 T put(List<E> key, T value)
          Associates the specified value with the specified key in this map.
 T remove(Object key)
           
 
Methods inherited from class net.sf.molae.pipe.basic.AbstractMapWithSet
entrySet, keySet, size
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapTree

public MapTree()
Method Detail

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<List<E>,T>
Overrides:
containsKey in class AbstractMap<List<E>,T>

get

public T get(Object key)
Returns the value to which this map maps the specified key.

Specified by:
get in interface Map<List<E>,T>
Overrides:
get in class AbstractMap<List<E>,T>
Parameters:
key - a list of index values
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for this key.
Throws:
ClassCastException - if the key is not a List
NullPointerException - if the key is null

put

public T put(List<E> key,
             T value)
Associates the specified value with the specified key in this map.

Specified by:
put in interface Map<List<E>,T>
Overrides:
put in class AbstractMap<List<E>,T>
Parameters:
key - a list of index values
value - value to be associated with the specified key
Returns:
previous value associated with specified key
Throws:
ClassCastException - if the key is not a List.
NullPointerException - if the key is null.

remove

public T remove(Object key)
Specified by:
remove in interface Map<List<E>,T>
Overrides:
remove in class AbstractMap<List<E>,T>

clear

public void clear()
Specified by:
clear in interface Map<List<E>,T>
Overrides:
clear in class AbstractMap<List<E>,T>

getEntrySetIterator

protected Iterator<Map.Entry<List<E>,T>> getEntrySetIterator()
Description copied from class: AbstractMapWithSet
Returns the iterator of the entry set.

Specified by:
getEntrySetIterator in class AbstractMapWithSet<List<E>,T>
Returns:
the iterator of the entry set.