org.apache.cocoon.serialization
Class TextSerializer

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.serialization.AbstractSerializer
                  extended byorg.apache.cocoon.serialization.AbstractTextSerializer
                      extended byorg.apache.cocoon.serialization.TextSerializer
All Implemented Interfaces:
CacheableProcessingComponent, Configurable, ContentHandler, LexicalHandler, LogEnabled, Poolable, Recyclable, Serializer, SitemapOutputComponent, XMLConsumer, XMLConsumer, XMLPipe, XMLProducer

public class TextSerializer
extends AbstractTextSerializer

Text serializer converts XML into plain text. It omits all XML tags and writes only character events to the output. Internally, text serializer uses XML serializer with OutputKeys.METHOD set to text.

Input document must have at least one element - root element - which should wrap all the text inside it.

Version:
$Id: TextSerializer.java 171341 2005-05-22 16:35:41Z cziegeler $
Author:
Stefano Mazzocchi

Nested Class Summary
 
Nested classes inherited from class org.apache.cocoon.serialization.AbstractTextSerializer
AbstractTextSerializer.NamespaceAsAttributes
 
Field Summary
 
Fields inherited from class org.apache.cocoon.serialization.AbstractTextSerializer
format
 
Fields inherited from class org.apache.cocoon.serialization.AbstractSerializer
output
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
 
Constructor Summary
TextSerializer()
           
 
Method Summary
 void characters(char[] c, int start, int len)
          Receive notification of character data.
 void configure(Configuration conf)
          Set the configurations for this serializer.
 void endDocument()
          Receive notification of the end of a document.
 void recycle()
          Recycle serializer by removing references
 void setOutputStream(OutputStream out)
          Set the OutputStream where the requested resource should be serialized.
 void startElement(String uri, String loc, String raw, Attributes a)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.serialization.AbstractTextSerializer
configure, getKey, getTransformerFactory, getTransformerHandler, getValidity, needsNamespacesAsAttributes, setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.cocoon.serialization.AbstractSerializer
getMimeType, shouldSetContentLength
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
comment, endCDATA, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, 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
 
Methods inherited from interface org.xml.sax.ContentHandler
endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 

Constructor Detail

TextSerializer

public TextSerializer()
Method Detail

configure

public void configure(Configuration conf)
               throws ConfigurationException
Set the configurations for this serializer.

Specified by:
configure in interface Configurable
Overrides:
configure in class AbstractTextSerializer
Throws:
ConfigurationException

setOutputStream

public void setOutputStream(OutputStream out)
                     throws IOException
Set the OutputStream where the requested resource should be serialized.

Specified by:
setOutputStream in interface SitemapOutputComponent
Overrides:
setOutputStream in class AbstractTextSerializer
Throws:
IOException

startElement

public void startElement(String uri,
                         String loc,
                         String raw,
                         Attributes a)
                  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.
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:
SAXException

characters

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

Specified by:
characters in interface ContentHandler
Overrides:
characters in class 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:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of a document.

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

recycle

public void recycle()
Description copied from class: AbstractSerializer
Recycle serializer by removing references

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractTextSerializer
See Also:
Recyclable.recycle()


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