blackboard.base
Class BbList

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
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess
Direct Known Subclasses:
BbDeleteTrackingList

public class BbList
extends SharableArrayList

Generic list class for a collection of objects. While this list can be used to store any generic set of objects, it can be created such that it enforces the type of objects that can be added/set within the list. In addition, it also exposes the filtering functionality provided by ListFilter.

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

Nested Class Summary
 class BbList.Iterator
          A custom extension of FilteringIterator that can be retrieved from any BbList object using getFilteringIterator() or getFilteringIterator(ListFilter).
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
BbList()
          Default Constructor.
BbList(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 obj)
          Overrides add() in parent to enforce type safety of this list.
 boolean add(java.lang.Object obj)
          Overrides add() in parent to enforce type safety of this list.
 BbList getFilteredSubList(ListFilter filter)
          Returns a sublist containing only those elements that meet the given filter's requirements.
 BbList.Iterator getFilteringIterator()
          Returns a BbList.Iterator for this list with no applied filters.
 BbList.Iterator getFilteringIterator(ListFilter filter)
          Returns a BbList.Iterator for this list with the given filter applied.
 java.lang.Object set(int index, java.lang.Object obj)
          Overrides set() in parent to enforce type safety of this list.
 
Methods inherited from class blackboard.base.SharableArrayList
debug, getSubList, trimList
 
Methods inherited from class java.util.ArrayList
addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, 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, removeAll, retainAll, 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, removeAll, retainAll, subList
 

Constructor Detail

BbList

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


BbList

public BbList(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 boolean add(java.lang.Object obj)
            throws java.lang.IllegalArgumentException
Overrides add() in parent to enforce type safety of this list.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList
Parameters:
obj - the Object to add to the list. The provided value should be of the type provided in the constructor.
Throws:
java.lang.IllegalArgumentException - if the element being added is not an instance of the Class provided in the constructor.

add

public void add(int index,
                java.lang.Object obj)
Overrides add() in parent to enforce type safety of this list.

Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList
Parameters:
index - the index at which the specified element is to be inserted.
obj - the Object to add to the list. The provided value should be of the type provided in the constructor.
Throws:
java.lang.IllegalArgumentException - if the element being added is not an instance of the Class provided in the constructor.

set

public java.lang.Object set(int index,
                            java.lang.Object obj)
Overrides set() in parent to enforce type safety of this list.

Specified by:
set in interface java.util.List
Overrides:
set in class java.util.ArrayList
Parameters:
index - the index at which the specified element is to be set.
obj - the Object to set in the list. The provided value should be of the type provided in the constructor.
Throws:
java.lang.IllegalArgumentException - if the element being set is not an instance of the Class provided in the constructor.

getFilteringIterator

public BbList.Iterator getFilteringIterator()
Returns a BbList.Iterator for this list with no applied filters. Once returned, filters can be added to the iterator using the method FilteringIterator.addFilter(ListFilter).

Returns:
a BbList.Iterator over the elements in this list in proper sequence

getFilteringIterator

public BbList.Iterator getFilteringIterator(ListFilter filter)
Returns a BbList.Iterator for this list with the given filter applied. Once returned, additional filters can be added to the iterator using the method FilteringIterator.addFilter(ListFilter).

Parameters:
filter - the ListFilter that should be used to filter values in this list.
Returns:
a BbList.Iterator over the elements in this list in proper sequence

getFilteredSubList

public BbList getFilteredSubList(ListFilter filter)
Returns a sublist containing only those elements that meet the given filter's requirements. The sublist has the same ordering as the original list.

Parameters:
filter - the ListFilter that should be used to filter values in this list.
Returns:
a new BbList that does not contain those elements that did not pass the given filter.


Copyright © 2003 Blackboard, Inc. All Rights Reserved.