aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-09-24 09:17:12 +0000
committerKeiron Liddle <keiron@apache.org>2001-09-24 09:17:12 +0000
commit3cf392b13f6cab2cf343a86c8e55942656cc9bb5 (patch)
tree61f07612c59f71a3728772876ce11dddfba6f812 /src/org/apache/fop/fo
parent5a9662ed5c350df04d0089c0b9fbba5354b4c772 (diff)
downloadxmlgraphics-fop-3cf392b13f6cab2cf343a86c8e55942656cc9bb5.tar.gz
xmlgraphics-fop-3cf392b13f6cab2cf343a86c8e55942656cc9bb5.zip
updated to use HashMap so that when using threads reading data
is not synchronized and therefore slower git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194480 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo')
-rw-r--r--src/org/apache/fop/fo/DirectPropertyListBuilder.java2
-rw-r--r--src/org/apache/fop/fo/FOTreeBuilder.java25
-rw-r--r--src/org/apache/fop/fo/PropertyListBuilder.java36
-rw-r--r--src/org/apache/fop/fo/StandardElementMapping.java155
-rw-r--r--src/org/apache/fop/fo/TreeBuilder.java9
5 files changed, 116 insertions, 111 deletions
diff --git a/src/org/apache/fop/fo/DirectPropertyListBuilder.java b/src/org/apache/fop/fo/DirectPropertyListBuilder.java
index 7c6b6f6e4..d4f3fa02e 100644
--- a/src/org/apache/fop/fo/DirectPropertyListBuilder.java
+++ b/src/org/apache/fop/fo/DirectPropertyListBuilder.java
@@ -28,7 +28,7 @@ public class DirectPropertyListBuilder extends PropertyListBuilder {
public DirectPropertyListBuilder() {
}
- public PropertyList makeList(String elementName, Attributes attributes,
+ public PropertyList makeList(String uri, String elementName, Attributes attributes,
PropertyList parentPropertyList,
FObj parentFO) throws FOPException {
AttrPropertyList ret = new AttrPropertyList(attributes);
diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java
index ae67d2d91..6b7417e61 100644
--- a/src/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/org/apache/fop/fo/FOTreeBuilder.java
@@ -25,7 +25,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.Attributes;
// Java
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Stack;
import java.util.Vector;
import java.io.IOException;
@@ -47,14 +47,14 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* table mapping element names to the makers of objects
* representing formatting objects
*/
- protected Hashtable fobjTable = new Hashtable();
+ protected HashMap fobjTable = new HashMap();
protected Vector namespaces = new Vector();
/**
* class that builds a property list for each formatting object
*/
- protected Hashtable propertylistTable = new Hashtable();
+ protected HashMap propertylistTable = new HashMap();
/**
* current formatting object being handled
@@ -71,7 +71,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
/**
* set of names of formatting objects encountered but unknown
*/
- protected Hashtable unknownFOs = new Hashtable();
+ protected HashMap unknownFOs = new HashMap();
/**
*
@@ -99,9 +99,8 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addMapping(String namespaceURI, String localName,
- FObj.Maker maker) {
- this.fobjTable.put(namespaceURI + "^" + localName, maker);
+ public void addMapping(String namespaceURI, HashMap table) {
+ this.fobjTable.put(namespaceURI, table);
this.namespaces.addElement(namespaceURI.intern());
}
@@ -112,7 +111,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addPropertyList(String namespaceURI, Hashtable list) {
+ public void addPropertyList(String namespaceURI, HashMap list) {
PropertyListBuilder plb;
plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
if (plb == null) {
@@ -132,7 +131,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
* @param maker Maker for class representing formatting object
*/
public void addElementPropertyList(String namespaceURI, String localName,
- Hashtable list) {
+ HashMap list) {
PropertyListBuilder plb;
plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
if (plb == null) {
@@ -214,13 +213,15 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
FObj.Maker fobjMaker;
// String fullName = mapName(rawName);
- String fullName = uri + "^" + localName;
- fobjMaker = (FObj.Maker)fobjTable.get(fullName);
+ //String fullName = uri + "^" + localName;
+ HashMap table = (HashMap)fobjTable.get(uri);
+ fobjMaker = (FObj.Maker)table.get(localName);
PropertyListBuilder currentListBuilder =
(PropertyListBuilder)this.propertylistTable.get(uri);
boolean foreignXML = false;
if (fobjMaker == null) {
+ String fullName = uri + "^" + localName;
if (!this.unknownFOs.containsKey(fullName)) {
this.unknownFOs.put(fullName, "");
log.error("Unknown formatting object "
@@ -239,7 +240,7 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
PropertyList list = null;
if (currentListBuilder != null) {
list =
- currentListBuilder.makeList(fullName, attlist,
+ currentListBuilder.makeList(uri, localName, attlist,
(currentFObj == null) ? null
: currentFObj.properties, currentFObj);
} else if(foreignXML) {
diff --git a/src/org/apache/fop/fo/PropertyListBuilder.java b/src/org/apache/fop/fo/PropertyListBuilder.java
index f2bf0522c..19db4e7fd 100644
--- a/src/org/apache/fop/fo/PropertyListBuilder.java
+++ b/src/org/apache/fop/fo/PropertyListBuilder.java
@@ -16,7 +16,7 @@ import org.apache.fop.apps.FOPException;
import org.xml.sax.Attributes;
-import java.util.Hashtable;
+import java.util.HashMap;
public class PropertyListBuilder {
@@ -25,19 +25,19 @@ public class PropertyListBuilder {
*/
private static final String FONTSIZEATTR = "font-size";
- private Hashtable propertyListTable;
- private Hashtable elementTable;
+ private HashMap propertyListTable;
+ private HashMap elementTable;
public PropertyListBuilder() {
- this.propertyListTable = new Hashtable();
- this.elementTable = new Hashtable();
+ this.propertyListTable = new HashMap();
+ this.elementTable = new HashMap();
}
- public void addList(Hashtable list) {
- propertyListTable = list; // should add all
+ public void addList(HashMap list) {
+ propertyListTable.putAll(list);
}
- public void addElementList(String element, Hashtable list) {
+ public void addElementList(String element, HashMap list) {
elementTable.put(element, list);
}
@@ -78,13 +78,12 @@ public class PropertyListBuilder {
return b;
}
- public PropertyList makeList(String elementName, Attributes attributes,
+ public PropertyList makeList(String ns, String elementName, Attributes attributes,
PropertyList parentPropertyList,
FObj parentFO) throws FOPException {
- int index = elementName.indexOf("^");
String space = "http://www.w3.org/TR/1999/XSL/Format";
- if (index != -1) {
- space = elementName.substring(0, index);
+ if (ns != null) {
+ space = ns;
}
PropertyList par = null;
@@ -92,12 +91,11 @@ public class PropertyListBuilder {
&& space.equals(parentPropertyList.getNameSpace())) {
par = parentPropertyList;
}
- // System.out.println(elementName.substring(index + 1));
PropertyList p = new PropertyList(par, space,
- elementName.substring(index + 1));
+ elementName);
p.setBuilder(this);
- Hashtable table;
- table = (Hashtable)elementTable.get(elementName.substring(index + 1));
+ HashMap table;
+ table = (HashMap)elementTable.get(elementName);
/* Store names of properties already set. */
StringBuffer propsDone = new StringBuffer(256);
@@ -235,19 +233,19 @@ public class PropertyListBuilder {
protected Property.Maker findMaker(String space, String elementName,
String propertyName) {
- return findMaker((Hashtable)elementTable.get(elementName),
+ return findMaker((HashMap)elementTable.get(elementName),
propertyName);
}
/**
* Convenience function to return the Maker for a given property
- * given the Hashtable containing properties specific to this element.
+ * given the HashMap containing properties specific to this element.
* If table is non-null and
* @param elemTable Element-specific properties or null if none.
* @param propertyName Name of property.
* @return A Maker for this property.
*/
- private Property.Maker findMaker(Hashtable elemTable,
+ private Property.Maker findMaker(HashMap elemTable,
String propertyName) {
Property.Maker propertyMaker = null;
if (elemTable != null) {
diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java
index 132963ca1..5938bf0fd 100644
--- a/src/org/apache/fop/fo/StandardElementMapping.java
+++ b/src/org/apache/fop/fo/StandardElementMapping.java
@@ -8,107 +8,114 @@
package org.apache.fop.fo;
import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Iterator;
import org.apache.fop.fo.properties.FOPropertyMapping;
import org.apache.fop.fo.flow.*;
import org.apache.fop.fo.pagination.*;
public class StandardElementMapping implements ElementMapping {
+ private static HashMap foObjs = null;
- public void addToBuilder(TreeBuilder builder) {
+ public synchronized void addToBuilder(TreeBuilder builder) {
- String uri = "http://www.w3.org/1999/XSL/Format";
+ if(foObjs == null) {
+ foObjs = new HashMap();
- // Declarations and Pagination and Layout Formatting Objects
- builder.addMapping(uri, "root", Root.maker());
- builder.addMapping(uri, "declarations", Declarations.maker());
- builder.addMapping(uri, "color-profile", ColorProfile.maker());
- builder.addMapping(uri, "page-sequence", PageSequence.maker());
- builder.addMapping(uri, "layout-master-set", LayoutMasterSet.maker());
- builder.addMapping(uri, "page-sequence-master",
+ // Declarations and Pagination and Layout Formatting Objects
+ foObjs.put("root", Root.maker());
+ foObjs.put("declarations", Declarations.maker());
+ foObjs.put("color-profile", ColorProfile.maker());
+ foObjs.put("page-sequence", PageSequence.maker());
+ foObjs.put("layout-master-set", LayoutMasterSet.maker());
+ foObjs.put("page-sequence-master",
PageSequenceMaster.maker());
- builder.addMapping(uri, "single-page-master-reference",
+ foObjs.put("single-page-master-reference",
SinglePageMasterReference.maker());
- builder.addMapping(uri, "repeatable-page-master-reference",
+ foObjs.put("repeatable-page-master-reference",
RepeatablePageMasterReference.maker());
- builder.addMapping(uri, "repeatable-page-master-alternatives",
+ foObjs.put("repeatable-page-master-alternatives",
RepeatablePageMasterAlternatives.maker());
- builder.addMapping(uri, "conditional-page-master-reference",
+ foObjs.put("conditional-page-master-reference",
ConditionalPageMasterReference.maker());
- builder.addMapping(uri, "simple-page-master",
+ foObjs.put("simple-page-master",
SimplePageMaster.maker());
- builder.addMapping(uri, "region-body", RegionBody.maker());
- builder.addMapping(uri, "region-before", RegionBefore.maker());
- builder.addMapping(uri, "region-after", RegionAfter.maker());
- builder.addMapping(uri, "region-start", RegionStart.maker());
- builder.addMapping(uri, "region-end", RegionEnd.maker());
- builder.addMapping(uri, "flow", Flow.maker());
- builder.addMapping(uri, "static-content", StaticContent.maker());
- builder.addMapping(uri, "title", Title.maker());
-
- // Block-level Formatting Objects
- builder.addMapping(uri, "block", Block.maker());
- builder.addMapping(uri, "block-container", BlockContainer.maker());
-
- // Inline-level Formatting Objects
- builder.addMapping(uri, "bidi-override", BidiOverride.maker());
- builder.addMapping(uri, "character",
+ foObjs.put("region-body", RegionBody.maker());
+ foObjs.put("region-before", RegionBefore.maker());
+ foObjs.put("region-after", RegionAfter.maker());
+ foObjs.put("region-start", RegionStart.maker());
+ foObjs.put("region-end", RegionEnd.maker());
+ foObjs.put("flow", Flow.maker());
+ foObjs.put("static-content", StaticContent.maker());
+ foObjs.put("title", Title.maker());
+
+ // Block-level Formatting Objects
+ foObjs.put("block", Block.maker());
+ foObjs.put("block-container", BlockContainer.maker());
+
+ // Inline-level Formatting Objects
+ foObjs.put("bidi-override", BidiOverride.maker());
+ foObjs.put("character",
org.apache.fop.fo.flow.Character.maker());
- builder.addMapping(uri, "initial-property-set",
+ foObjs.put("initial-property-set",
InitialPropertySet.maker());
- builder.addMapping(uri, "external-graphic", ExternalGraphic.maker());
- builder.addMapping(uri, "instream-foreign-object",
+ foObjs.put("external-graphic", ExternalGraphic.maker());
+ foObjs.put("instream-foreign-object",
InstreamForeignObject.maker());
- builder.addMapping(uri, "inline", Inline.maker());
- builder.addMapping(uri, "inline-container", InlineContainer.maker());
- builder.addMapping(uri, "leader", Leader.maker());
- builder.addMapping(uri, "page-number", PageNumber.maker());
- builder.addMapping(uri, "page-number-citation",
+ foObjs.put("inline", Inline.maker());
+ foObjs.put("inline-container", InlineContainer.maker());
+ foObjs.put("leader", Leader.maker());
+ foObjs.put("page-number", PageNumber.maker());
+ foObjs.put("page-number-citation",
PageNumberCitation.maker());
- // Formatting Objects for Tables
- builder.addMapping(uri, "table-and-caption", TableAndCaption.maker());
- builder.addMapping(uri, "table", Table.maker());
- builder.addMapping(uri, "table-column", TableColumn.maker());
- builder.addMapping(uri, "table-caption", TableCaption.maker());
- builder.addMapping(uri, "table-header", TableHeader.maker());
- builder.addMapping(uri, "table-footer", TableFooter.maker());
- builder.addMapping(uri, "table-body", TableBody.maker());
- builder.addMapping(uri, "table-row", TableRow.maker());
- builder.addMapping(uri, "table-cell", TableCell.maker());
-
- // Formatting Objects for Lists
- builder.addMapping(uri, "list-block", ListBlock.maker());
- builder.addMapping(uri, "list-item", ListItem.maker());
- builder.addMapping(uri, "list-item-body", ListItemBody.maker());
- builder.addMapping(uri, "list-item-label", ListItemLabel.maker());
-
- // Dynamic Effects: Link and Multi Formatting Objects
- builder.addMapping(uri, "basic-link", BasicLink.maker());
- builder.addMapping(uri, "multi-switch", MultiSwitch.maker());
- builder.addMapping(uri, "multi-case", MultiCase.maker());
- builder.addMapping(uri, "multi-toggle", MultiToggle.maker());
- builder.addMapping(uri, "multi-properties", MultiProperties.maker());
- builder.addMapping(uri, "multi-property-set",
+ // Formatting Objects for Tables
+ foObjs.put("table-and-caption", TableAndCaption.maker());
+ foObjs.put("table", Table.maker());
+ foObjs.put("table-column", TableColumn.maker());
+ foObjs.put("table-caption", TableCaption.maker());
+ foObjs.put("table-header", TableHeader.maker());
+ foObjs.put("table-footer", TableFooter.maker());
+ foObjs.put("table-body", TableBody.maker());
+ foObjs.put("table-row", TableRow.maker());
+ foObjs.put("table-cell", TableCell.maker());
+
+ // Formatting Objects for Lists
+ foObjs.put("list-block", ListBlock.maker());
+ foObjs.put("list-item", ListItem.maker());
+ foObjs.put("list-item-body", ListItemBody.maker());
+ foObjs.put("list-item-label", ListItemLabel.maker());
+
+ // Dynamic Effects: Link and Multi Formatting Objects
+ foObjs.put("basic-link", BasicLink.maker());
+ foObjs.put("multi-switch", MultiSwitch.maker());
+ foObjs.put("multi-case", MultiCase.maker());
+ foObjs.put("multi-toggle", MultiToggle.maker());
+ foObjs.put("multi-properties", MultiProperties.maker());
+ foObjs.put("multi-property-set",
MultiPropertySet.maker());
- // Out-of-Line Formatting Objects
- builder.addMapping(uri, "float",
+ // Out-of-Line Formatting Objects
+ foObjs.put("float",
org.apache.fop.fo.flow.Float.maker());
- builder.addMapping(uri, "footnote", Footnote.maker());
- builder.addMapping(uri, "footnote-body", FootnoteBody.maker());
+ foObjs.put("footnote", Footnote.maker());
+ foObjs.put("footnote-body", FootnoteBody.maker());
+
+ // Other Formatting Objects
+ foObjs.put("wrapper", Wrapper.maker());
+ foObjs.put("marker", Marker.maker());
+ foObjs.put("retrieve-marker", RetrieveMarker.maker());
+ }
- // Other Formatting Objects
- builder.addMapping(uri, "wrapper", Wrapper.maker());
- builder.addMapping(uri, "marker", Marker.maker());
- builder.addMapping(uri, "retrieve-marker", RetrieveMarker.maker());
+ String uri = "http://www.w3.org/1999/XSL/Format";
+ builder.addMapping(uri, foObjs);
builder.addPropertyList(uri, FOPropertyMapping.getGenericMappings());
/* Add any element mappings */
- for (Enumeration e = FOPropertyMapping.getElementMappings();
- e.hasMoreElements(); ) {
- String elem = (String)e.nextElement();
+ for (Iterator iter = FOPropertyMapping.getElementMappings().iterator();
+ iter.hasNext(); ) {
+ String elem = (String)iter.next();
builder.addElementPropertyList(uri, elem,
FOPropertyMapping.getElementMapping(elem));
}
diff --git a/src/org/apache/fop/fo/TreeBuilder.java b/src/org/apache/fop/fo/TreeBuilder.java
index 5342dd54c..3076a2d6c 100644
--- a/src/org/apache/fop/fo/TreeBuilder.java
+++ b/src/org/apache/fop/fo/TreeBuilder.java
@@ -8,7 +8,7 @@
package org.apache.fop.fo;
// Java
-import java.util.Hashtable;
+import java.util.HashMap;
/**
*/
@@ -22,8 +22,7 @@ public interface TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addMapping(String namespaceURI, String localName,
- FObj.Maker maker);
+ public void addMapping(String namespaceURI, HashMap table);
/**
* add a mapping from element name to maker.
@@ -32,7 +31,7 @@ public interface TreeBuilder {
* @param localName local name of formatting object element
* @param maker Maker for class representing formatting object
*/
- public void addPropertyList(String namespaceURI, Hashtable list);
+ public void addPropertyList(String namespaceURI, HashMap list);
public void addPropertyListBuilder(String namespaceURI, PropertyListBuilder list);
@@ -44,6 +43,6 @@ public interface TreeBuilder {
* @param maker Maker for class representing formatting object
*/
public void addElementPropertyList(String namespaceURI, String localName,
- Hashtable list);
+ HashMap list);
}