org.inria.ns.reflex.xml.serialize
Class SwitchSerializer

java.lang.Object
  extended by org.inria.ns.reflex.structures.Configurable.Impl
      extended by org.inria.ns.reflex.xml.serialize.SwitchSerializer
All Implemented Interfaces:
Configurable, Serializer
Direct Known Subclasses:
FOPSerializer, PageSerializer

public abstract class SwitchSerializer
extends Configurable.Impl
implements Serializer

A switch that selects the right serializer according to the root element encountered (SVG, XSLFO, etc).

Author:
Philippe Poulard

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.structures.Configurable
Configurable.Impl
 
Constructor Summary
SwitchSerializer(String mimeType)
          Create a switch.
 
Method Summary
 String getMimeType()
          Return the MIME type.
abstract  void plugSerializer(URIResolver uriResolver, Source xmlSource, StreamResult streamResult, SAXBuffer buffer, OutputStream[] out, String nsURI)
          Plug a concrete serializer according to the namespace URI of the root element.
 void serialize(URIResolver uriResolver, Source xmlSource, StreamResult xmlResult)
          Cast the source to a SAX source and bufferize events until the root element is read, then invoke plugSerializer(URIResolver, Source, StreamResult, SAXBuffer, OutputStream[], String).
 
Methods inherited from class org.inria.ns.reflex.structures.Configurable.Impl
containsAttribute, getAttribute, getAttributes, mergeAttributes, setAttribute, setAttributes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.inria.ns.reflex.xml.serialize.Serializer
acceptAttribute
 
Methods inherited from interface org.inria.ns.reflex.structures.Configurable
containsAttribute, getAttribute, getAttributes, mergeAttributes, setAttribute, setAttributes
 

Constructor Detail

SwitchSerializer

public SwitchSerializer(String mimeType)
Create a switch.

Parameters:
mimeType - The target MIME type, "image/png", "application/pdf", etc.
Method Detail

plugSerializer

public abstract void plugSerializer(URIResolver uriResolver,
                                    Source xmlSource,
                                    StreamResult streamResult,
                                    SAXBuffer buffer,
                                    OutputStream[] out,
                                    String nsURI)
                             throws SAXException
Plug a concrete serializer according to the namespace URI of the root element.

Parameters:
uriResolver - The URI resolver to use by the serializer to resolve references found in the source to serialize.
xmlSource - The XML source from which SAX events are fired (and so far that have been bufferized)
streamResult - The stream where the serializer have to write.
buffer - The SAX events that have been bufferized so far.
out - An array that contains a single output to write to; if this method use intermediate pipelines, it may change out[0] with the new output stream in order to don't break pipes.
nsURI - The namespace URI of the root element.
Throws:
SAXException

serialize

public void serialize(URIResolver uriResolver,
                      Source xmlSource,
                      StreamResult xmlResult)
               throws SerializeException
Cast the source to a SAX source and bufferize events until the root element is read, then invoke plugSerializer(URIResolver, Source, StreamResult, SAXBuffer, OutputStream[], String).

Specified by:
serialize in interface Serializer
Parameters:
uriResolver - The URI resolver to use for resolving references.
xmlSource - The source to read.
xmlResult - The output stream where to write.
Throws:
SerializeException

getMimeType

public String getMimeType()
Return the MIME type.

Returns:
The MIME type.