aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-01-27 15:34:10 +0000
committerJeremias Maerki <jeremias@apache.org>2006-01-27 15:34:10 +0000
commit951ce154766871a9a2d9c0d5941c9a6dfe5d9250 (patch)
treeaeb2a39bbf13b93f5e8847390b67ca24c537f6fc
parentc6e95444dd433fffa81a41821d235e51c6dde98c (diff)
downloadxmlgraphics-fop-951ce154766871a9a2d9c0d5941c9a6dfe5d9250.tar.gz
xmlgraphics-fop-951ce154766871a9a2d9c0d5941c9a6dfe5d9250.zip
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. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@372880 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index c0aa87a44..f674d58c8 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -48,6 +48,8 @@ public class FOTreeBuilder extends DefaultHandler {
/** 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 @@ public class FOTreeBuilder extends DefaultHandler {
/** 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 @@ public class FOTreeBuilder extends DefaultHandler {
* @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 @@ public class FOTreeBuilder extends DefaultHandler {
}
}
- /**
- * Resets this object for another run.
- */
- public void reset() {
- currentFObj = null;
- rootFObj = null;
- foEventHandler = null;
- }
-
}