net.ontopia.utils
Class GrabberCollection<O,G>

java.lang.Object
  extended by net.ontopia.utils.GrabberCollection<O,G>
All Implemented Interfaces:
Iterable<G>, Collection<G>, CachedIF

public class GrabberCollection<O,G>
extends Object
implements Collection<G>, CachedIF

INTERNAL: A collection that uses a grabber to populate itself by grabbing the individual objects of the nested collection. A decider can be used to decide whether grabbed objects should be added to the collection or not.


Field Summary
protected  Collection<O> coll
           
protected  DeciderIF<G> decider
           
protected  boolean grabbed
           
protected  Collection<G> grabbed_coll
           
protected  GrabberIF<O,G> grabber
           
 
Constructor Summary
GrabberCollection(Collection<O> coll, GrabberIF<O,G> grabber)
           
GrabberCollection(Collection<O> coll, GrabberIF<O,G> grabber, DeciderIF<G> decider)
           
 
Method Summary
 boolean add(G o)
           
 boolean addAll(Collection<? extends G> c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 boolean equals(Object o)
           
protected  Collection<G> getCollection()
           
 boolean isEmpty()
           
 Iterator<G> iterator()
           
 void refresh()
          Refreshes the collection by looping over the nested collection and regrabbing its items.
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 int size()
           
 Object[] toArray()
           
<G> G[]
toArray(G[] a)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
hashCode
 

Field Detail

coll

protected Collection<O> coll

grabber

protected GrabberIF<O,G> grabber

decider

protected DeciderIF<G> decider

grabbed

protected boolean grabbed

grabbed_coll

protected Collection<G> grabbed_coll
Constructor Detail

GrabberCollection

public GrabberCollection(Collection<O> coll,
                         GrabberIF<O,G> grabber)

GrabberCollection

public GrabberCollection(Collection<O> coll,
                         GrabberIF<O,G> grabber,
                         DeciderIF<G> decider)
Method Detail

refresh

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

Specified by:
refresh in interface CachedIF

getCollection

protected Collection<G> getCollection()

clear

public void clear()
Specified by:
clear in interface Collection<G>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<G>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<G>

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<G>
Overrides:
equals in class Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<G>

iterator

public Iterator<G> iterator()
Specified by:
iterator in interface Iterable<G>
Specified by:
iterator in interface Collection<G>

size

public int size()
Specified by:
size in interface Collection<G>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<G>

toArray

public <G> G[] toArray(G[] a)
Specified by:
toArray in interface Collection<G>

add

public boolean add(G o)
Specified by:
add in interface Collection<G>

addAll

public boolean addAll(Collection<? extends G> c)
Specified by:
addAll in interface Collection<G>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<G>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<G>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<G>


Copyright © 2000-2012 Ontopia.