All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.resources.DirectoryResource

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource
                   |
                   +----w3c.jigsaw.resources.HTTPResource
                           |
                           +----w3c.jigsaw.resources.FilteredResource
                                   |
                                   +----w3c.jigsaw.resources.ContainerResource
                                           |
                                           +----w3c.jigsaw.resources.StoreContainer
                                                   |
                                                   +----w3c.jigsaw.resources.DirectoryResource

public class DirectoryResource
extends StoreContainer
A simple, and reasonably efficient directory resource. This directory resource embeds its own resource store object to keep track of its next children (wich might themselves be DirectoryResource). It is reasonably efficient in the sense that it won't overload the memory with unused informations. However, stay tuned for a really efficient file based directory resource (tuned to serve only files).


Variable Index

 o ATTR_DIRECTORY
Attribute index - The index for our directory attribute.
 o ATTR_DIRSTAMP
Attribute index - The last we we physically visited the directory.
 o ATTR_ICONDIR
Attribute index - The icon directory to use in dir listing.
 o ATTR_INDEXER
Attribute index - The indexer to use for that directory, if any.
 o ATTR_NEGOTIABLE
Attribute index - Should this directory support content negotiation.
 o listing
Our current (cached) directory listing.
 o listing_stamp
The time at which we generated the directory index.

Constructor Index

 o DirectoryResource()

Method Index

 o checkIfModifiedSince(Request)
Check the If-Modified-Since condition of that request.
 o createDefaultResource(String)
Try creating a default resource having the given name.
 o delete()
Delete this directory resource, for ever.
 o enumerateResourceIdentifiers(boolean)
Enumerate all available children resource identifiers.
 o get(Request)
GET on a directory, generate a directory listing.
 o getDirectory()
Get the physical directory exported by this resource.
 o getDirectoryListing(Request)
Reply with an HTML doc listing the resources of this directory.
 o getDirStamp()
Get the absolute time at which we examined the physicall directory.
 o getIconDirectory()
Get the optional icon directory.
 o getIndexer(ResourceContext)
Get the indexer out of the given context.
 o getNegotiableFlag()
Get the negotiable flag for this directory.
 o initialize(Object[])
Initialize this directory resource with the given set of attributes.
 o main(String[])
Create an empty resource store, and store a default resource directory in it.
 o setValue(int, Object)
Keep our cached repository value in sync.
 o updateDefaultChildAttributes(Hashtable)
Initialize and register a new resource into this directory.
 o updateNegotiableResource(String)
Update a negotiable resource.
 o verify()
Verify that resource.

Variables

 o ATTR_DIRECTORY
 protected static int ATTR_DIRECTORY
Attribute index - The index for our directory attribute.

 o ATTR_ICONDIR
 protected static int ATTR_ICONDIR
Attribute index - The icon directory to use in dir listing.

 o ATTR_DIRSTAMP
 protected static int ATTR_DIRSTAMP
Attribute index - The last we we physically visited the directory.

 o ATTR_NEGOTIABLE
 protected static int ATTR_NEGOTIABLE
Attribute index - Should this directory support content negotiation.

 o ATTR_INDEXER
 protected static int ATTR_INDEXER
Attribute index - The indexer to use for that directory, if any.

 o listing
 protected HtmlGenerator listing
Our current (cached) directory listing.

 o listing_stamp
 protected long listing_stamp
The time at which we generated the directory index.

Constructors

 o DirectoryResource
 public DirectoryResource()

Methods

 o updateNegotiableResource
 public synchronized void updateNegotiableResource(String name)
Update a negotiable resource. Given the name of a resource that exists, create or update the attributes of a resource that allows to negotiate its content.

I hate this part here: it has nothing to do within the directory resource itself, and the indexer shouldn't know that much about directory resource, so I am stuck.

Parameters:
name - The name of the newly created resource.
 o getIndexer
 protected ResourceIndexer getIndexer(ResourceContext c)
Get the indexer out of the given context.

