org.apache.cocoon.serialization
Class SVGSerializer

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.apache.batik.dom.util.SAXDocumentFactory
          extended byorg.apache.batik.dom.svg.SAXSVGDocumentFactory
              extended byorg.apache.cocoon.xml.dom.SVGBuilder
                  extended byorg.apache.cocoon.serialization.SVGSerializer
All Implemented Interfaces:
org.apache.cocoon.caching.CacheableProcessingComponent, Configurable, ContentHandler, Contextualizable, org.apache.batik.dom.util.DocumentFactory, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler, Poolable, Recyclable, org.apache.cocoon.serialization.Serializer, org.apache.cocoon.sitemap.SitemapOutputComponent, org.apache.batik.dom.svg.SVGDocumentFactory, org.apache.cocoon.xml.XMLConsumer, XMLConsumer

public class SVGSerializer
extends SVGBuilder
implements Contextualizable, Configurable, org.apache.cocoon.caching.CacheableProcessingComponent, org.apache.cocoon.serialization.Serializer

A Batik based Serializer for generating PNG/JPEG images

Version:
$Id: SVGSerializer.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
 
Nested classes inherited from class org.apache.batik.dom.util.SAXDocumentFactory
org.apache.batik.dom.util.SAXDocumentFactory.PreInfo
 
Field Summary
 
Fields inherited from class org.apache.cocoon.xml.dom.SVGBuilder
locator, log
 
Fields inherited from class org.apache.batik.dom.svg.SAXSVGDocumentFactory
dtdids, DTDIDS, dtdProps, HTTP_CHARSET, KEY_PUBLIC_IDS, KEY_SKIP_DTD, KEY_SKIPPABLE_PUBLIC_IDS, KEY_SYSTEM_ID, LOCK, skip_dtd, skippable_dtdids
 
Fields inherited from class org.apache.batik.dom.util.SAXDocumentFactory
createDocumentDescriptor, currentNode, document, documentDescriptor, errorHandler, implementation, inCDATA, inDTD, isValidating, namespaces, parserClassName, preInfo, stringBuffer, stringContent
 
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
 
Constructor Summary
SVGSerializer()
           
 
Method Summary
 void configure(Configuration conf)
          Set the configurations for this serializer.
 void contextualize(Context context)
          Get the context
 Serializable getKey()
          Generate the unique key.
 String getMimeType()
          Return the MIME type.
 SourceValidity getValidity()
          Generate the validity object.
 void notify(Document doc)
          Receive notification of a successfully completed DOM tree generation.
 void setOutputStream(OutputStream out)
          Set the OutputStream where the XML should be serialized.
 boolean shouldSetContentLength()
          Returns true so the pipeline implementation will buffer generated output and write content length to the response.
 
Methods inherited from class org.apache.cocoon.xml.dom.SVGBuilder
endDocument, getDocument, getLogger, recycle, setDocumentLocator, startDocument
 
Methods inherited from class org.apache.batik.dom.svg.SAXSVGDocumentFactory
createDocument, createDocument, createDocument, createDocument, createDocument, createDocument, createSVGDocument, createSVGDocument, createSVGDocument, getDOMImplementation, resolveEntity
 
Methods inherited from class org.apache.batik.dom.util.SAXDocumentFactory
appendStringData, characters, comment, createDocument, createDocument, createDocument, endCDATA, endDTD, endElement, endEntity, error, fatalError, getDocumentDescriptor, ignorableWhitespace, isValidating, processingInstruction, setErrorHandler, setValidating, startCDATA, startDTD, startElement, startEntity, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, notationDecl, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
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
 
Methods inherited from interface org.apache.batik.dom.util.DocumentFactory
createDocument, getDocumentDescriptor, isValidating, setValidating
 

Constructor Detail

SVGSerializer

public SVGSerializer()
Method Detail

contextualize

public void contextualize(Context context)
                   throws ContextException
Get the context

Specified by:
contextualize in interface Contextualizable
Throws:
ContextException

setOutputStream

public void setOutputStream(OutputStream out)
Set the OutputStream where the XML should be serialized.

Specified by:
setOutputStream in interface org.apache.cocoon.sitemap.SitemapOutputComponent

configure

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

Specified by:
configure in interface Configurable
Throws:
ConfigurationException

notify

public void notify(Document doc)
            throws SAXException
Receive notification of a successfully completed DOM tree generation.

Overrides:
notify in class SVGBuilder
Throws:
SAXException

getMimeType

public String getMimeType()
Return the MIME type.

Specified by:
getMimeType in interface org.apache.cocoon.sitemap.SitemapOutputComponent

getKey

public Serializable getKey()
Generate the unique key. This key must be unique inside the space of this component. This method must be invoked before the getValidity() method.

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated key or 0 if the component is currently not cacheable.

getValidity

public SourceValidity getValidity()
Generate the validity object. Before this method can be invoked the getKey() method must be invoked.

Specified by:
getValidity in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

shouldSetContentLength

public boolean shouldSetContentLength()
Returns true so the pipeline implementation will buffer generated output and write content length to the response.

Batik's PNGTranscoder closes the output stream, therefore we cannot pass the output stream directly to Batik and have to instruct pipeline to buffer it. If we do not buffer, we would get an exception when org.apache.cocoon.Cocoon#process(org.apache.cocoon.environment.Environment) tries to close the stream.

Specified by:
shouldSetContentLength in interface org.apache.cocoon.sitemap.SitemapOutputComponent


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.