diff options
author | Glen Mazza <gmazza@apache.org> | 2004-07-16 05:10:32 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-07-16 05:10:32 +0000 |
commit | 4cd2247565deba8992baa983ba5622620fa6bb5e (patch) | |
tree | f532f1b3f662df43ac7674d5857dbfc83f6cd194 /src/java/org/apache/fop/fo/FOTreeBuilder.java | |
parent | 03a30e10172c62743876bc3bb6546c8e0a0ca4d2 (diff) | |
download | xmlgraphics-fop-4cd2247565deba8992baa983ba5622620fa6bb5e.tar.gz xmlgraphics-fop-4cd2247565deba8992baa983ba5622620fa6bb5e.zip |
Moved user-defined ElementMapping initialization from Driver to FOUserAgent.
Moved only "string" method, the version we use internally--probably sufficient
for others' work as well. (Note: an additional unused FOUserAgent object will
be created in driver during command-line use--cp. its no-param constructor vs.
setUserAgent() call in apps.Fop; this will need to be ironed out at some time.)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197794 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/FOTreeBuilder.java')
-rw-r--r-- | src/java/org/apache/fop/fo/FOTreeBuilder.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 0516016a4..c9f566c18 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.Reader; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -88,17 +89,12 @@ public class FOTreeBuilder extends DefaultHandler { private Locator locator; /** - * Default constructor + * FOTreeBuilder constructor + * @param render type as defined in Constants class + * @param foUserAgent in effect for this process + * @param stream OutputStream to direct results */ - public FOTreeBuilder() { - setupDefaultMappings(); - } - - /** - * Creates the FOInputHandler object based on passed-in render type - * @param render type - */ - public void initialize(int renderType, FOUserAgent foUserAgent, + public FOTreeBuilder(int renderType, FOUserAgent foUserAgent, OutputStream stream) throws FOPException { if (renderType == Constants.RENDER_MIF) { foInputHandler = new MIFHandler(foUserAgent, stream); @@ -113,6 +109,18 @@ public class FOTreeBuilder extends DefaultHandler { foInputHandler = new AreaTreeHandler(foUserAgent, renderType, stream); } + + // Add standard element mappings + setupDefaultMappings(); + + // add additional ElementMappings defined within FOUserAgent + ArrayList addlEMs = foUserAgent.getAdditionalElementMappings(); + + if (addlEMs != null) { + for (int i = 0; i < addlEMs.size(); i++) { + addElementMapping((String) addlEMs.get(i)); + } + } } /** @@ -142,23 +150,13 @@ public class FOTreeBuilder extends DefaultHandler { } /** - * Add the given element mapping. - * An element mapping maps element names to Java classes. - * - * @param mapping the element mappingto add - */ - public void addElementMapping(ElementMapping mapping) { - this.fobjTable.put(mapping.getNamespaceURI(), mapping.getTable()); - this.namespaces.add(mapping.getNamespaceURI().intern()); - } - - /** * Add the element mapping with the given class name. * @param mappingClassName the class name representing the element mapping. * @throws IllegalArgumentException if there was not such element mapping. */ public void addElementMapping(String mappingClassName) throws IllegalArgumentException { + try { ElementMapping mapping = (ElementMapping)Class.forName(mappingClassName).newInstance(); @@ -178,6 +176,11 @@ public class FOTreeBuilder extends DefaultHandler { } } + private void addElementMapping(ElementMapping mapping) { + this.fobjTable.put(mapping.getNamespaceURI(), mapping.getTable()); + this.namespaces.add(mapping.getNamespaceURI().intern()); + } + /** * SAX Handler for locator * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator) |