    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.tools.resources.Resource

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

public class Resource
extends AttributeHolder

The resource class describes an object, accessible through the server. Resource objects are required to have the following properties:

- They must be persistent (their life-time can span multiple server life-time).
- They must be editable, so that one can change some of their aspects (such as any associated attribute).
- They must be self-described: each resource must now what kind of attribute it understands.
- They must be able to update themselves: some of the meta-information associated with a resource may require lot of CPU to compute.
- They must implement some name-service policy.

These resource objects do not define how they are accessed. See the sub-classes for specific accesses.

##

ATTR_CONTEXT
  Attribute index - The hierarchical context of the resource.
ATTR_IDENTIFIER
  Attribute index - The index for the identifier attribute.
ATTR_LAST_MODIFIED
  Attribute index - The index for the last-modified attribute.
ATTR_PARENT
  Attribute index - The index for our parent attribute.
ATTR_RESOURCE_FRAMES
  Attribute index - Associated resource frames
ATTR_STORE_ENTRY
  Attribute index - The index of the resource store entry attribute.
ATTR_URL
  Attribute index - The index for our URL attribute.

##

Resource()
  Create an empty resource instance.

##

acceptUnload()
  Is that resource willing to be unloaded.
checkMultipleLock(ResourceReference)
  Check if this resource is loked more than one time.
collectFrames(Class)
  Collect any frame that's an instance of the given class.
delete()
  Delete this Resource instance, and remove it from its store.
getClone(Object[])
  Clone this attribute holder, and init it with the given attributes.
getContext()
  Get the hierarchical context for that resource.
getFrame(Class)
  Get the first occurence of a frame of the given class.
getFrames()
  Collect all frames.
getHelpURL()
  Get this resource's help url.
getHelpURL(String)
  Get the help URL for that resource's topic.
getIdentifier()
  Get this resource identifier.
getLastModified()
  Get this resource last modification time.
getParent()
  Get this resource parent resource.
getResourceReference()
  Get the ResourceReference of that resource.
getSpace()
  Get the ResourceSpace where this resource is stored.
getSpaceEntry()
  Get the space entry for that resource.
getStoreEntry()
  Get the store entry for that resource.
getURLPath()
  Get the file part of the URL this resource is attached to.
getValue(Class, int, Object)
  Get an attached frame attribute value.
markModified()
  Mark this resource as having been modified.
notifyUnload()
  This resource is being unloaded.
registerFrame(ResourceFrame, Hashtable)
  Initialize and attach a new ResourceFrame to that resource.
setContext(ResourceContext)
  Set the given context as the current context of this resource.
setContext(ResourceContext, boolean)
  Set the given context as the current context of this resource.
setValue(Class, int, Object)
  Set an attached frame attribute value.
setValue(int, Object)
  We overide setValue, to mark the resource as modified.
unregisterFrame(ResourceFrame)
  Unregister a resource frame from the given resource.
updateAttributes()
  The web admin wants us to update any out of date attribute.

##

ATTR_STORE_ENTRY

     protected static int ATTR_STORE_ENTRY

  Attribute index - The index of the resource store entry attribute.

ATTR_IDENTIFIER

     protected static int ATTR_IDENTIFIER

  Attribute index - The index for the identifier attribute.

ATTR_RESOURCE_FRAMES

     protected static int ATTR_RESOURCE_FRAMES

  Attribute index - Associated resource frames

ATTR_PARENT

     protected static int ATTR_PARENT

  Attribute index - The index for our parent attribute.

ATTR_CONTEXT

     protected static int ATTR_CONTEXT

  Attribute index - The hierarchical context of the resource.

ATTR_URL

     protected static int ATTR_URL

  Attribute index - The index for our URL attribute.

ATTR_LAST_MODIFIED

     protected static int ATTR_LAST_MODIFIED

  Attribute index - The index for the last-modified attribute.

##

Resource

     public Resource()

  Create an empty resource instance. Initialize the instance attributes description, and its values.

##

getClone

     public Object getClone(Object values[])

  Clone this attribute holder, and init it with the given attributes.

  Overrides:
    getClone in class AttributeHolder

getParent

     public ResourceReference getParent()

  Get this resource parent resource. The parent of a resource can be either null if it is the server root resource, or any Resource.

  Returns:
    An instance of ResourceReference, or null

getURLPath

     public String getURLPath()

  Get the file part of the URL this resource is attached to.

  Returns:
    An URL object specifying the location in the information space of this resource.

getHelpURL

     public String getHelpURL()

  Get this resource's help url.

  Returns:
    An URL, encoded as a String, or null if not available.

getHelpURL

     public String getHelpURL(String topics)

  Get the help URL for that resource's topic.

  Parameters:
    topic - The topic you want help for.
  Returns:
    A String encoded URL, or null if none was found.

