|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<E>
java.util.HashSet<E>
java.util.LinkedHashSet<E>
org.geotools.util.CheckedHashSet<E>
E
- The type of elements in the set.public class CheckedHashSet<E>
A checked and synchronized Set
. Type checks are performed at run-time in addition of
compile-time checks. The synchronization lock can be modified at runtime by overriding the
getLock()
method.
This class is similar to using the wrappers provided in Collections
, minus the cost
of indirection levels and with the addition of overrideable methods.
Collections.checkedSet(java.util.Set, java.lang.Class)
,
Collections.synchronizedSet(java.util.Set)
,
Serialized FormConstructor Summary | |
---|---|
CheckedHashSet(java.lang.Class<E> type)
Constructs a set of the specified type. |
|
CheckedHashSet(java.lang.Class<E> type,
int capacity)
Constructs a set of the specified type and initial capacity. |
Method Summary | ||
---|---|---|
boolean |
add(E element)
Adds the specified element to this set if it is not already present. |
|
boolean |
addAll(java.util.Collection<? extends E> collection)
Appends all of the elements in the specified collection to this set. |
|
protected void |
checkWritePermission()
Checks if changes in this collection are allowed. |
|
void |
clear()
Removes all of the elements from this set. |
|
CheckedHashSet<E> |
clone()
Returns a shallow copy of this set. |
|
boolean |
contains(java.lang.Object o)
Returns true if this set contains the specified element. |
|
protected void |
ensureValidType(E element)
Checks the type of the specified object. |
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this set for equality. |
|
java.lang.Class<E> |
getElementType()
Returns the element type given at construction time. |
|
protected java.lang.Object |
getLock()
Returns the synchronization lock. |
|
int |
hashCode()
Returns the hash code value for this set. |
|
boolean |
isEmpty()
Returns true if this set contains no elements. |
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this set. |
|
boolean |
remove(java.lang.Object o)
Removes the pecified element from this set. |
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all of this set's elements that are also contained in the specified collection. |
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this set that are contained in the specified collection. |
|
int |
size()
Returns the number of elements in this set. |
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this set. |
|
|
toArray(T[] a)
Returns an array containing all of the elements in this set. |
|
java.lang.String |
toString()
Returns a string representation of this set. |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
containsAll |
Methods inherited from interface java.util.Set |
---|
containsAll |
Constructor Detail |
---|
public CheckedHashSet(java.lang.Class<E> type)
type
- The element type (should not be null).public CheckedHashSet(java.lang.Class<E> type, int capacity)
type
- The element type (should not be null).capacity
- The initial capacity.Method Detail |
---|
public java.lang.Class<E> getElementType()
getElementType
in interface CheckedCollection<E>
protected void ensureValidType(E element) throws java.lang.IllegalArgumentException
element
- the object to check, or null
.
java.lang.IllegalArgumentException
- if the specified element is not of the expected type.protected void checkWritePermission() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.protected java.lang.Object getLock()
this
.
Subclasses that override this method should be careful to update the lock reference
when this set is cloned.
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in interface java.util.Set<E>
iterator
in class java.util.HashSet<E>
public int size()
size
in interface java.util.Collection<E>
size
in interface java.util.Set<E>
size
in class java.util.HashSet<E>
public boolean isEmpty()
true
if this set contains no elements.
isEmpty
in interface java.util.Collection<E>
isEmpty
in interface java.util.Set<E>
isEmpty
in class java.util.HashSet<E>
public boolean contains(java.lang.Object o)
true
if this set contains the specified element.
contains
in interface java.util.Collection<E>
contains
in interface java.util.Set<E>
contains
in class java.util.HashSet<E>
public boolean add(E element) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
add
in interface java.util.Collection<E>
add
in interface java.util.Set<E>
add
in class java.util.HashSet<E>
element
- element to be added to this set.
true
if the set did not already contain the specified element.
java.lang.IllegalArgumentException
- if the specified element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean addAll(java.util.Collection<? extends E> collection) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.Set<E>
addAll
in class java.util.AbstractCollection<E>
collection
- the elements to be inserted into this set.
true
if this set changed as a result of the call.
java.lang.IllegalArgumentException
- if at least one element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean remove(java.lang.Object o) throws java.lang.UnsupportedOperationException
remove
in interface java.util.Collection<E>
remove
in interface java.util.Set<E>
remove
in class java.util.HashSet<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean removeAll(java.util.Collection<?> c) throws java.lang.UnsupportedOperationException
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.Set<E>
removeAll
in class java.util.AbstractSet<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean retainAll(java.util.Collection<?> c) throws java.lang.UnsupportedOperationException
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.Set<E>
retainAll
in class java.util.AbstractCollection<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public void clear() throws java.lang.UnsupportedOperationException
clear
in interface java.util.Collection<E>
clear
in interface java.util.Set<E>
clear
in class java.util.HashSet<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
toArray
in class java.util.AbstractCollection<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
toArray
in class java.util.AbstractCollection<E>
T
- The type of array elements.public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in interface java.util.Set<E>
equals
in class java.util.AbstractSet<E>
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.Set<E>
hashCode
in class java.util.AbstractSet<E>
public CheckedHashSet<E> clone()
clone
in class java.util.HashSet<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |