|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.collection.SynchronizedCollection
Decorates another Collection
to synchronize its behaviour
for a multi-threaded environment.
Iterators must be manually synchronized:
synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }
This class is Serializable from Commons Collections 3.1.
Field Summary | |
protected Collection |
collection
The collection to decorate |
protected Object |
lock
The object to lock on, needed for List/SortedSet views |
Constructor Summary | |
protected |
SynchronizedCollection(Collection collection)
Constructor that wraps (not copies). |
protected |
SynchronizedCollection(Collection collection,
Object lock)
Constructor that wraps (not copies). |
Method Summary | |
boolean |
add(Object object)
|
boolean |
addAll(Collection coll)
|
void |
clear()
|
boolean |
contains(Object object)
|
boolean |
containsAll(Collection coll)
|
static Collection |
decorate(Collection coll)
Factory method to create a synchronized collection. |
boolean |
equals(Object object)
|
int |
hashCode()
|
boolean |
isEmpty()
|
Iterator |
iterator()
Iterators must be manually synchronized. |
boolean |
remove(Object object)
|
boolean |
removeAll(Collection coll)
|
boolean |
retainAll(Collection coll)
|
int |
size()
|
Object[] |
toArray()
|
Object[] |
toArray(Object[] object)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final Collection collection
protected final Object lock
Constructor Detail |
protected SynchronizedCollection(Collection collection)
collection
- the collection to decorate, must not be null
IllegalArgumentException
- if the collection is nullprotected SynchronizedCollection(Collection collection, Object lock)
collection
- the collection to decorate, must not be nulllock
- the lock object to use, must not be null
IllegalArgumentException
- if the collection is nullMethod Detail |
public static Collection decorate(Collection coll)
coll
- the collection to decorate, must not be null
IllegalArgumentException
- if collection is nullpublic boolean add(Object object)
add
in interface Collection
public boolean addAll(Collection coll)
addAll
in interface Collection
public void clear()
clear
in interface Collection
public boolean contains(Object object)
contains
in interface Collection
public boolean containsAll(Collection coll)
containsAll
in interface Collection
public boolean isEmpty()
isEmpty
in interface Collection
public Iterator iterator()
synchronized (coll) { Iterator it = coll.iterator(); // do stuff with iterator }
iterator
in interface Collection
public Object[] toArray()
toArray
in interface Collection
public Object[] toArray(Object[] object)
toArray
in interface Collection
public boolean remove(Object object)
remove
in interface Collection
public boolean removeAll(Collection coll)
removeAll
in interface Collection
public boolean retainAll(Collection coll)
retainAll
in interface Collection
public int size()
size
in interface Collection
public boolean equals(Object object)
equals
in interface Collection
equals
in class Object
public int hashCode()
hashCode
in interface Collection
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |