Package org.exolab.castor.mapping
Interface CollectionHandler<T>
- All Known Implementing Classes:
ArrayCollectionHandler
,ArrayListCollectionHandler
,CollectionCollectionHandler
,EnumerateCollectionHandler
,HashtableCollectionHandler
,IteratorCollectionHandler
,ListCollectionHandler
,MapCollectionHandler
,QueueCollectionHandler
,SetCollectionHandler
,SortedMapCollectionHandler
,SortedSetCollectionHandler
,VectorCollectionHandler
public interface CollectionHandler<T>
Collection handler for adding/listing elements of a collection. A collection field will use this
handler to add elements when it's value is set, and to enumerate then when it's value is
retrieved. A collection handler is instantiated only once, must be thread safe and not use any
synchronization.
- Version:
- $Revision$ $Date: 2003-03-03 00:05:44 -0700 (Mon, 03 Mar 2003) $
- Author:
- Assaf Arkin
-
Method Summary
Modifier and TypeMethodDescriptionAdd an object to the collection.Clears the collection of any objects.Returns an enumeration of all the elements in the collection.int
Returns the number of elements in the collection.
-
Method Details
-
add
Add an object to the collection. A collection may not allow the same object to be added more than once. The collection is provided as a parameter and is returned as the return value if the returned collection is a different object. That way the handler can create a new collection or change the collection as necessary (e.g. when resizing an array).- Parameters:
collection
- The collection, null if no collection has been created yetobject
- The object to add to the collection- Returns:
- The collection with the new object if a different instance than the collection parameter, null otherwise
- Throws:
ClassCastException
- The collection handler does not support collections of this type
-
elements
Returns an enumeration of all the elements in the collection.- Parameters:
collection
- The collection- Returns:
- An enumeration of all the elements in the collection
- Throws:
ClassCastException
- The collection handler does not support collections of this type
-
size
Returns the number of elements in the collection.- Parameters:
collection
- The collection- Returns:
- Number of elements in the collection
- Throws:
ClassCastException
- The collection handler does not support collections of this type
-
clear
Clears the collection of any objects. The collection is provided as a parameter and is returned as the return value if the returned collection is a different object. That way the handler can create a new collection or change the collection as necessary (e.g. when resizing an array).- Parameters:
collection
- The collection, null if no collection has been created yet- Returns:
- The empty collection if a different instance than the collection parameter, null otherwise
- Throws:
ClassCastException
- The collection handler does not support collections of this type
-