org.apache.cocoon.portal.serialization
Class IncludingHTMLSerializer

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.serialization.AbstractSerializer
                  extended by org.apache.cocoon.serialization.AbstractTextSerializer
                      extended by org.apache.cocoon.serialization.HTMLSerializer
                          extended by org.apache.cocoon.portal.serialization.IncludingHTMLSerializer
All Implemented Interfaces:
Poolable, Recyclable, Component, Configurable, Contextualizable, LogEnabled, CacheableProcessingComponent, Serializer, SitemapOutputComponent, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class IncludingHTMLSerializer
extends HTMLSerializer

This is a special serializer that allows to include content that is not XML at the last possible point. This is very useful for the portlets as they don't deliver valid XML but HTML. The trick is to insert a special token in the characters of the SAX stream: '~~'. This token is filtered later on and replaced with the complete content of the portlet.

Version:
CVS $Id: IncludingHTMLSerializer.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Carsten Ziegeler

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.cocoon.serialization.AbstractTextSerializer
AbstractTextSerializer.NamespaceAsAttributes
 
Field Summary
protected  String encoding
          The encoding.
static String NAMESPACE
           
protected  LinkedList orderedPortletList
           
static ThreadLocal portlets
           
protected static char token
           
protected static char[] tokens
           
 
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
IncludingHTMLSerializer()
           
 
Method Summary
static void addPortlet(String name, String content)
          Add a portlet
 void configure(Configuration conf)
          Set the configurations for this serializer.
 void endElement(String uri, String loc, String raw)
          Receive notification of the end of an element.
 void recycle()
          Recycle serializer by removing references
 void setOutputStream(OutputStream stream)
          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
contextualize, 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
characters, comment, endCDATA, endDocument, endDTD, 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
characters, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 

Field Detail

portlets

public static final ThreadLocal portlets

NAMESPACE

public static final String NAMESPACE
See Also:
Constant Field Values

orderedPortletList

protected LinkedList orderedPortletList

token

protected static final char token
See Also:
Constant Field Values

tokens

protected static final char[] tokens

encoding

protected String encoding
The encoding.

Constructor Detail

IncludingHTMLSerializer

public IncludingHTMLSerializer()
Method Detail

configure

public void configure(Configuration conf)
               throws ConfigurationException
Description copied from class: HTMLSerializer
Set the configurations for this serializer.

Specified by:
configure in interface Configurable
Overrides:
configure in class HTMLSerializer
Throws:
ConfigurationException
See Also:
HTMLSerializer.configure(org.apache.avalon.framework.configuration.Configuration)

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()

addPortlet

public static void addPortlet(String name,
                              String content)
Add a portlet


endElement

public void endElement(String uri,
                       String loc,
                       String raw)
                throws SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of an element.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement 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.
Throws:
SAXException
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

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
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

setOutputStream

public void setOutputStream(OutputStream stream)
                     throws IOException
Description copied from class: HTMLSerializer
Set the OutputStream where the requested resource should be serialized.

Specified by:
setOutputStream in interface SitemapOutputComponent
Overrides:
setOutputStream in class HTMLSerializer
Throws:
IOException
See Also:
SitemapOutputComponent.setOutputStream(java.io.OutputStream)


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