getContext

     protected ResourceContext getContext()

  Get the hierarchical context for that resource.

  Returns:
    A ResourceContext instance, guaranteed not to be null

setContext

     protected void setContext(ResourceContext context)

  Set the given context as the current context of this resource.

  Parameters:
    context - The new context.

setContext

     protected void setContext(ResourceContext context,
                               boolean keepmodules)

  Set the given context as the current context of this resource.

  Parameters:
    context - The new context.
    keepmodules - If true the new context will have the same modules than the old one.

getStoreEntry

     public Object getStoreEntry()

  Get the store entry for that resource. Only the resource store in charge of this resource knows about the type of the resulting object. Buy declaring the class of that object private, the resource store can assume some private access to it.

  Returns:
    A java Object instance, or null if no store entry is attached to that resource.

getIdentifier

     public String getIdentifier()

  Get this resource identifier.

  Returns:
    The String value for the identifier.

getSpaceEntry

     protected SpaceEntry getSpaceEntry()

  Get the space entry for that resource. This Object is use to retrieve the resource in the resource space.

  Returns:
    A spaceEntry instance.

getSpace

     protected ResourceSpace getSpace()

  Get the ResourceSpace where this resource is stored.

  Returns:
    A ResourceSpace instance.

getResourceReference

     public ResourceReference getResourceReference()

  Get the ResourceReference of that resource. ResourceReference is the only public way to access a resource.

  Returns:
    a ResourceReference instance.

registerFrame

     public void registerFrame(ResourceFrame frame,
                               Hashtable defs)

  Initialize and attach a new ResourceFrame to that resource.

  Parameters:
    frame - An uninitialized ResourceFrame instance.
    defs - A default set of attribute values.

unregisterFrame

     public synchronized void unregisterFrame(ResourceFrame frame)

  Unregister a resource frame from the given resource.

  Parameters:
    frame - The frame to unregister from the resource.

getFrames

     public synchronized ResourceFrame[] getFrames()

  Collect all frames.

  Returns:
    An array of ResourceFrame, containing a set of frames instances or null if no resource frame is available.

collectFrames

     public synchronized ResourceFrame[] collectFrames(Class c)

  Collect any frame that's an instance of the given class.

  Parameters:
    cls - The class of frames we are looking for.
  Returns:
    An array of ResourceFrame, containing a set of frames instances of the given class, or null if no resource frame is available.

getFrame

     public synchronized ResourceFrame getFrame(Class c)

  Get the first occurence of a frame of the given class.

  Parameters:
    cls - The class of te frame to look for.
  Returns:
    A ResourceFrame instance, or null.

getValue

     public synchronized Object getValue(Class c,
                                         int idx,
                                         Object def)

  Get an attached frame attribute value. This method really is a short-hand that combines a `getFrame` and `getValue` method call.

  Parameters:
    cls - The class of the frame we want the value of.
    idx - The attribute index.
    def - The default value (if the attribute value isn't defined).
  Returns:
    The attribute value as an Object instance, or the provided default value if the attribute value isn't defined.

setValue

     public synchronized void setValue(Class c,
                                       int idx,
                                       Object val)

  Set an attached frame attribute value. This method really is a short-hand that combines a `getFrame` and a `setValue` method call.

  Parameters:
    cls - The class of the frame we want to modify.
    idx - The attribute to modify.
    val - The new attribute value.

getLastModified

     public long getLastModified()

  Get this resource last modification time.

  Returns:
    A long giving the date of the last modification time, or -1 if undefined.

markModified

     public void markModified()

  Mark this resource as having been modified.

setValue

     public void setValue(int idx,
                          Object value)

  We overide setValue, to mark the resource as modified.

  Parameters:
    idx - The index of the attribute to modify.
    value - The new attribute value.
  Overrides:
    setValue in class AttributeHolder

acceptUnload

     public boolean acceptUnload()

  Is that resource willing to be unloaded. This method is a bit tricky to implement. The guideline is that you should not dynamically change the returned value (since you can't control what happens between a call to that method and a call to the `notifyUnload` method).

  Returning false should never be needed, except for very strange resources.

  Returns:
    A boolean true if the resource can be unloaded false otherwise.

notifyUnload

     public void notifyUnload()

  This resource is being unloaded. The resource is being unloaded from memory, perform any additional cleanup required.

updateAttributes

     public void updateAttributes()

  The web admin wants us to update any out of date attribute.

checkMultipleLock

     protected void checkMultipleLock(ResourceReference rr) throws MultipleLockException

  Check if this resource is loked more than one time.

  Throws: MultipleLockException
    is thrown if true.

delete

     public synchronized void delete() throws MultipleLockException

  Delete this Resource instance, and remove it from its store. This method will erase definitely this resource, for ever, by removing it from its resource store (when doable).

    All Packages  Class Hierarchy  This Package  Previous  Next  Index