You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/01/27 16:34:14 UTC

svn commit: r372880 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java

Author: jeremias
Date: Fri Jan 27 07:34:10 2006
New Revision: 372880

URL: http://svn.apache.org/viewcvs?rev=372880&view=rev
Log:
Added safe-guard against reuse to avoid problems with the renderers.
Removed reset() method. Compared to the many hundred object instances that get created by the FO tree and layout engine, the Fop and FOTreeBuilder instance are negligible. Better keep the API as simple as possible and create an environmental class in the long run.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java?rev=372880&r1=372879&r2=372880&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java Fri Jan 27 07:34:10 2006
@@ -48,6 +48,8 @@
 
     /** The registry for ElementMapping instances */
     protected ElementMappingRegistry elementMappingRegistry;
+    //TODO Remove the ElementMappingRegistry from here and move it to a new environmental class
+    //FOTreeBuilder should be a "one-use" component.
     
     /**
      * The root of the formatting object tree
@@ -76,6 +78,8 @@
     /** The user agent for this processing run. */
     private FOUserAgent userAgent;
     
+    private boolean used = false;
+    
     /**
      * FOTreeBuilder constructor
      * @param outputFormat the MIME type of the output format to use (ex. "application/pdf").
@@ -143,6 +147,11 @@
      * @see org.xml.sax.ContentHandler#startDocument()
      */
     public void startDocument() throws SAXException {
+        if (used) {
+            throw new IllegalStateException("FOTreeBuilder (and the Fop class) cannot be reused."
+                    + " Please instantiate a new instance.");
+        }
+        used = true;
         rootFObj = null;    // allows FOTreeBuilder to be reused
         if (log.isDebugEnabled()) {
             log.debug("Building formatting object tree");
@@ -300,14 +309,5 @@
         }
     }
     
-    /**
-     * Resets this object for another run.
-     */
-    public void reset() {
-        currentFObj = null;
-        rootFObj = null;
-        foEventHandler = null;
-    }
-
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org