net.sourceforge.chaperon.cocoon
Class PatternTransformer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.transformation.AbstractTransformer
                  extended by net.sourceforge.chaperon.cocoon.PatternTransformer
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.caching.CacheableProcessingComponent, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.transformation.Transformer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer, org.apache.excalibur.xml.sax.XMLConsumer, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler

public class PatternTransformer
extends org.apache.cocoon.transformation.AbstractTransformer
implements org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.parameters.Parameterizable, org.apache.cocoon.caching.CacheableProcessingComponent

This transfomer transforms text pattern of a XML file into lexemes by using a lexicon file.

Input:

 <section>
  Text 123 bla
 </section>
 

can be transformed into the following output:

 <section>
  Text
  <lexeme symbol="number" text="123"/>
  bla
 </section>
 

Version:
CVS $Id: PatternTransformer.java,v 1.3 2004/01/18 01:36:29 benedikta Exp $
Author:
Stephan Michels

Nested Class Summary
 class PatternTransformer.LexicalAutomatonEntry
          This class represent a entry in a store to cache the lexical automaton.
 
Field Summary
static java.lang.String NS
          Namespace for the SAX events.
 
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
PatternTransformer()
           
 
Method Summary
 void characters(char[] c, int start, int len)
          Receive notification of character data.
 void comment(char[] ch, int start, int len)
          Report an XML comment anywhere in the document.
 void dispose()
          The dispose operation is called at the end of a components lifecycle.
 void enableLogging(org.apache.avalon.framework.logger.Logger logger)
          Provide component with a logger.
 void endElement(java.lang.String uri, java.lang.String loc, java.lang.String raw)
          Receive notification of the end of an element.
 java.io.Serializable getKey()
          Generate the unique key.
 org.apache.excalibur.source.SourceValidity getValidity()
          Generate the validity object.
 void ignorableWhitespace(char[] c, int start, int len)
          Receive notification of ignorable whitespace in element content.
 void parameterize(org.apache.avalon.framework.parameters.Parameters parameters)
          Provide component with parameters.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
 void recycle()
          Recycle this component.
 void service(org.apache.avalon.framework.service.ServiceManager manager)
          Pass the ServiceManager to the Serviceable.
 void setup(org.apache.cocoon.environment.SourceResolver resolver, java.util.Map objectmodel, java.lang.String src, org.apache.avalon.framework.parameters.Parameters parameters)
          Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the request.
 void startElement(java.lang.String uri, java.lang.String loc, java.lang.String raw, org.xml.sax.Attributes a)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
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, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

NS

public static final java.lang.String NS
Namespace for the SAX events.

See Also:
Constant Field Values
Constructor Detail

PatternTransformer

public PatternTransformer()
Method Detail

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
Provide component with a logger.

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
Overrides:
enableLogging in class org.apache.avalon.framework.logger.AbstractLogEnabled
Parameters:
logger - the logger

service

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

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

parameterize

public void parameterize(org.apache.avalon.framework.parameters.Parameters parameters)
                  throws org.apache.avalon.framework.parameters.ParameterException
Provide component with parameters.

Specified by:
parameterize in interface org.apache.avalon.framework.parameters.Parameterizable
Parameters:
parameters - the parameters
Throws:
org.apache.avalon.framework.parameters.ParameterException - if parameters are invalid

setup

public void setup(org.apache.cocoon.environment.SourceResolver resolver,
                  java.util.Map objectmodel,
                  java.lang.String src,
                  org.apache.avalon.framework.parameters.Parameters parameters)
           throws org.apache.cocoon.ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the request.

Specified by:
setup in interface org.apache.cocoon.sitemap.SitemapModelComponent
Parameters:
resolver - Source resolver
objectmodel - Object model
src - Source
parameters - Parameters
Throws:
java.io.IOException
org.apache.cocoon.ProcessingException
org.xml.sax.SAXException

getKey

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

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated key hashes the src

getValidity

public org.apache.excalibur.source.SourceValidity getValidity()
Generate the validity object.

Specified by:
getValidity in interface org.apache.cocoon.caching.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 org.apache.avalon.excalibur.pool.Recyclable
Overrides:
recycle in class org.apache.cocoon.xml.AbstractXMLProducer

dispose

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

Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

startElement

public void startElement(java.lang.String uri,
                         java.lang.String loc,
                         java.lang.String raw,
                         org.xml.sax.Attributes a)
                  throws org.xml.sax.SAXException
Receive notification of the beginning of an element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.apache.cocoon.xml.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.
loc - 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.
a - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String loc,
                       java.lang.String raw)
                throws org.xml.sax.SAXException
Receive notification of the end of an element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.apache.cocoon.xml.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.
loc - 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:
org.xml.sax.SAXException

characters

public void characters(char[] c,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
Receive notification of character data.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
c - The characters from the XML document.
start - The start position in the array.
len - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] c,
                                int start,
                                int len)
                         throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
c - The characters from the XML document.
start - The start position in the array.
len - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Receive notification of a processing instruction.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none was supplied.
Throws:
org.xml.sax.SAXException

comment

public void comment(char[] ch,
                    int start,
                    int len)
             throws org.xml.sax.SAXException
Report an XML comment anywhere in the document.

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
Overrides:
comment in class org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
ch - An array holding the characters in the comment.
start - The starting position in the array.
len - The number of characters to use from the array.
Throws:
org.xml.sax.SAXException


Copyright ? 2003 Chaperon project. All Rights Reserved.