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

SortedCollectionContainerPolicy

public class SortedCollectionContainerPolicy extends CollectionContainerPolicy

Purpose: A SortedCollectionContainerPolicy is ContainerPolicy whose container class implements the SortedInterface interface. Added for BUG # 3233263

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

see
ContainerPolicy
see
MapContainerPolicy

Fields Summary
protected Comparator
m_comparator
Constructors Summary
public SortedCollectionContainerPolicy()
INTERNAL: Construct a new policy.


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

        super(containerClass);
    
Methods Summary
public java.lang.ObjectcontainerInstance()
INTERNAL Override from ContainerPolicy. Need to maintain the comparator in the new instance

        try {
            if (m_comparator != null) {
                Object[] arguments = new Object[] { m_comparator };
                Class[] constructClass = new Class[] { Comparator.class };
                Constructor constructor = null;
                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                    try {
                        constructor = (Constructor)AccessController.doPrivileged(new PrivilegedGetConstructorFor(getContainerClass(), constructClass, false));
                        return AccessController.doPrivileged(new PrivilegedInvokeConstructor(constructor, arguments));
                    } catch (PrivilegedActionException exception) {
                        throw QueryException.couldNotInstantiateContainerClass(getContainerClass(), exception.getException());
                    }
                } else {
                    constructor = PrivilegedAccessHelper.getConstructorFor(getContainerClass(), constructClass, false);
                    return PrivilegedAccessHelper.invokeConstructor(constructor, arguments);
                }
            } else {
                if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                    try {
                        return AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getContainerClass()));
                    } catch (PrivilegedActionException exception) {
                        throw QueryException.couldNotInstantiateContainerClass(getContainerClass(), exception.getException());
                    }
                } else {
                    return PrivilegedAccessHelper.newInstanceFromClass(getContainerClass());
                }
            }
        } catch (Exception ex) {
            throw QueryException.couldNotInstantiateContainerClass(getContainerClass(), ex);
        }
    
public java.util.ComparatorgetComparator()
INTERNAL: Return the stored comparator

        return m_comparator;
    
public voidsetComparator(java.util.Comparator comparator)
INTERNAL: Sets a comparator object for this policy to use when instantiating a new SortedSet object.

        m_comparator = comparator;