Returns:
A ResourceIndexer instance, guaranteeed not to be null.
 o setValue
 public void setValue(int idx,
                      Object value)
Keep our cached repository value in sync.

Overrides:
setValue in class StoreContainer
 o createDefaultResource
 public synchronized HTTPResource createDefaultResource(String name)
Try creating a default resource having the given name. This method will make its best effort to create a default resource having this name in the directory. If a file with this name exists, it will check the pre-defined admin extensions and look for a match. If a directory with this name exists, and admin allows to do so, it will create a sub-directory resource.

Parameters:
name - The name of the resource to try to create.
Returns:
A HTTPResource instance, if possible, null otherwise.
Overrides:
createDefaultResource in class ContainerResource
 o updateDefaultChildAttributes
 protected void updateDefaultChildAttributes(Hashtable attrs)
Initialize and register a new resource into this directory.

Parameters:
resource - The uninitialized resource to be added.
Overrides:
updateDefaultChildAttributes in class StoreContainer
 o getDirectory
 public File getDirectory()
Get the physical directory exported by this resource.

Returns:
A non-null File object giving the directory of this resource.
 o getIconDirectory
 public String getIconDirectory()
Get the optional icon directory.

 o getDirStamp
 public long getDirStamp()
Get the absolute time at which we examined the physicall directory.

Returns:
The date (as a long number of ms since Java epoch), or -1 if we never examined it before.
 o getNegotiableFlag
 public boolean getNegotiableFlag()
Get the negotiable flag for this directory. When turned to true, this flag indicates to the directory resource that it should automatically build negotiated resources ont op of all existing resources.

You should know, at least, that turning this flag on has some not so small cost in terms of the size of the index files, and some not so small costs in CPU time when detecting not found documents. Otherwise, in all other situations its cost is probably negligible.

Returns:
A boolean, true if the directory is extensible false otherwise.
 o initialize
 public void initialize(Object values[])
Initialize this directory resource with the given set of attributes.

Parameters:
values - The attribute values.
Overrides:
initialize in class StoreContainer
 o enumerateResourceIdentifiers
 public Enumeration enumerateResourceIdentifiers(boolean all)
Enumerate all available children resource identifiers. This method requires that we create all our pending resources if we are in the extensible mode...too bad !

Returns:
An enumeration of all our resources.
Overrides:
enumerateResourceIdentifiers in class StoreContainer
 o getDirectoryListing
 public synchronized Reply getDirectoryListing(Request request) throws HTTPException
Reply with an HTML doc listing the resources of this directory. This function takes special care not to regenerate a directory listing when one is available. It also caches the date of the directory listing, so that it can win big with NOT_MODIFIED.

Using a modem, I know that each place I can reply with an NOT_MODIFIED, is a big win.

Parameters:
request - The request to handle.
Throws: HTTPException
If processsing the request failed.
 o checkIfModifiedSince
 public int checkIfModifiedSince(Request request)
Check the If-Modified-Since condition of that request.

Parameters:
request - The request to check.
Returns:
An integer, either COND_FAILED if condition was checked, but failed, COND_OK if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).
Overrides:
checkIfModifiedSince in class HTTPResource
 o get
 public Reply get(Request request) throws HTTPException
GET on a directory, generate a directory listing.

Parameters:
request - The request to handle.
Overrides:
get in class HTTPResource
 o delete
 public synchronized void delete()
Delete this directory resource, for ever. This method will delete the directory resource, and its associated store, along with any of the sub-resources it contains. Deleting the root directory of your server might take sometime...

Once the resource is deleted, it is removed from its inital store and will not be unpickleable any more.

Overrides:
delete in class StoreContainer
 o verify
 public synchronized boolean verify()
Verify that resource.

Overrides:
verify in class HTTPResource
 o main
 public static void main(String args[]) throws Exception
Create an empty resource store, and store a default resource directory in it.


All Packages  Class Hierarchy  This Package  Previous  Next  Index