|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
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:
Field Summary | |
protected org.xml.sax.helpers.AttributesImpl |
attributes
|
protected static java.lang.String |
DATE_ATTR_NAME
|
protected java.text.SimpleDateFormat |
dateFormatter
|
protected int |
depth
|
protected static java.lang.String |
DIR_NODE_NAME
|
protected org.apache.regexp.RE |
excludeRE
|
protected static java.lang.String |
FILE_NODE_NAME
|
protected static java.lang.String |
FILENAME_ATTR_NAME
|
protected org.apache.regexp.RE |
includeRE
|
protected boolean |
isRequestedDirectory
|
protected static java.lang.String |
LASTMOD_ATTR_NAME
|
protected static java.lang.String |
PREFIX
The namespace prefix for this namespace. |
protected org.apache.regexp.RE |
rootRE
|
protected static java.lang.String |
URI
The URI of the namespace of this generator. |
Fields inherited from class org.apache.cocoon.generation.ComposerGenerator |
manager |
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator |
objectModel, parameters, resolver, source |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
contentHandler, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.generation.Generator |
ROLE |
Constructor Summary | |
DirectoryGenerator()
|
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.cocoon.generation.ComposerGenerator |
compose, dispose |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
setConsumer, setContentHandler, setLexicalHandler |
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 |
Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
setConsumer |
Field Detail |
protected static final java.lang.String URI
protected static final java.lang.String PREFIX
protected static final java.lang.String DIR_NODE_NAME
protected static final java.lang.String FILE_NODE_NAME
protected static final java.lang.String FILENAME_ATTR_NAME
protected static final java.lang.String LASTMOD_ATTR_NAME
protected static final java.lang.String DATE_ATTR_NAME
protected int depth
protected org.xml.sax.helpers.AttributesImpl attributes
protected java.text.SimpleDateFormat dateFormatter
protected org.apache.regexp.RE rootRE
protected org.apache.regexp.RE includeRE
protected org.apache.regexp.RE excludeRE
protected boolean isRequestedDirectory
Constructor Detail |
public DirectoryGenerator()
Method Detail |
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
setup
in interface SitemapModelComponent
setup
in class AbstractGenerator
resolver
- the SourceResolver objectobjectModel
- a Map
containing model objectsrc
- the URI for this request (?)par
- configuration parameters
ProcessingException
org.xml.sax.SAXException
java.io.IOException
public void generate() throws org.xml.sax.SAXException, ProcessingException
org.xml.sax.SAXException
- if an error occurs while outputting the document
ProcessingException
- if the requsted URI isn't a directory on the local
filesystemprotected java.util.Stack getAncestors(java.io.File path)
path
- the File whose ancestors shall be retrieved
protected void addPathWithAncestors(java.io.File path, java.util.Stack ancestors) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void addPath(java.io.File path, int depth) throws org.xml.sax.SAXException
path
- the file/directory to processdepth
- how deep to scan the directory
org.xml.sax.SAXException
- if an error occurs while constructing nodesprotected void startNode(java.lang.String nodeName, java.io.File path) throws org.xml.sax.SAXException
nodeName
- the name of the new nodepath
- the file/directory to use when setting attributes
org.xml.sax.SAXException
- if an error occurs while creating the nodeprotected void setNodeAttributes(java.io.File path) throws org.xml.sax.SAXException
path
- the file/directory to use when setting attributes
org.xml.sax.SAXException
- if an error occurs while setting the attributesprotected void endNode(java.lang.String nodeName) throws org.xml.sax.SAXException
nodeName
- the name of the new node
org.xml.sax.SAXException
- if an error occurs while closing the nodeprotected boolean isRoot(java.io.File path)
path
- the File to check
protected boolean isIncluded(java.io.File path)
path
- the File to check
null
, false otherwise.protected boolean isExcluded(java.io.File path)
path
- the File to check
null
, true otherwise.public void recycle()
recycle
in interface org.apache.avalon.excalibur.pool.Recyclable
recycle
in class AbstractGenerator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |