## org.w3c.tools.resources
Class ContainerResource

    java.lang.Object
      |
      +--org.w3c.tools.resources.AttributeHolder
            |
            +--org.w3c.tools.resources.Resource
                  |
                  +--org.w3c.tools.resources.FramedResource
                        |
                        +--org.w3c.tools.resources.AbstractContainer
                              |
                              +--org.w3c.tools.resources.ContainerResource

Direct Known Subclasses:
  CvsEntryResource, DirectoryResource, ExternalContainer, VirtualHostResource

public class ContainerResource
extends AbstractContainer

This resource manage children resources.

Field Summary
`protected boolean` | `acquired`
`protected static int` | `ATTR_KEY` Attribute index - The index of the resource key.

Fields inherited from class org.w3c.tools.resources.FramedResource
`ATTR_OID, attrListener, debugEvent, event_disabled, framesRef, structListener`

Fields inherited from class org.w3c.tools.resources.Resource
`ATTR_CONTEXT, ATTR_HELP_URL, ATTR_IDENTIFIER, ATTR_LAST_MODIFIED, ATTR_PARENT, ATTR_RESOURCE_FRAMES, ATTR_STORE_ENTRY, ATTR_URL`

Fields inherited from class org.w3c.tools.resources.AttributeHolder
`attributes, slowpickle, values`

Constructor Summary
`ContainerResource()`

Method Summary
`protected void` | `acquireChildren()` Acquire our children.
`protected ResourceReference` | `addResource(Resource resource, java.util.Hashtable defs)` Add an initialized resource into this store container instance.
`ResourceReference` | `createDefaultResource(java.lang.String name)` Create a default child resource in that container.
`void` | `delete()` Delete that resource container.
`void` | `delete(java.lang.String name)` Remove a child resource from that container.
`protected void` | `deleteChildren()`
`java.util.Enumeration` | `enumerateResourceIdentifiers(boolean all)` Enumerate children resource identifiers.
`protected SpaceEntry` | `getChildrenSpaceEntry()` Get the SpaceEntry of our children resources.
`java.lang.Object` | `getClone(java.lang.Object[] values)`
`java.lang.Integer` | `getKey()` Get the container Key.
`protected int` | `getMatchingCharsCount(java.lang.String s1, java.lang.String s2)` Get the number of matching character (case sensitive).
`protected SpaceEntry` | `getSpaceEntry()`
`void` | `initialize(java.lang.Object[] values)` Initialize ourself.
`protected ResourceReference` | `internalLookup(java.lang.String name, SpaceEntry sp, ResourceSpace space)`
`boolean` | `lookup(LookupState ls, LookupResult lr)` Lookup the next component of this lookup state in here.
`ResourceReference` | `lookup(java.lang.String name)` Lookup a children in the container.
`void` | `notifyUnload()` This resource is being unloaded.
`void` | `registerResource(java.lang.String name, Resource resource, java.util.Hashtable defs)` Initialize and register the given resource within that container.
`void` | `replace(DirectoryResource newdir)` Delete that container and its children if children is true
`void` | `resourceCreated(StructureChangedEvent evt)` A new resource has been created in some space.
`void` | `resourceModified(StructureChangedEvent evt)` This handles the `RESOURCE_MODIFIED` kind of events.
`void` | `resourceRemoved(StructureChangedEvent evt)` A resource is about to be removed This handles the `RESOURCE_REMOVED` kind of events.
`protected ResourceContext` | `updateDefaultChildAttributes(java.util.Hashtable attrs)` Update default child attributes.

Methods inherited from class org.w3c.tools.resources.AbstractContainer
`attributeChanged, enumerateResourceIdentifiers, resourceUnloaded`

Methods inherited from class org.w3c.tools.resources.FramedResource

`addAttributeChangedListener, addStructureChangedListener, collectFramesReference, disableEvent, displayEvent, enableEvent, eventDisabled, fireAttributeChangeEvent, fireStructureChangedEvent, fireStructureChangedEvent, frameAdded, frameModified, frameRemoved, getFrame, getFrame, getFrameReference, getFrameReference, getFramesReference, getOid, markModified, perform, performFrames, postAttributeChangeEvent, postEvent, postStructureChangedEvent, postStructureChangedEvent, processEvent, registerFrame, registerFrameIfNone, removeAttributeChangedListener, removeStructureChangedListener, setValue, unregisterFrame`

Methods inherited from class org.w3c.tools.resources.Resource
`acceptUnload, checkMultipleLock, collectFrames, getContext, getFrame, getFrames, getHelpURL, getHelpURL, getIdentifier, getLastModified, getParent, getResourceReference, getServer, getSpace, getStoreEntry, getURLPath, getValue, getValue, isInitialized, isUnloaded, setContext, setContext, setValue, updateAttributes`

Methods inherited from class org.w3c.tools.resources.AttributeHolder
`definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, initialize, lookupAttribute, pickle, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue, unpickle, unpickle, unpickle, unpickleInstance, unpickleInstance`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ATTR_KEY

    protected static int ATTR_KEY

  Attribute index - The index of the resource key.

### acquired

    protected boolean acquired

Constructor Detail

### ContainerResource

    public ContainerResource()

Method Detail

### getClone

    public java.lang.Object getClone(java.lang.Object[] values)

  Overrides:
    getClone in class FramedResource

### getKey

    public java.lang.Integer getKey()

  Get the container Key. This key must be unique and unchanged during the container life.
  Returns:
    a String instance.

### getSpaceEntry

    protected SpaceEntry getSpaceEntry()

  Overrides:
    getSpaceEntry in class Resource

