org.inria.ns.reflex.xml.provider.fo
Class FOPSerializer

java.lang.Object
  extended by org.inria.ns.reflex.structures.Configurable.Impl
      extended by org.inria.ns.reflex.xml.serialize.SwitchSerializer
          extended by org.inria.ns.reflex.xml.provider.fo.FOPSerializer
All Implemented Interfaces:
Configurable, Serializer

public class FOPSerializer
extends SwitchSerializer
implements Serializer

An XSLFO serializer. FOP is the concrete engine. An intermediate filter can be used for non XSLFO formats (XML+CSS, XHTML+CSS).

Author:
Philippe Poulard
See Also:
HTMLToXHTMLFilter, XHTMLToXSLFOFilter

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.structures.Configurable
Configurable.Impl
 
Field Summary
static String XMLNS_FOP
          The namespace URI for FOP parameters.
 
Constructor Summary
FOPSerializer(String mimeType)
           
 
Method Summary
 boolean acceptAttribute(QName name)
          Indicates whether this serializer accept an attribute or not.
 void connect(URIResolver uriResolver, String baseURL, XMLFilterImpl input, OutputStream output, String nsUri)
          Connect a SAX input to a FOP engine; if the input is not XSLFO, additional filters will be inserted between the SAX input and the FOP engine to transform HTML to XHTML if necessary, and XML+CSS to XSLFO.
 boolean containsAttribute(Object key)
          Returns true if the attributes set contains a mapping for the specified key.
 Object getAttribute(Object key)
          Returns an attribute that has been defined for the processor.
 Map getAttributes()
          Returns the set of attributes defined.
 void mergeAttributes(Map attributes)
          Merges 2 collections.
 void plugSerializer(URIResolver uriResolver, Source xmlSource, StreamResult streamResult, SAXBuffer buffer, OutputStream[] out, String nsURI)
          Adaptive connexion to FOP.
 void setAttribute(Object key, Object data)
          Defines an attribute.
 void setAttributes(Map attributes)
          Defines an attributes set.
 
Methods inherited from class org.inria.ns.reflex.xml.serialize.SwitchSerializer
getMimeType, serialize
 
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
serialize
 

Field Detail

XMLNS_FOP

public static String XMLNS_FOP
The namespace URI for FOP parameters.

Constructor Detail

FOPSerializer

public FOPSerializer(String mimeType)
Method Detail

acceptAttribute

public boolean acceptAttribute(QName name)
Description copied from interface: Serializer
Indicates whether this serializer accept an attribute or not.

Specified by:
acceptAttribute in interface Serializer
Parameters:
name - The name of the attribute.
Returns:
true if the attribute can be used to configure this serializer, false otherwise.

containsAttribute

public boolean containsAttribute(Object key)
Description copied from interface: Configurable
Returns true if the attributes set contains a mapping for the specified key.

Specified by:
containsAttribute in interface Configurable
Overrides:
containsAttribute in class Configurable.Impl
Parameters:
key - The key associated to the object.
Returns:
true if the attributes set contains a mapping for the specified key.

getAttribute

public Object getAttribute(Object key)
Description copied from interface: Configurable
Returns an attribute that has been defined for the processor. If none correspond to the key, null is returned.

Specified by:
getAttribute in interface Configurable
Overrides:
getAttribute in class Configurable.Impl
Parameters:
key - The key associated to the object.
Returns:
The object defined as an attribute.

getAttributes

public Map getAttributes()
Description copied from interface: Configurable
Returns the set of attributes defined.

Specified by:
getAttributes in interface Configurable
Overrides:
getAttributes in class Configurable.Impl
Returns:
The set of attributes defined.

setAttribute

public void setAttribute(Object key,
                         Object data)
Description copied from interface: Configurable
Defines an attribute.

Specified by:
setAttribute in interface Configurable
Overrides:
setAttribute in class Configurable.Impl
Parameters:
key - The key associated to the object.
data - The object to define as an attribute.

mergeAttributes

public void mergeAttributes(Map attributes)
Description copied from interface: Configurable
Merges 2 collections.

Specified by:
mergeAttributes in interface Configurable
Overrides:
mergeAttributes in class Configurable.Impl
Parameters:
attributes - The attributes set to merge with.

setAttributes

public void setAttributes(Map attributes)
Description copied from interface: Configurable
Defines an attributes set.

Specified by:
setAttributes in interface Configurable
Overrides:
setAttributes in class Configurable.Impl
Parameters:
attributes - The attributes set to define.

connect

public void connect(URIResolver uriResolver,
                    String baseURL,
                    XMLFilterImpl input,
                    OutputStream output,
                    String nsUri)
             throws org.apache.fop.apps.FOPException
Connect a SAX input to a FOP engine; if the input is not XSLFO, additional filters will be inserted between the SAX input and the FOP engine to transform HTML to XHTML if necessary, and XML+CSS to XSLFO.

Parameters:
uriResolver - The URI resolver to use for retrieving resources.
xmlSource - The source that fire SAX events.
input - The SAX input that propagates SAX events to FOP.
output - The output of the FOP engine.
nsUri - The namespace URI of the root element that will be serialized; can be XSLFO, HTML, or XML.
Throws:
org.apache.fop.apps.FOPException

plugSerializer

public void plugSerializer(URIResolver uriResolver,
                           Source xmlSource,
                           StreamResult streamResult,
                           SAXBuffer buffer,
                           OutputStream[] out,
                           String nsURI)
                    throws SAXException
Adaptive connexion to FOP.

Specified by:
plugSerializer in class SwitchSerializer
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
See Also:
connect(URIResolver, String, XMLFilterImpl, OutputStream, String)