]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Refactor: extract method convertAttributeToProperty() from makeList()
authorWilliam Victor Mote <vmote@apache.org>
Thu, 1 May 2003 05:39:03 +0000 (05:39 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Thu, 1 May 2003 05:39:03 +0000 (05:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196382 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/PropertyListBuilder.java

index 2c49f2e6ecd2ef4a1a8d7d2b763442f5531bc45a..56b2c50756605c8b891a9a671aaa172a2299cbe0 100644 (file)
@@ -146,27 +146,17 @@ public class PropertyListBuilder {
         PropertyList p = new PropertyList(parentProperties, nameSpaceURIToUse,
                                           elementName);
         p.setBuilder(this);
-        HashMap table;
-        table = (HashMap)elementTable.get(elementName);
+        HashMap validProperties;
+        validProperties = (HashMap)elementTable.get(elementName);
 
         /*
          * If font-size is set on this FO, must set it first, since
          * other attributes specified in terms of "ems" depend on it.
-         * When we do "shorthand" properties, must handle the "font"
+         */
+        /** @todo When we do "shorthand" properties, must handle the "font"
          * property as well to see if font-size is set.
          */
-        String fontsizeval = attributes.getValue(FONTSIZEATTR);
-        if (fontsizeval != null) {
-            Property.Maker propertyMaker = findMaker(table, FONTSIZEATTR);
-            if (propertyMaker != null) {
-                try {
-                    p.put(FONTSIZEATTR,
-                          propertyMaker.make(p, fontsizeval, parentFO));
-                } catch (FOPException e) {
-                    /**@todo log this exception */
-                }
-            }
-        }
+        convertAttributeToProperty(attributes, FONTSIZEATTR, validProperties, p, parentFO);
 
         for (int i = 0; i < attributes.getLength(); i++) {
             String attributeName = attributes.getQName(i);
@@ -175,7 +165,7 @@ public class PropertyListBuilder {
             String subPropName = findSubPropertyName(attributeName);
             Property propVal = null;
 
-            Property.Maker propertyMaker = findMaker(table, basePropName);
+            Property.Maker propertyMaker = findMaker(validProperties, basePropName);
 
             if (propertyMaker != null) {
                 try {
@@ -216,6 +206,37 @@ public class PropertyListBuilder {
         return p;
     }
 
+    /**
+     *
+     * @param attributes Collection of attributes
+     * @param attributeName Attribute name to convert
+     * @param validProperties Collection of valid properties
+     * @param propList PropertyList in which to add the newly created Property
+     * @param parentFO Parent FO of the object for which this property is being
+     *     built
+     */
+    private void convertAttributeToProperty(Attributes attributes,
+                                            String attributeName,
+                                            HashMap validProperties,
+                                            PropertyList propList,
+                                            FObj parentFO) {
+        String attributeValue = attributes.getValue(attributeName);
+        if (attributeValue == null) {
+            return;
+        }
+        Property.Maker propertyMaker = findMaker(validProperties, attributeName);
+        if (propertyMaker == null) {
+            return;
+        }
+        try {
+            propList.put(attributeName,
+                propertyMaker.make(propList, attributeValue, parentFO));
+        }
+        catch (FOPException e) {
+            /**@todo log this exception */
+        }
+    }
+
     /**
      * Finds the first or base part (up to any period) of an attribute name.
      * For example, if input is "space-before.minimum", should return