Package jadex.commons.collection
Class CheckedCollection
- java.lang.Object
- 
- jadex.commons.collection.CheckedCollection
 
- 
- All Implemented Interfaces:
- java.lang.Iterable,- java.util.Collection,- java.util.Set
 
 public class CheckedCollection extends java.lang.Object implements java.util.Collection, java.util.SetA checked collection can be used for concurrent modification bug tracking. It saves the stack trace of the last modification and displays both exceptions if the original exception notices a concurrent modification exception.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.CollectioncollThe collection.protected java.lang.ExceptionlastmodThe last modification.protected CheckedMapparentThe paretn map (if any).
 - 
Constructor SummaryConstructors Constructor Description CheckedCollection(java.util.Collection coll)Create a new collection.CheckedCollection(java.util.Collection coll, CheckedMap parent)Create a new collection.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object o)Ensures that this collection contains the specified element (optional operation).booleanaddAll(java.util.Collection c)Adds all of the elements in the specified collection to this collection (optional operation).voidclear()Removes all of the elements from this collection (optional operation).booleancontains(java.lang.Object o)ReturnsbooleancontainsAll(java.util.Collection c)Returnsbooleanequals(java.lang.Object o)Compares the specified object with this collection for equality.inthashCode()Returns the hash code value for this collection.booleanisEmpty()Returnsjava.util.Iteratoriterator()Returns an iterator over the elements in this collection.booleanremove(java.lang.Object o)Removes a single instance of the specified element from this collection, if it is present (optional operation).booleanremoveAll(java.util.Collection c)Removes all of this collection's elements that are also contained in the specified collection (optional operation).booleanretainAll(java.util.Collection c)Retains only the elements in this collection that are contained in the specified collection (optional operation).intsize()Returns the number of elements in this collection.java.lang.Object[]toArray()Returns an array containing all of the elements in this collection.java.lang.Object[]toArray(java.lang.Object[] a)Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 
- 
- 
- 
Field Detail- 
collprotected java.util.Collection coll The collection.
 - 
lastmodprotected java.lang.Exception lastmod The last modification.
 - 
parentprotected CheckedMap parent The paretn map (if any).
 
- 
 - 
Constructor Detail- 
CheckedCollectionpublic CheckedCollection(java.util.Collection coll) Create a new collection.
 - 
CheckedCollectionpublic CheckedCollection(java.util.Collection coll, CheckedMap parent)Create a new collection.
 
- 
 - 
Method Detail- 
sizepublic int size() Returns the number of elements in this collection. If this collection contains more than- Specified by:
- sizein interface- java.util.Collection
- Specified by:
- sizein interface- java.util.Set
- Returns:
- the number of elements in this collection
 - 
isEmptypublic boolean isEmpty() Returns- Specified by:
- isEmptyin interface- java.util.Collection
- Specified by:
- isEmptyin interface- java.util.Set
- Returns:
 - 
containspublic boolean contains(java.lang.Object o) Returns- Specified by:
- containsin interface- java.util.Collection
- Specified by:
- containsin interface- java.util.Set
- Parameters:
- o- element whose presence in this collection is to be tested
- Returns:
- 
- Throws:
java.lang.ClassCastException- if the type of the specified element is incompatible with this collection (optional)java.lang.NullPointerException- if the specified element is null and this collection does not permit null elements (optional)
 - 
iteratorpublic java.util.Iterator iterator() Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).- Specified by:
- iteratorin interface- java.util.Collection
- Specified by:
- iteratorin interface- java.lang.Iterable
- Specified by:
- iteratorin interface- java.util.Set
- Returns:
- an
 
 - 
toArraypublic java.lang.Object[] toArray() Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.- Specified by:
- toArrayin interface- java.util.Collection
- Specified by:
- toArrayin interface- java.util.Set
- Returns:
- an array containing all of the elements in this collection
 - 
toArraypublic java.lang.Object[] toArray(java.lang.Object[] a) Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.toArray()method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.- Specified by:
- toArrayin interface- java.util.Collection
- Specified by:
- toArrayin interface- java.util.Set
- Parameters:
- a- the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
- Returns:
- an array containing all of the elements in this collection
- Throws:
- java.lang.ArrayStoreException- if the runtime type of the specified array is not a supertype of the runtime type of every element in this collection
- java.lang.NullPointerException- if the specified array is null
 - 
