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

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

public class GrabberCollection<O,G>
extends java.lang.Object
implements java.util.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  java.util.Collection<O> coll
           
protected  DeciderIF<G> decider
           
protected  boolean grabbed
           
protected  java.util.Collection<G> grabbed_coll
           
protected  GrabberIF<O,G> grabber
           
 
Constructor Summary
GrabberCollection(java.util.Collection<O> coll, GrabberIF<O,G> grabber)
           
GrabberCollection(java.util.Collection<O> coll, GrabberIF<O,G> grabber, DeciderIF<G> decider)
           
 
Method Summary
 boolean add(G o)
           
 boolean addAll(java.util.Collection<? extends G> c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 boolean equals(java.lang.Object o)
           
protected  java.util.Collection<G> getCollection()
           
 boolean isEmpty()
           
 java.util.Iterator<G> iterator()
           
 void refresh()
          Refreshes the collection by looping over the nested collection and regrabbing its items.
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
           
 java.lang.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 java.util.Collection<O> coll

grabber

protected GrabberIF<O,G> grabber

decider

protected DeciderIF<G> decider

grabbed

protected boolean grabbed

grabbed_coll

protected java.util.Collection<G> grabbed_coll
Constructor Detail

GrabberCollection

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

GrabberCollection

public GrabberCollection(java.util.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 java.util.Collection<G> getCollection()

clear

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

contains

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

containsAll

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

equals

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

isEmpty

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

iterator

public java.util.Iterator<G> iterator()
Specified by:
iterator in interface java.lang.Iterable<G>
Specified by:
iterator in interface java.util.Collection<G>

size

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

toArray

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

toArray

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

add

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

addAll

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

remove

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

removeAll

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

retainAll

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


Copyright © 2000-2012 Ontopia.