### getChildrenSpaceEntry

    protected SpaceEntry getChildrenSpaceEntry()

  Get the SpaceEntry of our children resources.
  Returns:
    A SpaceEntry instance.

### resourceModified

    public void resourceModified(StructureChangedEvent evt)

  This handles the `RESOURCE_MODIFIED` kind of events.
  Parameters:
    `evt` - The StructureChangeEvent.
  Overrides:
    resourceModified in class AbstractContainer

### resourceCreated

    public void resourceCreated(StructureChangedEvent evt)

  A new resource has been created in some space. This handles the `RESOURCE_CREATED` kind of events.
  Parameters:
    `evt` - The event describing the change.
  Overrides:
    resourceCreated in class AbstractContainer

### resourceRemoved

    public void resourceRemoved(StructureChangedEvent evt)

  A resource is about to be removed This handles the `RESOURCE_REMOVED` kind of events.
  Parameters:
    `evt` - The event describing the change.
  Overrides:
    resourceRemoved in class AbstractContainer

### updateDefaultChildAttributes

    protected ResourceContext updateDefaultChildAttributes(java.util.Hashtable attrs)

  Update default child attributes. A parent can often pass default attribute values to its children, such as a pointer to itself (the parent attribute).

  This is the method to overide when you want your container to provide these kinds of attributes. By default this method will set the following attributes:

  name
    The name of the child (it's identifier) - String instance.
  parent
    The parent of the child (ie ourself here) - a ContainerResource instance.
  url
    If a identifier attribute is defined, that attribute is set to the full URL path of the children.
  Overrides:
    updateDefaultChildAttributes in class AbstractContainer

### enumerateResourceIdentifiers

    public java.util.Enumeration enumerateResourceIdentifiers(boolean all)

  Enumerate children resource identifiers.
  Parameters:
    `all` - Should all resources be enumerated ? Resources are often created on demand only, this flag allows the caller to tell the container about wether it is interested only in already created resources, or in all resources (even the one that have not yet been created).
  Returns:
    An String enumeration, one element per child.
  Overrides:
    enumerateResourceIdentifiers in class AbstractContainer

### createDefaultResource

    public ResourceReference createDefaultResource(java.lang.String name)

  Create a default child resource in that container. This method is called by the editor to add a default resource in the container under the given name. The meaning of default is left up to the container here.
  Parameters:
    `name` - The identifier for the new resource.
  Overrides:
    createDefaultResource in class AbstractContainer

### getMatchingCharsCount

    protected int getMatchingCharsCount(java.lang.String s1,
                                        java.lang.String s2)

  Get the number of matching character (case sensitive). ex getMatchingCharsCount("index.html", "Index.html") = 10.
  Parameters:
    `s1` - the first string.
    `s2` - the second string.
  Returns:
    -1 if s1 and s2 are not equals (ignoring case), otherwise the number of matching character (case sensitive).

### lookup

    public ResourceReference lookup(java.lang.String name)

  Lookup a children in the container.
  Parameters:
    `name` - The name of the children to lookup.
  Overrides:
    lookup in class AbstractContainer

### internalLookup

    protected ResourceReference internalLookup(java.lang.String name,
                                               SpaceEntry sp,
                                               ResourceSpace space)

### lookup

    public boolean lookup(LookupState ls,
                          LookupResult lr)
                   throws ProtocolException

  Lookup the next component of this lookup state in here.
  Parameters:
    `ls` - The current lookup state.
    `lr` - The lookup result under construction.
  Returns:
    A boolean, true if lookup has completed, false if it should be continued by the caller.
  Throws:
    ProtocolException - If an error occurs.
  Overrides:
    lookup in class FramedResource

### delete

    public void delete(java.lang.String name)
                throws MultipleLockException

  Remove a child resource from that container.
  Parameters:
    `name` - The name of the child to remove.
  Throws:
    MultipleLockException - If somone else has locked the resource.
  Overrides:
    delete in class AbstractContainer

### replace

    public void replace(DirectoryResource newdir)
                 throws MultipleLockException

  Delete that container and its children if children is true
  Throws:
    MultipleLockException - If somone else has locked one of the resource child.

### delete

    public void delete()
                throws MultipleLockException

  Delete that resource container.
  Throws:
    MultipleLockException - If somone else has locked the resource.
  Overrides:
    delete in class FramedResource

### deleteChildren

    protected void deleteChildren()
                           throws MultipleLockException

### notifyUnload

    public void notifyUnload()

  This resource is being unloaded. The resource is being unloaded from memory, perform any additional cleanup required.
  Overrides:
    notifyUnload in class FramedResource

### acquireChildren

    protected void acquireChildren()

  Acquire our children. Must be called before all child manipulation.

### addResource

    protected ResourceReference addResource(Resource resource,
                                            java.util.Hashtable defs)

  Add an initialized resource into this store container instance.
  Parameters:
    `resource` - The resource to be added to the store.

### registerResource

    public void registerResource(java.lang.String name,
                                 Resource resource,
                                 java.util.Hashtable defs)
                          throws InvalidResourceException

  Initialize and register the given resource within that container.
  Parameters:
    `name` - The identifier for the resource.
    `resource` - An unitialized resource instance.
    `defs` - A default set of init attribute values (may be null).
  Throws:
    InvalidResourceException - If an error occurs during the registration.
  Overrides:
    registerResource in class AbstractContainer

### initialize

    public void initialize(java.lang.Object[] values)

  Initialize ourself. As we are a container resource that really contains something, we make sure our URL ends properly with a slash.
  Parameters:
    `values` - Our default attribute values.
  Overrides:
    initialize in class FramedResource