org.apache.cocoon.transformation
Class ParserTransformer

java.lang.Object
  extended by net.sourceforge.chaperon.process.ParserProcessor
      extended by org.apache.cocoon.transformation.ParserTransformer
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, LogEnabled, Parameterizable, Serviceable, CacheableProcessingComponent, SitemapModelComponent, Transformer, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class ParserTransformer
extends net.sourceforge.chaperon.process.ParserProcessor
implements Transformer, LogEnabled, Serviceable, Parameterizable, Recyclable, Disposable, CacheableProcessingComponent

This transfomer transforms lexical tokens in a XML file into a XML hirachy by using a grammar file.

Input:

 <lexemes xmlns="http://chaperon.sourceforge.net/schema/lexemes/1.0">
  <lexeme symbol="word" text="Text"/>
  <lexeme symbol="number" text="123"/>
  <lexeme symbol="word" text="bla"/>
 </lexemes>
 

were transform into the following output:

 <sentence xmlns="http://chaperon.sourceforge.net/schema/syntaxtree/1.0">
  <word>Text</word>
  <number>123</number>
  <word>bla</word>
 </sentence>
 

Version:
CVS $Id: ParserTransformer.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Stephan Michels

Nested Class Summary
static class ParserTransformer.ParserAutomatonEntry
          This class represent a entry in a store to cache the parser automaton.
 
Field Summary
 
Fields inherited from class net.sourceforge.chaperon.process.ParserProcessor
ERROR, NS_OUTPUT, OUTPUT
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
ParserTransformer()
           
 
Method Summary
 void dispose()
          The dispose operation is called at the end of a components lifecycle.
 void enableLogging(Logger logger)
          Provide component with a logger.
 Serializable getKey()
          Generate the unique key.
 SourceValidity getValidity()
          Generate the validity object.
 void parameterize(Parameters parameters)
          Provide component with parameters.
 void recycle()
          Recycle this component.
 void service(ServiceManager manager)
          Pass the ServiceManager to the object.
 void setConsumer(XMLConsumer consumer)
          Set the XMLConsumer that will receive XML data.
 void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters)
          Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the request.
 
Methods inherited from class net.sourceforge.chaperon.process.ParserProcessor
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setContentHandler, setDocumentLocator, setFailSafe, setFlatten, setLexicalHandler, setLocalizable, setLog, setParserAutomaton, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping
 
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
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 

Constructor Detail

ParserTransformer

public ParserTransformer()
Method Detail

enableLogging

public void enableLogging(Logger logger)
Provide component with a logger.

Specified by:
enableLogging in interface LogEnabled
Parameters:
logger - the logger

service

public void service(ServiceManager manager)
Pass the ServiceManager to the object. The Serviceable implementation should use the specified ServiceManager to acquire the services it needs for execution.

Specified by:
service in interface Serviceable
Parameters:
manager - The ServiceManager which this Serviceable uses.

parameterize

public void parameterize(Parameters parameters)
                  throws ParameterException
Provide component with parameters.

Specified by:
parameterize in interface Parameterizable
Parameters:
parameters - the parameters
Throws:
ParameterException - if parameters are invalid

setConsumer

public void setConsumer(XMLConsumer consumer)
Set the XMLConsumer that will receive XML data.

Specified by:
setConsumer in interface XMLProducer
Parameters:
consumer -

setup

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

Specified by:
setup in interface SitemapModelComponent
Parameters:
resolver - Source resolver
objectmodel - Object model
src - Source
parameters - Parameters
Throws:
IOException
ProcessingException
SAXException

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.

recycle

public void recycle()
Recycle this component. All instance variables are set to null.

Specified by:
recycle in interface Recyclable

dispose

public void dispose()
The dispose operation is called at the end of a components lifecycle.

Specified by:
dispose in interface Disposable


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