FileDocCategorySizeDatePackage
CollectionContainerPolicy.javaAPI DocGlassfish v2 API6947Tue May 22 16:54:40 BST 2007oracle.toplink.essentials.internal.queryframework

CollectionContainerPolicy

public class CollectionContainerPolicy extends InterfaceContainerPolicy

Purpose: A CollectionContainerPolicy is ContainerPolicy whose container class implements the Collection interface.

Responsibilities: Provide the functionality to operate on an instance of a Collection.

see
ContainerPolicy
see
MapContainerPolicy

Fields Summary
Constructors Summary
public CollectionContainerPolicy()
INTERNAL: Construct a new policy.

        super();
    
public CollectionContainerPolicy(Class containerClass)
INTERNAL: Construct a new policy for the specified class.

        super(containerClass);
    
public CollectionContainerPolicy(String containerClassName)
INTERNAL: Construct a new policy for the specified class name.

        super(containerClassName);
    
Methods Summary
public booleanaddInto(java.lang.Object key, java.lang.Object element, java.lang.Object container)
INTERNAL: Add element into a container which implements the Collection interface.

param
element java.lang.Object
param
container java.lang.Object
return
boolean indicating whether the container changed

        try {
            return ((Collection)container).add(element);
        } catch (ClassCastException ex1) {
            throw QueryException.cannotAddElement(element, container, ex1);
        } catch (IllegalArgumentException ex2) {
            throw QueryException.cannotAddElement(element, container, ex2);
        } catch (UnsupportedOperationException ex3) {
            throw QueryException.cannotAddElement(element, container, ex3);
        }
    
public java.lang.ObjectbuildContainerFromVector(java.util.Vector vector, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL: Return a container populated with the contents of the specified Vector.

        if ((getContainerClass() == vector.getClass()) && (!hasElementDescriptor())) {
            return vector;
        } else {
            return super.buildContainerFromVector(vector, session);
        }
    
public voidclear(java.lang.Object container)
INTERNAL: Remove all the elements from container.

param
container java.lang.Object

        try {
            ((Collection)container).clear();
        } catch (UnsupportedOperationException ex) {
            throw QueryException.methodNotValid(container, "clear()");
        }
    
protected booleancontains(java.lang.Object element, java.lang.Object container)
INTERNAL: Return the true if element exists in container.

param
element java.lang.Object
param
container java.lang.Object
return
boolean true if container 'contains' element

        return ((Collection)container).contains(element);
    
public java.lang.ClassgetInterfaceType()

        return ClassConstants.Collection_Class;
    
public booleanhasOrder()
INTERNAL: Return whether the collection has order. SortedSets cannot be indexed, but they are order-sensitive.

        return Helper.classImplementsInterface(this.getContainerClass(), ClassConstants.SortedSet_Class);
    
public booleanisCollectionPolicy()

        return true;
    
public booleanisValidContainer(java.lang.Object container)
INTERNAL: Validate the container type.

        // PERF: Use instanceof which is inlined, not isAssignable which is very inefficent.
        return container instanceof Collection;
    
public java.lang.ObjectiteratorFor(java.lang.Object container)
INTERNAL: Return an iterator for the given container.

param
container java.lang.Object
return
java.util.Enumeration/java.util.Iterator

        return ((Collection)container).iterator();
    
protected booleanremoveFrom(java.lang.Object key, java.lang.Object element, java.lang.Object container)
INTERNAL: Remove element from container which implements the Collection interface.

param
key java.lang.Object This param represents the key that would be used by this object in a map, may be null
param
element java.lang.Object
param
container java.lang.Object

        try {
            return ((Collection)container).remove(element);
        } catch (UnsupportedOperationException ex) {
            throw QueryException.methodNotValid(element, "remove(Object element)");
        }
    
public intsizeFor(java.lang.Object container)
INTERNAL: Return the size of container.

param
anObject java.lang.Object
return
int The size of the container.

        return ((Collection)container).size();