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

IndirectListContainerPolicy

public class IndirectListContainerPolicy extends InterfaceContainerPolicy
A ContainerPolicy for jdk1.1 only (IndirectList implements Collection in jdk1.2; so the CollectionContainerPolicy can be used.)
see
ContainerPolicy
author
Big Country
since
TOPLink/Java 2.5

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

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

param
containerClass java.lang.Class

        super(containerClass);
        DescriptorException.invalidContainerPolicy(this, containerClass);
    
Methods Summary
protected booleanaddInto(java.lang.Object key, java.lang.Object element, java.lang.Object container)
INTERNAL: Add element into the container.

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

        try {
            ((IndirectList)container).addElement(element);
            return true;
        } catch (ClassCastException ex) {
            throw QueryException.cannotAddElement(element, container, ex);
        }
    
public voidaddIntoWithOrder(java.util.Vector indexes, java.util.Hashtable elements, 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

        Object object = null;
        try {
            Enumeration indexEnum = indexes.elements();
            while (indexEnum.hasMoreElements()) {
                Integer index = (Integer)indexEnum.nextElement();
                object = elements.get(index);
                if (index.intValue() >= (sizeFor(container) - 1)) {
                    ((IndirectList)container).addElement(object);
                } else {
                    ((IndirectList)container).setElementAt(object, index.intValue());
                }
            }
        } catch (ClassCastException ex1) {
            throw QueryException.cannotAddElement(object, container, ex1);
        }
    
public voidclear(java.lang.Object container)
INTERNAL: Remove all the elements from container.

param
container java.lang.Object

        ((IndirectList)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 ((IndirectList)container).contains(element);
    
public java.lang.ClassgetInterfaceType()

        return ClassConstants.IndirectList_Class;
    
public booleanhasNext(java.lang.Object iterator)
INTERNAL: Return whether the iterator has more objects,

param
iterator java.lang.Object
return
boolean true if iterator has more objects

        return ((Enumeration)iterator).hasMoreElements();
    
public booleanhasOrder()
INTERNAL: Returns true if the collection has order

see
ContainerPolicy#iteratorFor(java.lang.Object)

        return true;
    
public java.lang.ObjectiteratorFor(java.lang.Object container)
INTERNAL: Return an Iterator for the given container.

param
container java.lang.Object
return
java.lang.Object the iterator

        return ((IndirectList)container).elements();
    
protected java.lang.Objectnext(java.lang.Object iterator)
INTERNAL: Return the next object on the queue. Valid for some subclasses only.

param
iterator java.lang.Object
return
java.lang.Object the next object in the queue

        return ((Enumeration)iterator).nextElement();
    
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
element java.lang.Object
param
container java.lang.Object

        return ((IndirectList)container).removeElement(element);
    
public voidremoveFromWithOrder(int beginIndex, java.lang.Object container)
INTERNAL: Remove elements from this container starting with this index

param
beginIndex int the point to start deleting values from the collection
param
container java.lang.Object
return
boolean indicating whether the container changed

        int size = sizeFor(container) - 1;
        try {
            for (; size >= beginIndex; --size) {
                ((IndirectList)container).removeElementAt(size);
            }
        } catch (ClassCastException ex1) {
            throw QueryException.cannotRemoveFromContainer(new Integer(size), container, this);
        }
    
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 ((IndirectList)container).size();