blackboard.base
Class BbDeleteTrackingList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by blackboard.base.SharableArrayList
                  extended by blackboard.base.BbList
                      extended by blackboard.base.BbDeleteTrackingList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class BbDeleteTrackingList
extends BbList

An extension of BbList that maintains a tracking set of elements that have been removed through one mechanism or another. Useful within the persistence framework to track child objects attached to heavyweight objects, and delete them as needed.

For instance, imagine a class Foo, containing an array of Bar objects. When a Foo instance is loaded, and then one of the Bar elements is removed from its list, it would be difficult to update the database to reflect the deletion of that object. Now, however, a call to getDeletedElements() returns a complete set of elements unlinked one way or another.

Note: This class is typically for Blackboard-only use and should be considered unstable.

Since:
Bb 6.0
Version:
$Revision: #1 $ $Date: 2005/06/27 $
See Also:
List, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class blackboard.base.BbList
BbList.Iterator
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
BbDeleteTrackingList()
          Default Constructor.
BbDeleteTrackingList(java.lang.Class typeClass)
          Constructs a BbList designated to only accept objects that are instances of the object represented by the provided Class value for addition to the list.
 
Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(java.lang.Object o)
          Appends the specified element to this list.
 boolean addAll(java.util.Collection c)
          Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.
 boolean addAll(int index, java.util.Collection c)
          Inserts all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.
 void clear()
          Removes all of the elements from this list.
 java.util.Collection getDeletedElements()
          Returns a collection of all elements removed through one mechanism or another.
 java.lang.Object remove(int index)
          Removes the element at the specified position in this list.
 boolean remove(java.lang.Object o)
          Removes a single instance of the specified element from this collection, if it is present.
 boolean removeAll(java.util.Collection c)
          Removes from this list all the elements that are contained in the specified collection.
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this list that are not contained in the specified collection.
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this list with the specified element.
 
Methods inherited from class blackboard.base.BbList
getFilteredSubList, getFilteringIterator, getFilteringIterator
 
Methods inherited from class blackboard.base.SharableArrayList
debug, getSubList, trimList
 
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, subList
 

Constructor Detail

BbDeleteTrackingList

public BbDeleteTrackingList()
Default Constructor. Constructs a list that does not enforce type safety and can accept any type of object as a member.


BbDeleteTrackingList

public BbDeleteTrackingList(java.lang.Class typeClass)
Constructs a BbList designated to only accept objects that are instances of the object represented by the provided Class value for addition to the list. Any attempt to add objects of a different type will result in an exception being thrown. An example declaration of a BbList designed to only contain object of type Integer:
 BbList list = new BbList( Integer.class );
 list.add( new Integer( 1 ) );  <-- successful
 list.add( new Float( 1.0 ) );  <-- throws IllegalArgumentException
 

Parameters:
typeClass - An instance of Class that represents the type of object that can be added to the list
Method Detail

add

public void add(int index,
                java.lang.Object element)
Inserts the specified element at the specified position in this list. Ensures that equivalent objects are removed from the tracking set.

Specified by:
add in interface java.util.List
Overrides:
add in class BbList
Parameters:
index - The index at which the specified element is to be inserted
element - The element to be inserted
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index > size())

add

public boolean add(java.lang.Object o)
Appends the specified element to this list. Ensures that equivalent objects are removed from the tracking list.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class BbList
Parameters:
o - The object to be added

addAll

public boolean addAll(java.util.Collection c)
Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. 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 list, and this list is nonempty.) Ensures that equivalent objects are removed from the tracking list.

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList
Parameters:
c - The collection to be added

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. 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 list, and this list is nonempty.) Ensures that equivalent objects are removed from the tracking list.

Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList
Parameters:
index - The index at which the specified collection is to be inserted
c - The collection to be added
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index > size())

clear

public void clear()
Removes all of the elements from this list. The list will be empty after this call returns. Copies all elements into the tracking list that are not already there.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.ArrayList

remove

public java.lang.Object remove(int index)
Removes the element at the specified position in this list. Copies the removed element into the tracking list if it is not already there.

Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.ArrayList
Parameters:
index - The index of the element to be removed
Returns:
The element that was removed from the list
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index > size())

remove

public boolean remove(java.lang.Object o)
Removes a single instance of the specified element from this collection, if it is present. Copies the object into the tracking list if it is not already there. Note that this implementation throws an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method.

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.ArrayList
Parameters:
o - The element to be removed from the collection, if present
Returns:
true If the collection contained the specified element
Throws:
java.lang.UnsupportedOperationException - If the remove method is not supported by this collection

removeAll

public boolean removeAll(java.util.Collection c)
Removes from this list all the elements that are contained in the specified collection. Copies each element into the tracking list if it is not already there.

Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.List
Overrides:
removeAll in class java.util.AbstractCollection
Parameters:
c - The collection that defines which elements will be removed

retainAll

public boolean retainAll(java.util.Collection c)
Retains only the elements in this list that are not contained in the specified collection. Copies each element not retained into the tracking list if it is not already there.

Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.List
Overrides:
retainAll in class java.util.AbstractCollection
Parameters:
c - The collection that defines which elements will be retained

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replaces the element at the specified position in this list with the specified element. Copies the replaced item into the tracking list if it is not already there.

Specified by:
set in interface java.util.List
Overrides:
set in class BbList
Parameters:
index - The index of the element to replace
element - The element to be stored at the specified position
Returns:
The element previously at the specified position
Throws:
java.lang.IndexOutOfBoundsException - if index out of range (index < 0 || index >= size())

getDeletedElements

public java.util.Collection getDeletedElements()
Returns a collection of all elements removed through one mechanism or another.

Returns:
A collection of all removed elements


Copyright © 2003 Blackboard, Inc. All Rights Reserved.