com.springsource.util.common
Class SynchronizedList<T>

java.lang.Object
  extended by com.springsource.util.common.SynchronizedObject
      extended by com.springsource.util.common.SynchronizedCollection<T>
          extended by com.springsource.util.common.SynchronizedList<T>
Type Parameters:
T - the type of the list elements
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>

public class SynchronizedList<T>
extends SynchronizedCollection<T>
implements java.util.List<T>

SynchronizedList wraps a given List and protects access to the collection and any iterators created from the collection by synchronizing on a given monitor.

Concurrent Semantics
This class is thread safe, but ConcurrentModificationException may still be thrown.

Since:
jersey
Author:
Glyn Normington

Field Summary
private  java.util.List<T> list
           
(package private)  java.lang.Object monitor
           
 
Constructor Summary
SynchronizedList(java.util.List<? extends T> list, java.lang.Object monitor)
           
 
Method Summary
 void add(int index, T element)
          
 boolean addAll(int index, java.util.Collection<? extends T> c)
          
 boolean equals(java.lang.Object obj)
          
 T get(int index)
          
 int hashCode()
          
 int indexOf(java.lang.Object o)
          
 int lastIndexOf(java.lang.Object o)
          
 java.util.ListIterator<T> listIterator()
          
 java.util.ListIterator<T> listIterator(int index)
          
 T remove(int index)
          
 T set(int index, T element)
          
 java.util.List<T> subList(int fromIndex, int toIndex)
          
 
Methods inherited from class com.springsource.util.common.SynchronizedCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class com.springsource.util.common.SynchronizedObject
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Field Detail

monitor

final java.lang.Object monitor

list

private final java.util.List<T> list
Constructor Detail

SynchronizedList

public SynchronizedList(java.util.List<? extends T> list,
                        java.lang.Object monitor)
Method Detail

add

public void add(int index,
                T element)

Specified by:
add in interface java.util.List<T>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends T> c)

Specified by:
addAll in interface java.util.List<T>

get

public T get(int index)

Specified by:
get in interface java.util.List<T>

indexOf

public int indexOf(java.lang.Object o)

Specified by:
indexOf in interface java.util.List<T>

lastIndexOf

public int lastIndexOf(java.lang.Object o)

Specified by:
lastIndexOf in interface java.util.List<T>

listIterator

public java.util.ListIterator<T> listIterator()

Specified by:
listIterator in interface java.util.List<T>

listIterator

public java.util.ListIterator<T> listIterator(int index)

Specified by:
listIterator in interface java.util.List<T>

remove

public T remove(int index)

Specified by:
remove in interface java.util.List<T>

set

public T set(int index,
             T element)

Specified by:
set in interface java.util.List<T>

subList

public java.util.List<T> subList(int fromIndex,
                                 int toIndex)

Specified by:
subList in interface java.util.List<T>

hashCode

public int hashCode()

Specified by:
hashCode in interface java.util.Collection<T>
Specified by:
hashCode in interface java.util.List<T>
Overrides:
hashCode in class SynchronizedCollection<T>

equals

public boolean equals(java.lang.Object obj)

Specified by:
equals in interface java.util.Collection<T>
Specified by:
equals in interface java.util.List<T>
Overrides:
equals in class SynchronizedCollection<T>