|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.xml.AbstractXMLProducer org.apache.cocoon.generation.AbstractGenerator org.apache.cocoon.generation.ServiceableGenerator org.apache.cocoon.generation.TraversableGenerator
public class TraversableGenerator
Generates an XML source hierarchy listing from a Traversable Source.
The root node of the generated document will normally be a
collection
node and a collection node can contain zero or more
resource
or collection nodes. A resource node has no children.
Each node will contain the following attributes:
- name
- the name of the source
- lastModified
- the time the source was last modified, measured as the number of milliseconds since the epoch (as in java.io.File.lastModified)
- size
- the source size, in bytes (as in java.io.File.length)
- date (optional)
- the time the source was last modified in human-readable form
Configuration options:
Field Summary | |
---|---|
protected AttributesImpl |
attributes
Convenience object, so we don't need to create an AttributesImpl for every element. |
protected List |
cacheKeyParList
The cache key needs to be generated for the configuration of this generator, so storing the parameters for generateKey(). |
protected static String |
COL_NODE_NAME
|
protected static String |
DATE_ATTR_NAME
|
protected SimpleDateFormat |
dateFormatter
The dateFormatter determines into which date format the lastModified time should be converted. |
protected int |
depth
The depth parameter determines how deep the TraversableGenerator should delve. |
protected org.apache.regexp.RE |
excludeRE
The regular expression for the exclude pattern. |
protected org.apache.regexp.RE |
includeRE
The regular expression for the include pattern. |
protected boolean |
isRequestedSource
This is only set to true for the requested source specified by the src attribute on the generator's configuration. |
protected static String |
LASTMOD_ATTR_NAME
|
protected static String |
PREFIX
The namespace prefix for this namespace. |
protected long |
refreshDelay
The delay between checks on updates to the source hierarchy. |
protected static String |
RES_NAME_ATTR_NAME
|
protected static String |
RESOURCE_NODE_NAME
|
protected boolean |
reverse
The reverse parameter reverses the sort order. |
protected org.apache.regexp.RE |
rootRE
The regular expression for the root pattern. |
protected static String |
SIZE_ATTR_NAME
|
protected String |
sort
The sort parameter determines by which attribute the content of one collection should be sorted. |
protected static String |
URI
The URI of the namespace of this generator. |
protected static String |
URI_ATTR_NAME
|
protected MultiSourceValidity |
validity
The validity that is being built |
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator |
---|
manager |
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator |
---|
objectModel, parameters, resolver, source |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.generation.Generator |
---|
ROLE |
Constructor Summary | |
---|---|
TraversableGenerator()
|
Method Summary | |
---|---|
protected void |
addAncestorPath(TraversableSource source,
Stack ancestors)
Adds recursively the path from the source matched by the root pattern down to the requested source. |
protected void |
addContent(TraversableSource source)
Allow subclasses a chance to generate additional elements within collection and resource elements. |
protected void |
addPath(TraversableSource source,
int depth)
Adds a single node to the generated document. |
protected void |
endNode(String nodeName)
Ends the named node. |
void |
generate()
Generate XML data. |
protected Stack |
getAncestors(TraversableSource source)
Creates a stack containing the ancestors of a traversable source up to specific parent matching the root pattern. |
Serializable |
getKey()
Generate the unique key. |
SourceValidity |
getValidity()
Gets the source validity, using a deferred validity object. |
protected boolean |
isExcluded(TraversableSource source)
Determines if a given source shall be excluded from viewing. |
protected boolean |
isIncluded(TraversableSource source)
Determines if a given source shall be visible. |
protected boolean |
isRoot(TraversableSource source)
Determines if a given source is the defined root. |
void |
recycle()
Recycle resources |
protected void |
setNodeAttributes(TraversableSource source)
Sets the attributes for a given source. |
void |
setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters par)
Set the request parameters. |
protected void |
startNode(String nodeName,
TraversableSource source)
Begins a named node and calls setNodeAttributes to set its attributes. |
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator |
---|
dispose, service |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
setConsumer, setContentHandler, setLexicalHandler |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, 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 String URI
protected static final String PREFIX
protected static final String COL_NODE_NAME
protected static final String RESOURCE_NODE_NAME
protected static final String RES_NAME_ATTR_NAME
protected static final String URI_ATTR_NAME
protected static final String LASTMOD_ATTR_NAME
protected static final String DATE_ATTR_NAME
protected static final String SIZE_ATTR_NAME
protected MultiSourceValidity validity
protected AttributesImpl attributes
protected List cacheKeyParList
protected int depth
protected SimpleDateFormat dateFormatter
protected long refreshDelay
protected String sort
protected boolean reverse
false
is default.
protected org.apache.regexp.RE rootRE
protected org.apache.regexp.RE includeRE
protected org.apache.regexp.RE excludeRE
protected boolean isRequestedSource
src
attribute on the generator's configuration.
Constructor Detail |
---|
public TraversableGenerator()
Method Detail |
---|
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException
setup
in interface SitemapModelComponent
setup
in class AbstractGenerator
resolver
- the SourceResolver objectobjectModel
- a Map
containing model objectsrc
- the Traversable Source to be XMLized specified as
src
attribute on <map:generate/>par
- configuration parameters
ProcessingException
SAXException
IOException
public Serializable getKey()
CacheableProcessingComponent
getKey
in interface CacheableProcessingComponent
null
if the component
is currently not cacheable.public SourceValidity getValidity()
getValidity
in interface CacheableProcessingComponent
null
if the
component is currently not cacheable.MultiSourceValidity
public void generate() throws SAXException, ProcessingException
generate
in interface Generator
SAXException
- if an error occurs while outputting the document
ProcessingException
- if something went wrong while traversing
the source hierarchyprotected Stack getAncestors(TraversableSource source) throws IOException
source
- the traversable source whose ancestors shall be retrieved
IOException
protected void addAncestorPath(TraversableSource source, Stack ancestors) throws SAXException, ProcessingException
source
- the requested source.ancestors
- the stack of the ancestors.
SAXException
ProcessingException
protected void addPath(TraversableSource source, int depth) throws SAXException, ProcessingException
source
- the resource/collection to processdepth
- how deep to scan the collection hierarchy
SAXException
- if an error occurs while constructing nodes
ProcessingException
- if a problem occurs with the sourceprotected void addContent(TraversableSource source) throws SAXException, ProcessingException
source
- the source to generate additional data for.
SAXException
ProcessingException
protected void startNode(String nodeName, TraversableSource source) throws SAXException, ProcessingException
nodeName
- the name of the new nodesource
- the source a node with its attributes is added for
SAXException
- if an error occurs while creating the node
ProcessingException
protected void setNodeAttributes(TraversableSource source) throws SAXException, ProcessingException
source
- the source attributes are added for
SAXException
ProcessingException
protected void endNode(String nodeName) throws SAXException
nodeName
- the name of the new node
SAXException
- if an error occurs while closing the nodeprotected boolean isRoot(TraversableSource source)
source
- the source to check
protected boolean isIncluded(TraversableSource source)
source
- the source to check
protected boolean isExcluded(TraversableSource source)
source
- the source to check
public void recycle()
recycle
in interface Recyclable
recycle
in class AbstractGenerator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |