org.apache.cocoon.serialization
Class SVGSerializer

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

public class SVGSerializer
extends SVGBuilder
implements Serializer, Configurable, CacheableProcessingComponent, Contextualizable

A Batik based Serializer for generating PNG/JPEG images

Version:
$Id: SVGSerializer.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Davanum Srinivas, Ross Burton

Nested Class Summary
 
Nested classes/interfaces 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
enableLogging, 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 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 SitemapOutputComponent
See Also:
AbstractProcessingPipeline.setMimeTypeForSerializer(org.apache.cocoon.environment.Environment), AbstractProcessingPipeline.setMimeTypeForReader(org.apache.cocoon.environment.Environment)

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 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 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 Cocoon.process(org.apache.cocoon.environment.Environment) tries to close the stream.

Specified by:
shouldSetContentLength in interface SitemapOutputComponent


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