org.apache.cocoon.transformation.constrained
Class AbstractConstrainedTransformer

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.xml.AbstractXMLPipe
              extended byorg.apache.cocoon.transformation.AbstractTransformer
                  extended byorg.apache.cocoon.transformation.constrained.AbstractConstrainedTransformer
All Implemented Interfaces:
ContentHandler, LexicalHandler, LogEnabled, Poolable, Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLConsumer, XMLPipe, XMLProducer

public abstract class AbstractConstrainedTransformer
extends AbstractTransformer

This class is an abstract class from which you can extend your Transformer and write it in a way similar to AWT & Swing Event Handling. Part of this code is from the SQLTransformer of Donald Ball.

Version:
CVS $Id: AbstractConstrainedTransformer.java 156626 2005-03-09 09:43:39Z cziegeler $
Author:
Nicola Ken Barozzi, Tom Klaasen

Nested Class Summary
static class AbstractConstrainedTransformer.RipperListener
          Utility methods also for subclasses
 
Field Summary
 LexicalHandler lexical_handler
          The lexical handler of the SAX events generated by this AbstractConstrainedTransformer.
 XMLConsumer xml_consumer
          The consumer of the SAX events generated by this AbstractConstrainedTransformer.
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
AbstractConstrainedTransformer()
           
 
Method Summary
 void addEventListener(ElementEventListener l, XmlTreeConstraint constraint)
           
 void characters(char[] ary, int start, int length)
          Receive notification of character data.
 void data(String data)
           
 void end(String name)
           
 void endElement(String uri, String name, String raw)
          Receive notification of the end of an element.
abstract  String getName()
          Retrieve the 'name' of the namespace this class processes.
static String getStringValue(Object object)
           
abstract  String getUri()
          Retrieve the URI of the namespace this AbstractConstrainedTransformer has to process.
abstract  void init(Parameters parameters)
          Initialize: set up the listeners etc.
 void setDocumentLocator(Locator locator)
          Receive an object for locating the origin of SAX document events.
 void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters)
          The Sitemap will call the setup() method to prepare the component for use.
 void start(String name)
           
 void start(String name, AttributesImpl attr)
           
 void startElement(String uri, String name, String raw, Attributes attributes)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
recycle, 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.xml.sax.ContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

xml_consumer

public XMLConsumer xml_consumer
The consumer of the SAX events generated by this AbstractConstrainedTransformer.


lexical_handler

public LexicalHandler lexical_handler
The lexical handler of the SAX events generated by this AbstractConstrainedTransformer. FIXME: Isn't this always the same as the xml_consumer??

Constructor Detail

AbstractConstrainedTransformer

public AbstractConstrainedTransformer()
Method Detail

init

public abstract void init(Parameters parameters)
Initialize: set up the listeners etc.

Parameters:
parameters - The parameters that can be used by this method.

getUri

public abstract String getUri()
Retrieve the URI of the namespace this AbstractConstrainedTransformer has to process.

Returns:
The URI of the namespace this AbstractConstrainedTransformer has to process.

getName

public abstract String getName()
Retrieve the 'name' of the namespace this class processes. FIXME: Seems to be the last path element of the URI -- is that correct?

Returns:
The 'name' of the namespace this class processes.

setup

public final void setup(SourceResolver resolver,
                        Map objectModel,
                        String source,
                        Parameters parameters)
                 throws ProcessingException,
                        SAXException,
                        IOException
Description copied from interface: SitemapModelComponent
The Sitemap will call the setup() method to prepare the component for use. This is where you start the process of getting your information ready to generate your results. See ObjectModelHelper for help with the objectModel.

Parameters:
resolver - The SourceResolver to find resources within your context.
objectModel - A java.util.Map that contains the request and session information.
source - The value of the "src" attribute in the sitemap.
parameters - The sitemap parameters passed into your component.
Throws:
ProcessingException - if there is any other unexpected problem.
IOException - if there is a problem reading files.
SAXException - if there is a problem reading a SAX stream.

addEventListener

public void addEventListener(ElementEventListener l,
                             XmlTreeConstraint constraint)

setDocumentLocator

public void setDocumentLocator(Locator locator)
Description copied from class: AbstractXMLPipe
Receive an object for locating the origin of SAX document events.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class AbstractXMLPipe
Parameters:
locator - An object that can return the location of any SAX document event.

startElement

public void startElement(String uri,
                         String name,
                         String raw,
                         Attributes attributes)
                  throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of an element.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
name - 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.
attributes - 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 uri,
                       String name,
                       String raw)
                throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of an element.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
name - 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

characters

public void characters(char[] ary,
                       int start,
                       int length)
                throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of character data.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class AbstractXMLPipe
Parameters:
ary - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException

start

public void start(String name,
                  AttributesImpl attr)
           throws SAXException
Throws:
SAXException

start

public void start(String name)
           throws SAXException
Throws:
SAXException

end

public void end(String name)
         throws SAXException
Throws:
SAXException

data

public void data(String data)
          throws SAXException
Throws:
SAXException

getStringValue

public static String getStringValue(Object object)


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.