FileDocCategorySizeDatePackage
J2EEResourceCollectionImpl.javaAPI DocGlassfish v2 API4118Fri May 04 22:35:10 BST 2007com.sun.enterprise.repository

J2EEResourceCollectionImpl

public class J2EEResourceCollectionImpl extends Object implements J2EEResourceCollection
Concrete implementation class for J2EEResourceCollection.
author
Kenneth Saks

Fields Summary
private Map
resourceSets_
Constructors Summary
public J2EEResourceCollectionImpl()

        resourceSets_ = new HashMap();
    
Methods Summary
public voidaddResource(J2EEResource resource)

        Map resourceSet = getResourcesInternal(resource.getType());
        resourceSet.put(resource.getName(), resource);
    
public java.util.SetgetAllResources()

        Set allResources = new HashSet();
        Collection resourcesByType = resourceSets_.values();
        for(Iterator iter = resourcesByType.iterator(); iter.hasNext(); ) {
            HashMap next = (HashMap) iter.next();
            allResources.addAll(next.values());
        }
        return allResources;
    
public J2EEResourcegetResourceByName(int type, java.lang.String resourceName)

        Map resourceSet = getResourcesInternal(type);
        return (J2EEResource) resourceSet.get(resourceName);
            
    
public java.util.SetgetResourcesByType(int type)

        Map resourceSet = getResourcesInternal(type);
        Collection collection = resourceSet.values();
        Set shallowCopy = new HashSet();
        for(Iterator iter = collection.iterator(); iter.hasNext();) {
            J2EEResource next = (J2EEResource) iter.next();
            shallowCopy.add(next);
        }
        return shallowCopy;
    
private java.util.MapgetResourcesInternal(int type)

        Map resourceSet = (Map) resourceSets_.get(new Integer(type));
        if( resourceSet == null ) {
            resourceSet = new HashMap();
            resourceSets_.put(new Integer(type), resourceSet);
        }
        return resourceSet;
    
public voidremoveAllResourcesByType(int type)

        resourceSets_.remove(new Integer(type));
    
public booleanremoveResource(J2EEResource resource)

        Map resourceSet = getResourcesInternal(resource.getType());
        boolean removed = 
            (resourceSet.remove(resource.getName()) != null);
        return removed;