|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.util
Class Collections.SynchronizedCollection

java.lang.Objectjava.util.Collections.SynchronizedCollection
- All Implemented Interfaces:
- Collection, java.lang.Iterable, java.io.Serializable
- Direct Known Subclasses:
- Collections.SynchronizedList, Collections.SynchronizedSet
- Enclosing class:
- Collections
- static class Collections.SynchronizedCollection
- extends java.lang.Object
- implements Collection, java.io.Serializable
- extends java.lang.Object
The implementation of Collections.synchronizedCollection(Collection) 55 . This
class name is required for compatibility with Sun's JDK serializability.
Package visible, so that collections such as the one for
Hashtable.values() can specify which object to synchronize on.
| Field Summary | |
(package private) Collection |
c
The wrapped collection. |
(package private) java.lang.Object |
mutex
The object to synchronize on. |
private static long |
serialVersionUID
Compatible with JDK 1.4. |
| Constructor Summary | |
(package private) |
Collections.SynchronizedCollection(Collection c)
Wrap a given collection. |
(package private) |
Collections.SynchronizedCollection(java.lang.Object sync,
Collection c)
Called only by trusted code to specify the mutex as well as the collection. |
| Method Summary | |
boolean |
add(java.lang.Object o)
Adds the object to the underlying collection, first obtaining a lock on the mutex. |
boolean |
addAll(Collection col)
Adds the objects in col to the underlying collection, first obtaining a lock on the mutex. |
void |
clear()
Removes all objects from the underlying collection, first obtaining a lock on the mutex. |
boolean |
contains(java.lang.Object o)
Checks for the existence of o within the underlying collection, first obtaining a lock on the mutex. |
boolean |
containsAll(Collection c1)
Checks for the existence of each object in cl within the underlying collection, first obtaining a lock on the mutex. |
boolean |
isEmpty()
Returns true if there are no objects in the underlying
collection. |
Iterator |
iterator()
Returns a synchronized iterator wrapper around the underlying collection's iterator. |
boolean |
remove(java.lang.Object o)
Removes the specified object from the underlying collection, first obtaining a lock on the mutex. |
boolean |
removeAll(Collection col)
Removes all elements, e, of the underlying collection for which col.contains(e)
returns true. |
boolean |
retainAll(Collection col)
Retains all elements, e, of the underlying collection for which col.contains(e)
returns true. |
int |
size()
Retrieves the size of the underlying collection. |
java.lang.Object[] |
toArray()
Returns an array containing each object within the underlying collection. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Copies the elements in the underlying collection to the supplied array. |
java.lang.String |
toString()
Returns a string representation of the underlying collection. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
equals, hashCode |
| Field Detail |
serialVersionUID
private static final long serialVersionUID
- Compatible with JDK 1.4.
- See Also:
- Constant Field Values
c
final Collection c
- The wrapped collection. Package visible for use by subclasses.
mutex
final java.lang.Object mutex
- The object to synchronize on. When an instance is created via public
methods, it will be this; but other uses like SynchronizedMap.values()
must specify another mutex. Package visible for use by subclasses.
| Constructor Detail |
Collections.SynchronizedCollection
Collections.SynchronizedCollection(Collection c)
- Wrap a given collection.
Collections.SynchronizedCollection
Collections.SynchronizedCollection(java.lang.Object sync, Collection c)
- Called only by trusted code to specify the mutex as well as the
collection.
| Method Detail |
add
public boolean add(java.lang.Object o)
- Adds the object to the underlying collection, first
obtaining a lock on the mutex.
- Specified by:
addin interfaceCollection
addAll
public boolean addAll(Collection col)
- Adds the objects in col to the underlying collection, first
obtaining a lock on the mutex.
- Specified by:
addAllin interfaceCollection
clear
public void clear()
- Removes all objects from the underlying collection,
first obtaining a lock on the mutex.
- Specified by:
clearin interfaceCollection
contains
public boolean contains(java.lang.Object o)
- Checks for the existence of o within the underlying
collection, first obtaining a lock on the mutex.
- Specified by:
containsin interfaceCollection
containsAll
public boolean containsAll(Collection c1)
- Checks for the existence of each object in cl
within the underlying collection, first obtaining
a lock on the mutex.
- Specified by:
containsAllin interfaceCollection
isEmpty
public boolean isEmpty()
- Returns
trueif there are no objects in the underlying collection. A lock on the mutex is obtained before the check is performed.- Specified by:
isEmptyin interfaceCollection
iterator
public Iterator iterator()
- Returns a synchronized iterator wrapper around the underlying
collection's iterator. A lock on the mutex is obtained before
retrieving the collection's iterator.
- Specified by:
iteratorin interfaceCollection
remove
public boolean remove(java.lang.Object o)
- Removes the specified object from the underlying collection,
first obtaining a lock on the mutex.
- Specified by:
removein interfaceCollection
removeAll
public boolean removeAll(Collection col)
- Removes all elements, e, of the underlying
collection for which
col.contains(e)returnstrue. A lock on the mutex is obtained before the operation proceeds.- Specified by:
removeAllin interfaceCollection
retainAll
public boolean retainAll(Collection col)
- Retains all elements, e, of the underlying
collection for which
col.contains(e)returnstrue. That is, every element that doesn't exist in col is removed. A lock on the mutex is obtained before the operation proceeds.- Specified by:
retainAllin interfaceCollection
size
public int size()
- Retrieves the size of the underlying collection.
A lock on the mutex is obtained before the collection
is accessed.
- Specified by:
sizein interfaceCollection
toArray
public java.lang.Object[] toArray()
- Returns an array containing each object within the underlying
collection. A lock is obtained on the mutex before the collection
is accessed.
- Specified by:
toArrayin interfaceCollection
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Copies the elements in the underlying collection to the supplied
array. If
a.length < size(), a new array of the same run-time type is created, with a size equal to that of the collection. Ifa.length > size(), then the elements from 0 tosize() - 1contain the elements from this collection. The following element is set to null to indicate the end of the collection objects. However, this only makes a difference if null is not a permitted value within the collection. Before the copying takes place, a lock is obtained on the mutex.- Specified by:
toArrayin interfaceCollection
toString
public java.lang.String toString()
- Returns a string representation of the underlying collection.
A lock is obtained on the mutex before the string is created.
|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.util.Collections.SynchronizedCollection