org.apache.cocoon.generation
Class XPathDirectoryGenerator

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.generation.AbstractGenerator
              extended by org.apache.cocoon.generation.ServiceableGenerator
                  extended by org.apache.cocoon.generation.DirectoryGenerator
                      extended by org.apache.cocoon.generation.XPathDirectoryGenerator
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, LogEnabled, Serviceable, CacheableProcessingComponent, Generator, SitemapModelComponent, XMLProducer

public class XPathDirectoryGenerator
extends DirectoryGenerator

Version:
CVS $Id: XPathDirectoryGenerator.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Giacomo Pati, Gianugo Rabellino, Jörg Heinicke

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.cocoon.generation.DirectoryGenerator
DirectoryGenerator.DirValidity
 
Field Summary
protected  Document doc
          The document that should be parsed and (partly) included.
protected static Map mappingFiles
          All the mapping files lastmodified dates
protected  DOMParser parser
          The parser for the XML snippets to be included.
protected  PrefixResolver prefixResolver
          The PrefixResolver responsable for processing current request (if any).
protected  XPathProcessor processor
          The XPath processor.
protected static String QUERY_ATTR_NAME
          Attribute for the XPath query.
protected  org.apache.regexp.RE xmlRE
          The regular expression for the XML files pattern.
protected  String xpath
          The XPath.
protected static String XPATH_NODE_NAME
          Local name for the element that contains the included XML snippet.
 
Fields inherited from class org.apache.cocoon.generation.DirectoryGenerator
attributes, cacheKeyParList, DATE_ATTR_NAME, dateFormatter, depth, DIR_NODE_NAME, directorySource, excludeRE, FILE_NODE_NAME, FILENAME_ATTR_NAME, includeRE, isRequestedDirectory, LASTMOD_ATTR_NAME, PREFIX, refreshDelay, reverse, rootRE, SIZE_ATTR_NAME, sort, URI, validity
 
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
XPathDirectoryGenerator()
           
 
Method Summary
 void dispose()
          Disposable
protected  boolean isXML(File path)
          Determines if a given File shall be handled as XML.
protected  void performXPathQuery(File xmlFile)
          Performs an XPath query on the file.
 void recycle()
          Recycle resources
 void service(ServiceManager manager)
          Serviceable
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Setup this sitemap component
protected  void startNode(String nodeName, File path)
          Extends the startNode() method of the DirectoryGenerator by starting a possible XPath query on a file.
 
Methods inherited from class org.apache.cocoon.generation.DirectoryGenerator
addAncestorPath, addPath, endNode, generate, getAncestors, getKey, getValidity, isExcluded, isIncluded, isRoot, setNodeAttributes
 
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

XPATH_NODE_NAME

protected static final String XPATH_NODE_NAME
Local name for the element that contains the included XML snippet.

See Also:
Constant Field Values

QUERY_ATTR_NAME

protected static final String QUERY_ATTR_NAME
Attribute for the XPath query.

See Also:
Constant Field Values

mappingFiles

protected static final Map mappingFiles
All the mapping files lastmodified dates


parser

protected DOMParser parser
The parser for the XML snippets to be included.


doc

protected Document doc
The document that should be parsed and (partly) included.


prefixResolver

protected PrefixResolver prefixResolver
The PrefixResolver responsable for processing current request (if any).


xmlRE

protected org.apache.regexp.RE xmlRE
The regular expression for the XML files pattern.


xpath

protected String xpath
The XPath.


processor

protected XPathProcessor processor
The XPath processor.

Constructor Detail

XPathDirectoryGenerator

public XPathDirectoryGenerator()
Method Detail

dispose

public void dispose()
Disposable

Specified by:
dispose in interface Disposable
Overrides:
dispose in class ServiceableGenerator

recycle

public void recycle()
Recycle resources

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class DirectoryGenerator

service

public void service(ServiceManager manager)
             throws ServiceException
Serviceable

Specified by:
service in interface Serviceable
Overrides:
service in class ServiceableGenerator
Parameters:
manager - the ComponentManager
Throws:
ServiceException - in case a component could not be found

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Setup this sitemap component

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class DirectoryGenerator
Parameters:
resolver - the SourceResolver
objectModel - The environmental object model
src - the source attribute
par - the parameters
Throws:
ProcessingException - if processing failes
SAXException - in case of XML related errors
IOException - in case of file related errors

isXML

protected boolean isXML(File path)
Determines if a given File shall be handled as XML.

Parameters:
path - the File to check
Returns:
true if the given File shall handled as XML, false otherwise.

performXPathQuery

protected void performXPathQuery(File xmlFile)
                          throws SAXException
Performs an XPath query on the file.

Parameters:
xmlFile - the File the XPath is performed on.
Throws:
SAXException - if something goes wrong while adding the XML snippet.

startNode

protected void startNode(String nodeName,
                         File path)
                  throws SAXException
Extends the startNode() method of the DirectoryGenerator by starting a possible XPath query on a file.

Overrides:
startNode in class DirectoryGenerator
Parameters:
nodeName - the node currently processing
path - the file path
Throws:
SAXException - in case of errors


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.