net.ontopia.utils
Class CollectionMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,java.util.Collection<V>>
          extended by net.ontopia.utils.CollectionMap<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,java.util.Collection<V>>

public class CollectionMap<K,V>
extends java.util.HashMap<K,java.util.Collection<V>>

INTERNAL: A map which stores entries containing Collection values. Any object can be used as key. The add(key,value) and remove(key,value) makes sure that the Collection values are updated correctly.

The maintained index must only contain values implementing the Collection interface. The data structure looks like this: {key: [value, value, ...], key: [value, ...]}

Empty entries are removed by default.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  boolean drop_empty
           
 
Constructor Summary
CollectionMap()
           
CollectionMap(boolean drop_empty)
           
 
Method Summary
 void add(K key, V value)
           
protected  java.util.Collection<V> createCollection()
           
 void move(V value, K old_key, K new_key)
           
 void remove(K key, V value)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

drop_empty

protected boolean drop_empty
Constructor Detail

CollectionMap

public CollectionMap()

CollectionMap

public CollectionMap(boolean drop_empty)
Method Detail

createCollection

protected java.util.Collection<V> createCollection()

add

public void add(K key,
                V value)

remove

public void remove(K key,
                   V value)

move

public void move(V value,
                 K old_key,
                 K new_key)


Copyright © 2000-2012 Ontopia.