fop 0.91beta

org.apache.fop.fo
Class FOTreeBuilder

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.apache.fop.fo.FOTreeBuilder
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class FOTreeBuilder
extends org.xml.sax.helpers.DefaultHandler

SAX Handler that passes parsed data to the various FO objects, where they can be used either to build an FO Tree, or used by Structure Renderers to build other data structures.


Field Summary
protected  FONode currentFObj
          Current formatting object being handled
protected  PropertyList currentPropertyList
          Current propertyList for the node being handled.
protected  java.util.Map fobjTable
          Table mapping element names to the makers of objects representing formatting objects.
protected  org.apache.commons.logging.Log log
          logging instance
protected  java.util.Set namespaces
          Set of mapped namespaces.
protected  Root rootFObj
          The root of the formatting object tree
 
Constructor Summary
FOTreeBuilder(java.lang.String outputFormat, FOUserAgent foUserAgent, java.io.OutputStream stream)
          FOTreeBuilder constructor
 
Method Summary
 void addElementMapping(java.lang.String mappingClassName)
          Add the element mapping with the given class name.
 void characters(char[] data, int start, int length)
          SAX Handler for characters
 void endDocument()
          SAX Handler for the end of the document
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)
          SAX Handler for the end of an element
 void error(org.xml.sax.SAXParseException e)
           
 void fatalError(org.xml.sax.SAXParseException e)
           
protected  org.xml.sax.Locator getEffectiveLocator()
           
 FOEventHandler getEventHandler()
          Provides access to the underlying FOEventHandler object.
 FormattingResults getResults()
          Returns the results of the rendering process.
protected  boolean isLocatorDisabled()
          This method enables to reduce memory consumption of the FO tree slightly.
 void reset()
          Resets this object for another run.
 void setDocumentLocator(org.xml.sax.Locator locator)
          SAX Handler for locator
 void startDocument()
          SAX Handler for the start of the document
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attlist)
          SAX Handler for the start of an element
 void warning(org.xml.sax.SAXParseException e)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fobjTable

protected java.util.Map fobjTable
Table mapping element names to the makers of objects representing formatting objects.

log

protected org.apache.commons.logging.Log log
logging instance

namespaces

protected java.util.Set namespaces
Set of mapped namespaces.

rootFObj

protected Root rootFObj
The root of the formatting object tree

currentFObj

protected FONode currentFObj
Current formatting object being handled

currentPropertyList

protected PropertyList currentPropertyList
Current propertyList for the node being handled.
Constructor Detail

FOTreeBuilder

public FOTreeBuilder(java.lang.String outputFormat,
                     FOUserAgent foUserAgent,
                     java.io.OutputStream stream)
              throws FOPException
FOTreeBuilder constructor
Parameters:
outputFormat - the MIME type of the output format to use (ex. "application/pdf").
foUserAgent - in effect for this process
stream - OutputStream to direct results
Throws:
FOPException - if the FOTreeBuilder cannot be properly created
Method Detail

addElementMapping

public void addElementMapping(java.lang.String mappingClassName)
                       throws java.lang.IllegalArgumentException
Add the element mapping with the given class name.
Parameters:
mappingClassName - the class name representing the element mapping.
Throws:
java.lang.IllegalArgumentException - if there was not such element mapping.

isLocatorDisabled

protected boolean isLocatorDisabled()
This method enables to reduce memory consumption of the FO tree slightly. When it returns true no Locator is passed to the FO tree nodes which would copy the information into a SAX LocatorImpl instance.
Returns:
true if no context information should be stored on each node in the FO tree.

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
SAX Handler for locator
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.setDocumentLocator(Locator)

getEffectiveLocator

protected org.xml.sax.Locator getEffectiveLocator()
Returns:
a Locator instance if it is available and not disabled

characters

public void characters(char[] data,
                       int start,
                       int length)
                throws FOPException
SAX Handler for characters
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.characters(char[], int, int)

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
SAX Handler for the start of the document
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
SAX Handler for the end of the document
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.endDocument()

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String rawName,
                         org.xml.sax.Attributes attlist)
                  throws org.xml.sax.SAXException
SAX Handler for the start of an element
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.startElement(String, String, String, Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws FOPException
SAX Handler for the end of an element
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.endElement(String, String, String)

warning

public void warning(org.xml.sax.SAXParseException e)
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException)

error

public void error(org.xml.sax.SAXParseException e)
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
See Also:
ErrorHandler.error(org.xml.sax.SAXParseException)

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException)

getEventHandler

public FOEventHandler getEventHandler()
Provides access to the underlying FOEventHandler object.
Returns:
the FOEventHandler object

getResults

public FormattingResults getResults()
Returns the results of the rendering process. Information includes the total number of pages generated and the number of pages per page-sequence.
Returns:
the results of the rendering process.

reset

public void reset()
Resets this object for another run.

fop 0.91beta

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