org.apache.fop.apps
Class Driver

java.lang.Object
  |
  +--org.apache.fop.apps.Driver

public class Driver
extends java.lang.Object

Primary class that drives overall FOP process.

Once this class is instantiated, methods are called to set the Renderer to use, the (possibly multiple) ElementMapping(s) to use and the PrintWriter to use to output the results of the rendering (where applicable). In the case of the Renderer and ElementMapping(s), the Driver may be supplied either with the object itself, or the name of the class, in which case Driver will instantiate the class itself. The advantage of the latter is it enables runtime determination of Renderer and ElementMapping(s).

Once the Driver is set up, the buildFOTree method is called. Depending on whether DOM or SAX is being used, the invocation of the method is either buildFOTree(Document) or buildFOTree(Parser, InputSource) respectively.

A third possibility may be used to build the FO Tree, namely calling getContentHandler() and firing the SAX events yourself.

Once the FO Tree is built, the format() and render() methods may be called in that order.

Here is an example use of Driver from CommandLine.java:

   Driver driver = new Driver();
   driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);
   driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
   driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
   driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
   driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
   driver.setOutputStream(new FileOutputStream(args[1]));
   driver.buildFOTree(parser, fileInputSource(args[0]));
   driver.format();
   driver.render();
 


Field Summary
protected  AreaTree areaTree
          the area tree that is the result of formatting the FO tree
protected  boolean errorDump
          If true, full error stacks are reported
protected  Renderer renderer
          the renderer to use to output the area tree
protected  java.io.OutputStream stream
          the stream to use to output the results of the renderer
protected  FOTreeBuilder treeBuilder
          the FO tree builder
 
Constructor Summary
Driver()
          create a new Driver
 
Method Summary
 void addElementMapping(ElementMapping mapping)
          add the given element mapping.
 void addElementMapping(java.lang.String mappingClassName)
          add the element mapping with the given class name
 void addPropertyList(java.lang.String listClassName)
          add the element mapping with the given class name
 void buildFOTree(org.w3c.dom.Document document)
          build the formatting object tree using the given DOM Document
 void buildFOTree(org.xml.sax.XMLReader parser, org.xml.sax.InputSource source)
          build the formatting object tree using the given SAX Parser and SAX InputSource
protected  ElementMapping createElementMapping(java.lang.String mappingClassName)
          protected method used by addElementMapping(String) to instantiate element mapping class
protected  PropertyListMapping createPropertyList(java.lang.String listClassName)
          protected method used by addPropertyList(String) to instantiate list mapping class
protected  Renderer createRenderer(java.lang.String rendererClassName)
          protected method used by setRenderer(String, String) to instantiate the Renderer class
 void dumpError(java.lang.Exception e)
          Dumps an error
 void format()
          format the formatting object tree into an area tree
 org.xml.sax.ContentHandler getContentHandler()
          return the tree builder (a SAX ContentHandler).
 void loadStandardConfiguration()
          loads standard configuration file and a user file, if it has been specified
 void loadUserconfiguration(java.lang.String userConfigFile)
           
 void render()
          render the area tree to the output form
 void setBaseDir(java.lang.String fofile)
           
 void setErrorDump(boolean dump)
          Set the error dump option
 void setOutputStream(java.io.OutputStream stream)
          set the OutputStream to use to output the result of the Renderer (if applicable)
 void setRenderer(Renderer renderer)
          set the Renderer to use
 void setRenderer(java.lang.String rendererClassName, java.lang.String producer)
          set the class name of the Renderer to use as well as the producer string for those renderers that can make use of it
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

treeBuilder

protected FOTreeBuilder treeBuilder
the FO tree builder

areaTree

protected AreaTree areaTree
the area tree that is the result of formatting the FO tree

renderer

protected Renderer renderer
the renderer to use to output the area tree

stream

protected java.io.OutputStream stream
the stream to use to output the results of the renderer

errorDump

protected boolean errorDump
If true, full error stacks are reported
Constructor Detail

Driver

public Driver()
create a new Driver
Method Detail

setErrorDump

public void setErrorDump(boolean dump)
Set the error dump option
Parameters:
dump - if true, full stacks will be reported to the error log

setRenderer

public void setRenderer(Renderer renderer)
set the Renderer to use

setRenderer

public void setRenderer(java.lang.String rendererClassName,
                        java.lang.String producer)
set the class name of the Renderer to use as well as the producer string for those renderers that can make use of it

createRenderer

protected Renderer createRenderer(java.lang.String rendererClassName)
protected method used by setRenderer(String, String) to instantiate the Renderer class

addElementMapping

public void addElementMapping(ElementMapping mapping)
add the given element mapping. an element mapping maps element names to Java classes

addElementMapping

public void addElementMapping(java.lang.String mappingClassName)
add the element mapping with the given class name

createElementMapping

protected ElementMapping createElementMapping(java.lang.String mappingClassName)
protected method used by addElementMapping(String) to instantiate element mapping class

addPropertyList

public void addPropertyList(java.lang.String listClassName)
add the element mapping with the given class name

createPropertyList

protected PropertyListMapping createPropertyList(java.lang.String listClassName)
protected method used by addPropertyList(String) to instantiate list mapping class

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
return the tree builder (a SAX ContentHandler). used in situations where SAX is used but not via a FOP-invoked SAX parser. A good example is an XSLT engine that fires SAX events but isn't a SAX Parser itself.

buildFOTree

public void buildFOTree(org.xml.sax.XMLReader parser,
                        org.xml.sax.InputSource source)
                 throws FOPException
build the formatting object tree using the given SAX Parser and SAX InputSource

buildFOTree

public void buildFOTree(org.w3c.dom.Document document)
                 throws FOPException
build the formatting object tree using the given DOM Document

dumpError

public void dumpError(java.lang.Exception e)
Dumps an error

setOutputStream

public void setOutputStream(java.io.OutputStream stream)
set the OutputStream to use to output the result of the Renderer (if applicable)

format

public void format()
            throws FOPException
format the formatting object tree into an area tree

render

public void render()
            throws java.io.IOException,
                   FOPException
render the area tree to the output form

loadStandardConfiguration

public void loadStandardConfiguration()
loads standard configuration file and a user file, if it has been specified

loadUserconfiguration

public void loadUserconfiguration(java.lang.String userConfigFile)

setBaseDir

public void setBaseDir(java.lang.String fofile)


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.