net.ontopia.utils
Class GrabberMap<O,KG,VG>

java.lang.Object
  extended by net.ontopia.utils.GrabberMap<O,KG,VG>
All Implemented Interfaces:
Map<KG,Collection<VG>>, CachedIF

public class GrabberMap<O,KG,VG>
extends Object
implements Map<KG,Collection<VG>>, CachedIF

INTERNAL: An implementation of Map that uses a key grabber and a value grabber to extract its content.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  Collection<O> coll
           
protected  boolean grabbed
           
protected  Map<KG,Collection<VG>> grabbed_map
           
protected  GrabberIF<O,KG> key_grabber
           
protected  GrabberIF<O,VG> value_grabber
           
 
Constructor Summary
GrabberMap(Collection<O> coll, GrabberIF<O,KG> key_grabber, GrabberIF<O,VG> value_grabber)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set entrySet()
           
 boolean equals(Object o)
           
 Collection<VG> get(Object key)
           
protected  Map<KG,Collection<VG>> getMap()
           
 Map<KG,Collection<VG>> getNestedMap()
           
 int hashCode()
           
 boolean isEmpty()
           
 Set keySet()
           
 Collection<VG> put(KG key, Collection<VG> value)
           
 void putAll(Map t)
           
 void refresh()
          Refreshes the map by looping over the nested collection and regrabbing keys and values.
 Collection<VG> remove(Object key)
           
 void setNestedMap(Map<KG,Collection<VG>> map)
           
 int size()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coll

protected Collection<O> coll

key_grabber

protected GrabberIF<O,KG> key_grabber

value_grabber

protected GrabberIF<O,VG> value_grabber

grabbed_map

protected Map<KG,Collection<VG>> grabbed_map

grabbed

protected boolean grabbed
Constructor Detail

GrabberMap

public GrabberMap(Collection<O> coll,
                  GrabberIF<O,KG> key_grabber,
                  GrabberIF<O,VG> value_grabber)
Method Detail

getNestedMap

public Map<KG,Collection<VG>> getNestedMap()

setNestedMap

public void setNestedMap(Map<KG,Collection<VG>> map)

refresh

public void refresh()
Refreshes the map by looping over the nested collection and regrabbing keys and values. Any changes done to the previous collection will be lost.

Specified by:
refresh in interface CachedIF

getMap

protected Map<KG,Collection<VG>> getMap()

clear

public void clear()
Specified by:
clear in interface Map<KG,Collection<VG>>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<KG,Collection<VG>>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<KG,Collection<VG>>

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map<KG,Collection<VG>>

equals

public boolean equals(Object o)
Specified by:
equals in interface Map<KG,Collection<VG>>
Overrides:
equals in class Object

get

public Collection<VG> get(Object key)
Specified by:
get in interface Map<KG,Collection<VG>>

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<KG,Collection<VG>>
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<KG,Collection<VG>>

keySet

public Set keySet()
Specified by:
keySet in interface Map<KG,Collection<VG>>

put

public Collection<VG> put(KG key,
                          Collection<VG> value)
Specified by:
put in interface Map<KG,Collection<VG>>

putAll

public void putAll(Map t)
Specified by:
putAll in interface Map<KG,Collection<VG>>

remove

public Collection<VG> remove(Object key)
Specified by:
remove in interface Map<KG,Collection<VG>>

size

public int size()
Specified by:
size in interface Map<KG,Collection<VG>>

values

public Collection values()
Specified by:
values in interface Map<KG,Collection<VG>>


Copyright © 2000-2012 Ontopia.