org.apache.cocoon.sitemap
Class ContentAggregator

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLConsumer
          extended by org.apache.cocoon.xml.ContentHandlerWrapper
              extended by org.apache.cocoon.sitemap.ContentAggregator
All Implemented Interfaces:
Poolable, Recyclable, Component, LogEnabled, Serviceable, CacheableProcessingComponent, Generator, SitemapModelComponent, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class ContentAggregator
extends ContentHandlerWrapper
implements Generator, CacheableProcessingComponent, Serviceable

This generator implements the sitemap content aggregation. It combines several parts into one big XML document which is streamed into the pipeline.

Version:
$Id: ContentAggregator.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Giacomo Pati, Carsten Ziegeler

Nested Class Summary
protected static class ContentAggregator.Element
          This object holds an element definition
protected static class ContentAggregator.Part
          This object holds the part parts :)
 
Field Summary
protected  ContentAggregator.Element currentElement
          The element used for the current part
protected  ServiceManager manager
          The service manager
protected  ArrayList parts
          The aggregated parts
protected  SourceResolver resolver
          The SourceResolver
protected  ContentAggregator.Element rootElement
          The root element of the aggregated content
 
Fields inherited from class org.apache.cocoon.xml.ContentHandlerWrapper
contentHandler, lexicalHandler
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
ContentAggregator()
           
 
Method Summary
 void addPart(String uri, String element, String namespace, String stripRootElement, String prefix)
          Add a part.
 void endDocument()
          Ignore start and end document events
 void endElement(String namespaceURI, String localName, String raw)
          Override startElement() event to add namespace and prefix
 void generate()
          Generates the content
 Serializable getKey()
          Generate the unique key.
 SourceValidity getValidity()
          Generate the validity object.
 void recycle()
          Recycle the producer by removing references
 void service(ServiceManager manager)
           
 void setConsumer(XMLConsumer consumer)
          Set the XMLConsumer that will receive XML data.
 void setRootElement(String element, String namespace, String prefix)
          Set the root element.
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Set the SourceResolver, object model Map, the source and sitemap Parameters used to process the request.
 void startDocument()
          Ignore start and end document events
 void startElement(String namespaceURI, String localName, String raw, Attributes atts)
          Override startElement() event to add namespace and prefix
 
Methods inherited from class org.apache.cocoon.xml.ContentHandlerWrapper
characters, comment, endCDATA, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setContentHandler, setDocumentLocator, setLexicalHandler, skippedEntity, startCDATA, startDTD, startEntity, startPrefixMapping
 
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
 

Field Detail

rootElement

protected ContentAggregator.Element rootElement
The root element of the aggregated content


parts

protected ArrayList parts
The aggregated parts


currentElement

protected ContentAggregator.Element currentElement
The element used for the current part


resolver

protected SourceResolver resolver
The SourceResolver


manager

protected ServiceManager manager
The service manager

Constructor Detail

ContentAggregator

public ContentAggregator()
Method Detail

generate

public void generate()
              throws IOException,
                     SAXException,
                     ProcessingException
Generates the content

Specified by:
generate in interface Generator
Throws:
IOException
SAXException
ProcessingException

getKey

public Serializable getKey()
Generate the unique key. This key must be unique inside the space of this component.

Specified by:
getKey in interface CacheableProcessingComponent
Returns:
The generated key hashes the src

getValidity

public SourceValidity getValidity()
Generate the validity object.

Specified by:
getValidity in interface CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

setRootElement

public void setRootElement(String element,
                           String namespace,
                           String prefix)
Set the root element. Please make sure that the parameters are not null!


addPart

public void addPart(String uri,
                    String element,
                    String namespace,
                    String stripRootElement,
                    String prefix)
Add a part. Please make sure that the parameters are not null!


setConsumer

public void setConsumer(XMLConsumer consumer)
Set the XMLConsumer that will receive XML data.
This method will simply call setContentHandler(consumer) and setLexicalHandler(consumer).

Specified by:
setConsumer in interface XMLProducer

recycle

public void recycle()
Recycle the producer by removing references

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

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Set the SourceResolver, object model Map, the source and sitemap Parameters used to process the request.

Specified by:
setup in interface SitemapModelComponent
Throws:
ProcessingException
SAXException
IOException

startDocument

public void startDocument()
                   throws SAXException
Ignore start and end document events

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class ContentHandlerWrapper
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Ignore start and end document events

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class ContentHandlerWrapper
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String raw,
                         Attributes atts)
                  throws SAXException
Override startElement() event to add namespace and prefix

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class ContentHandlerWrapper
Parameters:
namespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String raw)
                throws SAXException
Override startElement() event to add namespace and prefix

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class ContentHandlerWrapper
Parameters:
namespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
Throws:
SAXException

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException


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