org.apache.cocoon.serialization
Class AbstractTextSerializer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.serialization.AbstractSerializer
                          |
                          +--org.apache.cocoon.serialization.AbstractTextSerializer
All Implemented Interfaces:
Cacheable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, 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, Serializer, SitemapOutputComponent, XMLConsumer, XMLPipe, XMLProducer
Direct Known Subclasses:
HTMLSerializer, RTFSerializer, TextSerializer, XMLSerializer

public abstract class AbstractTextSerializer
extends AbstractSerializer
implements org.apache.avalon.framework.configuration.Configurable, Cacheable

Version:
CVS $Id: AbstractTextSerializer.java,v 1.9.2.2 2002/12/04 08:43:27 cziegeler Exp $
Author:
Pierpaolo Fumagalli (Apache Software Foundation, Exoffice Technologies), Stefano Mazzocchi, Sylvain Wallez

Inner Class Summary
static class AbstractTextSerializer.NamespaceAsAttributes
          A pipe that ensures that all namespace prefixes are also present as 'xmlns:' attributes.
 
Field Summary
protected  java.util.Properties format
          The Properties used by this serializer.
 
Fields inherited from class org.apache.cocoon.serialization.AbstractSerializer
output
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
 
Constructor Summary
AbstractTextSerializer()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Set the configurations for this serializer.
 long generateKey()
          Generate the unique key.
 CacheValidity generateValidity()
          Generate the validity object.
protected  javax.xml.transform.sax.SAXTransformerFactory getTransformerFactory()
          Helper for TransformerFactory.
protected  boolean needsNamespacesAsAttributes()
          Checks if the used Trax implementation correctly handles namespaces set using startPrefixMapping(), but wants them also as 'xmlns:' attributes.
 void recycle()
          Recycle serializer by removing references
 void setConsumer(XMLConsumer consumer)
          Interpose namespace pipe if needed.
 void setContentHandler(org.xml.sax.ContentHandler handler)
          Interpose namespace pipe if needed.
 void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
          Interpose namespace pipe if needed.
 void setOutputStream(java.io.OutputStream out)
          Set the OutputStream where the XML should be serialized.
 
Methods inherited from class org.apache.cocoon.serialization.AbstractSerializer
getMimeType, shouldSetContentLength
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping
 
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
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
 

Field Detail

format

protected java.util.Properties format
The Properties used by this serializer.
Constructor Detail

AbstractTextSerializer

public AbstractTextSerializer()
Method Detail

setConsumer

public void setConsumer(XMLConsumer consumer)
Interpose namespace pipe if needed.
Overrides:
setConsumer in class AbstractXMLProducer

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
Interpose namespace pipe if needed.
Overrides:
setContentHandler in class AbstractXMLProducer

setLexicalHandler

public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
Interpose namespace pipe if needed.
Overrides:
setLexicalHandler in class AbstractXMLProducer
Following copied from class: org.apache.cocoon.xml.AbstractXMLProducer
Throws:
java.lang.IllegalStateException - If the LexicalHandler or the XMLConsumer were already set.

getTransformerFactory

protected javax.xml.transform.sax.SAXTransformerFactory getTransformerFactory()
Helper for TransformerFactory.

setOutputStream

public void setOutputStream(java.io.OutputStream out)
Set the OutputStream where the XML should be serialized.
Overrides:
setOutputStream in class AbstractSerializer

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Set the configurations for this serializer.
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable

recycle

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

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.

needsNamespacesAsAttributes

protected boolean needsNamespacesAsAttributes()
                                       throws java.lang.Exception
Checks if the used Trax implementation correctly handles namespaces set using startPrefixMapping(), but wants them also as 'xmlns:' attributes.

The check consists in sending SAX events representing a minimal namespaced document with namespaces defined only with calls to startPrefixMapping (no xmlns:xxx attributes) and check if they are present in the resulting text.



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