addpublic boolean add(java.lang.Object o) Ensures that this collection contains the specified element (optional operation). Returns- Specified by:
- addin interface- java.util.Collection
- Specified by:
- addin interface- java.util.Set
- Parameters:
- e- element whose presence in this collection is to be ensured
- Returns:
- 
- Throws:
java.lang.UnsupportedOperationException- if thejava.lang.ClassCastException- if the class of the specified element prevents it from being added to this collectionjava.lang.NullPointerException- if the specified element is null and this collection does not permit null elementsjava.lang.IllegalArgumentException- if some property of the element prevents it from being added to this collectionjava.lang.IllegalStateException- if the element cannot be added at this time due to insertion restrictions
 - 
removepublic boolean remove(java.lang.Object o) Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element- Specified by:
- removein interface- java.util.Collection
- Specified by:
- removein interface- java.util.Set
- Parameters:
- o- element to be removed from this collection, if present
- Returns:
- 
- Throws:
java.lang.ClassCastException- if the type of the specified element is incompatible with this collection (optional)java.lang.NullPointerException- if the specified element is null and this collection does not permit null elements (optional)java.lang.UnsupportedOperationException- if the
 - 
containsAllpublic boolean containsAll(java.util.Collection c) Returns- Specified by:
- containsAllin interface- java.util.Collection
- Specified by:
- containsAllin interface- java.util.Set
- Parameters:
- c- collection to be checked for containment in this collection
- Returns:
- 
- Throws:
java.lang.ClassCastException- if the types of one or more elements in the specified collection are incompatible with this collection (optional)java.lang.NullPointerException- if the specified collection contains one or more null elements and this collection does not permit null elements (optional), or if the specified collection is null
- See Also:
contains(Object)
 - 
addAllpublic boolean addAll(java.util.Collection c) Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)- Specified by:
- addAllin interface- java.util.Collection
- Specified by:
- addAllin interface- java.util.Set
- Parameters:
- c- collection containing elements to be added to this collection
- Returns:
- 
- Throws:
java.lang.UnsupportedOperationException- if thejava.lang.ClassCastException- if the class of an element of the specified collection prevents it from being added to this collectionjava.lang.NullPointerException- if the specified collection contains a null element and this collection does not permit null elements, or if the specified collection is nulljava.lang.IllegalArgumentException- if some property of an element of the specified collection prevents it from being added to this collectionjava.lang.IllegalStateException- if not all the elements can be added at this time due to insertion restrictions
- See Also:
add(Object)
 
 - 
removeAllpublic boolean removeAll(java.util.Collection c) Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.- Specified by:
- removeAllin interface- java.util.Collection
- Specified by:
- removeAllin interface- java.util.Set
- Parameters:
- c- collection containing elements to be removed from this collection
- Returns:
- 
- Throws:
java.lang.UnsupportedOperationException- if thejava.lang.ClassCastException- if the types of one or more elements in this collection are incompatible with the specified collection (optional)java.lang.NullPointerException- if this collection contains one or more null elements and the specified collection does not support null elements (optional), or if the specified collection is null
- See Also:
remove(Object),contains(Object)
 
 - 
retainAllpublic boolean retainAll(java.util.Collection c) Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.- Specified by:
- retainAllin interface- java.util.Collection
- Specified by:
- retainAllin interface- java.util.Set
- Parameters:
- c- collection containing elements to be retained in this collection
- Returns:
- 
- Throws:
java.lang.UnsupportedOperationException- if thejava.lang.ClassCastException- if the types of one or more elements in this collection are incompatible with the specified collection (optional)java.lang.NullPointerException- if this collection contains one or more null elements and the specified collection does not permit null elements (optional), or if the specified collection is null
- See Also:
remove(Object),contains(Object)
 
 - 
clearpublic void clear() Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
- clearin interface- java.util.Collection
- Specified by:
- clearin interface- java.util.Set
- Throws:
- java.lang.UnsupportedOperationException- if the
 
 - 
equalspublic boolean equals(java.lang.Object o) Compares the specified object with this collection for equality.- Specified by:
- equalsin interface- java.util.Collection
- Specified by:
- equalsin interface- java.util.Set
- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- object to be compared for equality with this collection
- Returns:
- 
- See Also:
Object.equals(Object),Set.equals(Object),List.equals(Object)
 - 
hashCodepublic int hashCode() Returns the hash code value for this collection. While the- Specified by:
- hashCodein interface- java.util.Collection
- Specified by:
- hashCodein interface- java.util.Set
- Overrides:
- hashCodein class- java.lang.Object
- Returns:
- the hash code value for this collection
- See Also:
- Object.hashCode(),- Object.equals(Object)
 
 
 
 
 
 
 
 
 
 
 
- 
 
-