aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/fo/FONode.java11
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java21
-rw-r--r--src/java/org/apache/fop/fo/expr/PropertyException.java9
-rw-r--r--src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java4
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequence.java4
-rw-r--r--src/java/org/apache/fop/fo/properties/PropertyMaker.java2
6 files changed, 38 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index caab92318..5832abe47 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -23,6 +23,7 @@ import java.util.ListIterator;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
+import org.xml.sax.helpers.LocatorImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,13 +47,13 @@ public abstract class FONode implements Cloneable {
/** Parent FO node */
protected FONode parent;
- /** Marks location of this object from the input FO
+ /**
+ * Marks location of this object from the input FO
* Call locator.getSystemId(), getLineNumber(),
* getColumnNumber() for file, line, column
* information
*/
- public Locator locator;
- //TODO Make private or protected and access via getLocator()
+ protected Locator locator;
/** Logger for fo-tree related messages **/
protected static Log log = LogFactory.getLog(FONode.class);
@@ -102,7 +103,9 @@ public abstract class FONode implements Cloneable {
*/
public void setLocator(Locator locator) {
if (locator != null) {
- this.locator = locator;
+ //Create a copy of the locator so the info is preserved when we need to
+ //give pointers during layout.
+ this.locator = new LocatorImpl(locator);
}
}
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index bd8017e76..cc87fcca9 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -185,6 +185,18 @@ public class FOTreeBuilder extends DefaultHandler {
}
/**
+ * 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.
+ * @return true if no context information should be stored on each node in the FO tree.
+ */
+ protected boolean isLocatorDisabled() {
+ //TODO make this configurable through the FOUserAgent so people can optimize memory
+ //consumption.
+ return false;
+ }
+
+ /**
* SAX Handler for locator
* @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
*/
@@ -192,6 +204,11 @@ public class FOTreeBuilder extends DefaultHandler {
this.locator = locator;
}
+ /** @return a Locator instance if it is available and not disabled */
+ protected Locator getEffectiveLocator() {
+ return (isLocatorDisabled() ? null : this.locator);
+ }
+
/**
* SAX Handler for characters
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
@@ -200,7 +217,7 @@ public class FOTreeBuilder extends DefaultHandler {
throws FOPException {
if (currentFObj != null) {
currentFObj.addCharacters(data, start, start + length,
- currentPropertyList, locator);
+ currentPropertyList, getEffectiveLocator());
}
}
@@ -270,7 +287,7 @@ public class FOTreeBuilder extends DefaultHandler {
try {
foNode = fobjMaker.make(currentFObj);
propertyList = foNode.createPropertyList(currentPropertyList, foEventHandler);
- foNode.processNode(localName, locator, attlist, propertyList);
+ foNode.processNode(localName, getEffectiveLocator(), attlist, propertyList);
foNode.startOfNode();
} catch (IllegalArgumentException e) {
throw new SAXException(e);
diff --git a/src/java/org/apache/fop/fo/expr/PropertyException.java b/src/java/org/apache/fop/fo/expr/PropertyException.java
index 9ce3224b8..696412c88 100644
--- a/src/java/org/apache/fop/fo/expr/PropertyException.java
+++ b/src/java/org/apache/fop/fo/expr/PropertyException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,18 +35,23 @@ public class PropertyException extends FOPException {
}
/**
+ * Sets the property context information.
+ * @param propInfo the property info instance
*/
public void setPropertyInfo(PropertyInfo propInfo) {
- setLocator(propInfo.getFO().locator);
+ setLocator(propInfo.getFO().getLocator());
propertyName = propInfo.getPropertyMaker().getName();
}
/**
+ * Sets the name of the property.
+ * @param propertyName the property name
*/
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
+ /** @see java.lang.Throwable#getMessage()*/
public String getMessage() {
if (propertyName != null) {
return super.getMessage() + "; property:'" + propertyName + "'";
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
index 76b9ffd96..a98f3a0ff 100644
--- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
+++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
@@ -143,7 +143,7 @@ public class LayoutMasterSet extends FObj {
throw new ValidationException("'master-name' ("
+ masterName
+ ") must be unique "
- + "across page-masters and page-sequence-masters", sPM.locator);
+ + "across page-masters and page-sequence-masters", sPM.getLocator());
}
this.simplePageMasters.put(masterName, sPM);
}
@@ -183,7 +183,7 @@ public class LayoutMasterSet extends FObj {
throw new ValidationException("'master-name' ("
+ masterName
+ ") must be unique "
- + "across page-masters and page-sequence-masters", pSM.locator);
+ + "across page-masters and page-sequence-masters", pSM.getLocator());
}
this.pageSequenceMasters.put(masterName, pSM);
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index e06eeb278..1066b67e1 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -219,7 +219,7 @@ public class PageSequence extends FObj {
if (hasFlowName(flowName)) {
throw new ValidationException("duplicate flow-name \""
+ flowName
- + "\" found within fo:page-sequence", flow.locator);
+ + "\" found within fo:page-sequence", flow.getLocator());
}
if (!root.getLayoutMasterSet().regionNameExists(flowName)
@@ -228,7 +228,7 @@ public class PageSequence extends FObj {
throw new ValidationException("flow-name \""
+ flowName
+ "\" could not be mapped to a region-name in the"
- + " layout-master-set", flow.locator);
+ + " layout-master-set", flow.getLocator());
}
}
diff --git a/src/java/org/apache/fop/fo/properties/PropertyMaker.java b/src/java/org/apache/fop/fo/properties/PropertyMaker.java
index cd36323ab..40e9b7b98 100644
--- a/src/java/org/apache/fop/fo/properties/PropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/PropertyMaker.java
@@ -431,7 +431,7 @@ public class PropertyMaker implements Cloneable {
}
return newProp;
} catch (PropertyException propEx) {
- propEx.setLocator(fo.locator);
+ propEx.setLocator(fo.getLocator());
propEx.setPropertyName(getName());
throw propEx;
}