org.apache.cocoon.transformation
Class FilterTransformer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.transformation.AbstractTransformer
                          |
                          +--org.apache.cocoon.transformation.FilterTransformer
All Implemented Interfaces:
Cacheable, org.apache.avalon.framework.component.Component, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLPipe, XMLProducer
Direct Known Subclasses:
RoleFilterTransformer

public class FilterTransformer
extends AbstractTransformer
implements Cacheable

The filter transformer can be used to let only an amount of elements through in a given block. Usage in sitemap <map:transform type="filter"> <map:parameter name="element-name" value="row"/> <map:parameter name="count" value="5"/> <map:parameter name="blocknr" value="3"/> </map:transform> Only the 3th block will be shown, containing only 5 row elements.

Version:
CVS $Id: FilterTransformer.java,v 1.7 2002/02/22 07:03:56 cziegeler Exp $
Author:
Sven Beauprez, Carsten Ziegeler

Field Summary
protected  int blocknr
           
protected  int count
           
protected  int counter
           
protected  int currentBlocknr
           
protected  java.lang.String elementName
           
protected  boolean foundIt
           
protected  java.lang.String parentName
           
protected  boolean skip
           
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
FilterTransformer()
           
 
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 endCDATA()
          Report the end of a CDATA section.
 void endElement(java.lang.String uri, java.lang.String name, java.lang.String raw)
          Receive notification of the end of an element.
 void endEntity(java.lang.String name)
          Report the end of an entity.
 long generateKey()
          Generate the unique key.
 CacheValidity generateValidity()
          Generate the validity object.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
          BEGIN SitemapComponent methods
 void startCDATA()
          Report the start of a CDATA section.
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attributes)
          BEGIN SAX ContentHandler handlers
 void startEntity(java.lang.String name)
          Report the beginning of an entity.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
endDocument, endDTD, endPrefixMapping, ignorableWhitespace, setDocumentLocator, skippedEntity, startDocument, startDTD, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
recycle, setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, 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, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
endDTD, startDTD
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

counter

protected int counter

count

protected int count

blocknr

protected int blocknr

currentBlocknr

protected int currentBlocknr

elementName

protected java.lang.String elementName

parentName

protected java.lang.String parentName

skip

protected boolean skip

foundIt

protected boolean foundIt
Constructor Detail

FilterTransformer

public FilterTransformer()
Method Detail

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String source,
                  org.apache.avalon.framework.parameters.Parameters parameters)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
BEGIN SitemapComponent methods

generateKey

public long generateKey()
Generate the unique key. This key must be unique inside the space of this component. This method must be invoked before the generateValidity() method.
Specified by:
generateKey in interface Cacheable
Returns:
The generated key or 0 if the component is currently not cacheable.

generateValidity

public CacheValidity generateValidity()
Generate the validity object. Before this method can be invoked the generateKey() method must be invoked.
Specified by:
generateValidity in interface Cacheable
Returns:
The generated validity object or null if the component is currently not cacheable.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String raw,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
BEGIN SAX ContentHandler handlers
Overrides:
startElement in class AbstractXMLPipe
Following copied from 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.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String name,
                       java.lang.String raw)
                throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of an element.
Overrides:
endElement in class AbstractXMLPipe
Following copied from 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.

characters

public void characters(char[] c,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of character data.
Overrides:
characters in class AbstractXMLPipe
Following copied from 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.

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of a processing instruction.
Overrides:
processingInstruction in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none was supplied.

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Report the beginning of an entity.
Overrides:
startEntity in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Report the end of an entity.
Overrides:
endEntity in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
name - The name of the entity that is ending.

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Report the start of a CDATA section.
Overrides:
startCDATA in class AbstractXMLPipe

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Report the end of a CDATA section.
Overrides:
endCDATA in class AbstractXMLPipe

comment

public void comment(char[] ch,
                    int start,
                    int len)
             throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Report an XML comment anywhere in the document.
Overrides:
comment in class AbstractXMLPipe
Following copied from 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.


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.