org.apache.cocoon.generation
Class DirectoryGenerator
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLoggable
|
+--org.apache.cocoon.xml.AbstractXMLProducer
|
+--org.apache.cocoon.generation.AbstractGenerator
|
+--org.apache.cocoon.generation.ComposerGenerator
|
+--org.apache.cocoon.generation.DirectoryGenerator
- All Implemented Interfaces:
- org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable, Generator, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, XMLProducer
- Direct Known Subclasses:
- ImageDirectoryGenerator, MP3DirectoryGenerator
- public class DirectoryGenerator
- extends ComposerGenerator
Generates an XML directory listing.
The root node of the generated document will normally be a
directory
node, and a directory node can contain zero
or more file
or directory nodes. A file node has no
children. Each node will contain the following attributes:
- name
- the name of the file or directory
- lastModified
- the time the file was last modified, measured as the number of
milliseconds since the epoch (as in java.io.File.lastModified)
- date (optional)
- the time the file was last modified in human-readable form
Configuration options:
- depth (optional)
- Sets how deep DirectoryGenerator should delve into the
directory structure. If set to 1 (the default), only the starting
directory's immediate contents will be returned.
- dateFormat (optional)
- Sets the format for the date attribute of each node, as
described in java.text.SimpleDateFormat. If unset, the default
format for the current locale will be used.
- Version:
- CVS $Id: DirectoryGenerator.java,v 1.7 2002/02/22 07:03:51 cziegeler Exp $
- Author:
- Pierpaolo Fumagalli
(Apache Software Foundation, Exoffice Technologies), Conny Krappatsch
(SMB GmbH) for Virbus AG
Fields inherited from interface org.apache.cocoon.generation.Generator |
ROLE |
Method Summary |
protected void |
addPath(java.io.File path,
int depth)
Adds a single node to the generated document. |
protected void |
addPathWithAncestors(java.io.File path,
java.util.Stack ancestors)
|
protected void |
endNode(java.lang.String nodeName)
Ends the named node. |
void |
generate()
Generate XML data. |
protected java.util.Stack |
getAncestors(java.io.File path)
Creates a stack containing the ancestors of File up to specified
directory. |
protected boolean |
isExcluded(java.io.File path)
Determines if a given File shall be excluded from viewing. |
protected boolean |
isIncluded(java.io.File path)
Determines if a given File shall be visible. |
protected boolean |
isRoot(java.io.File path)
Determines if a given File is the defined root. |
void |
recycle()
Recycle resources |
protected void |
setNodeAttributes(java.io.File path)
Sets the attributes for a given path. |
void |
setup(SourceResolver resolver,
java.util.Map objectModel,
java.lang.String src,
org.apache.avalon.framework.parameters.Parameters par)
Set the request parameters. |
protected void |
startNode(java.lang.String nodeName,
java.io.File path)
Begins a named node, and calls setNodeAttributes to set its
attributes. |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable |
getLogger, setLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
URI
protected static final java.lang.String URI
- The URI of the namespace of this generator.
PREFIX
protected static final java.lang.String PREFIX
- The namespace prefix for this namespace.
DIR_NODE_NAME
protected static final java.lang.String DIR_NODE_NAME
FILE_NODE_NAME
protected static final java.lang.String FILE_NODE_NAME
FILENAME_ATTR_NAME
protected static final java.lang.String FILENAME_ATTR_NAME
LASTMOD_ATTR_NAME
protected static final java.lang.String LASTMOD_ATTR_NAME
DATE_ATTR_NAME
protected static final java.lang.String DATE_ATTR_NAME
depth
protected int depth
attributes
protected org.xml.sax.helpers.AttributesImpl attributes
dateFormatter
protected java.text.SimpleDateFormat dateFormatter
rootRE
protected org.apache.regexp.RE rootRE
includeRE
protected org.apache.regexp.RE includeRE
excludeRE
protected org.apache.regexp.RE excludeRE
isRequestedDirectory
protected boolean isRequestedDirectory
DirectoryGenerator
public DirectoryGenerator()
setup
public void setup(SourceResolver resolver,
java.util.Map objectModel,
java.lang.String src,
org.apache.avalon.framework.parameters.Parameters par)
throws ProcessingException,
org.xml.sax.SAXException,
java.io.IOException
- Set the request parameters. Must be called before the generate
method.
- Overrides:
setup
in class AbstractGenerator
- Parameters:
resolver
- the SourceResolver objectobjectModel
- a Map
containing model objectsrc
- the URI for this request (?)par
- configuration parameters
generate
public void generate()
throws org.xml.sax.SAXException,
ProcessingException
- Generate XML data.
- Throws:
org.xml.sax.SAXException
- if an error occurs while outputting the documentProcessingException
- if the requsted URI isn't a directory on the local
filesystem
getAncestors
protected java.util.Stack getAncestors(java.io.File path)
- Creates a stack containing the ancestors of File up to specified
directory.
- Parameters:
path
- the File whose ancestors shall be retrieved- Returns:
- a Stack containing the ancestors.
addPathWithAncestors
protected void addPathWithAncestors(java.io.File path,
java.util.Stack ancestors)
throws org.xml.sax.SAXException
addPath
protected void addPath(java.io.File path,
int depth)
throws org.xml.sax.SAXException
- Adds a single node to the generated document. If the path is a
directory, and depth is greater than zero, then recursive calls
are made to add nodes for the directory's children.
- Parameters:
path
- the file/directory to processdepth
- how deep to scan the directory- Throws:
org.xml.sax.SAXException
- if an error occurs while constructing nodes
startNode
protected void startNode(java.lang.String nodeName,
java.io.File path)
throws org.xml.sax.SAXException
- Begins a named node, and calls setNodeAttributes to set its
attributes.
- Parameters:
nodeName
- the name of the new nodepath
- the file/directory to use when setting attributes- Throws:
org.xml.sax.SAXException
- if an error occurs while creating the node
setNodeAttributes
protected void setNodeAttributes(java.io.File path)
throws org.xml.sax.SAXException
- Sets the attributes for a given path. The default method sets attributes
for the name of thefile/directory and for the last modification time
of the path.
- Parameters:
path
- the file/directory to use when setting attributes- Throws:
org.xml.sax.SAXException
- if an error occurs while setting the attributes
endNode
protected void endNode(java.lang.String nodeName)
throws org.xml.sax.SAXException
- Ends the named node.
- Parameters:
nodeName
- the name of the new nodepath
- the file/directory to use when setting attributes- Throws:
org.xml.sax.SAXException
- if an error occurs while closing the node
isRoot
protected boolean isRoot(java.io.File path)
- Determines if a given File is the defined root.
- Parameters:
path
- the File to check- Returns:
- true if the File is the root or the root pattern is not set,
false otherwise.
isIncluded
protected boolean isIncluded(java.io.File path)
- Determines if a given File shall be visible.
- Parameters:
path
- the File to check- Returns:
- true if the File shall be visible or the include Pattern is
null
, false otherwise.
isExcluded
protected boolean isExcluded(java.io.File path)
- Determines if a given File shall be excluded from viewing.
- Parameters:
path
- the File to check- Returns:
- false if the given File shall not be excluded or the
exclude Pattern is
null
, true otherwise.
recycle
public void recycle()
- Recycle resources
- Overrides:
recycle
in class AbstractGenerator
Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.