]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Changes to handling of MAPPED_NUMERIC
authorPeter Bernard West <pbwest@apache.org>
Tue, 27 Aug 2002 15:33:04 +0000 (15:33 +0000)
committerPeter Bernard West <pbwest@apache.org>
Tue, 27 Aug 2002 15:33:04 +0000 (15:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195121 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/FOTree.java
src/org/apache/fop/fo/PropertyConsts.java

index d182ae580e30aec56de234a6155be9c10993c49a..1c7d3a012eacede944433a880aad8c525612c45a 100644 (file)
@@ -82,10 +82,21 @@ public class FOTree extends Tree implements Runnable {
     protected LinkedList[] propertyStacks;
 
     /**
-     * A <tt>HashMap</tt> of arrays of <tt>Numeric[]</tt> keyed on the
-     * index of properties which support MAPPED_NUMERIC data types.
+     * An FONode identifier.  This is available to be incremented for
+     * each FONode created.  The only requirement is that active FONodes
+     * have a unique identifier.  An accessor function is defined, but the
+     * responsibility for calling it rests with FONode.
      */
-    private HashMap mappedNumericArrays = new HashMap();
+    private int nodeID = 0;
+
+    /**
+     * Get the next node identifier.  There is no need to synchronize this
+     * as FONodes are created within a single thread.
+     * @return the next node identifier
+     */
+    public int nextNodeID() {
+        return ++nodeID;
+    }
 
     /**
      * @param xmlevents the buffer from which <tt>XMLEvent</tt>s from the
@@ -141,27 +152,6 @@ public class FOTree extends Tree implements Runnable {
             }
         }
 
-        // Initialise the Numeric arrays for properties with
-        // MAPPED_NUMERIC datatypes
-        for (int i = 0; i <= PropNames.LAST_PROPERTY_INDEX; i++ ) {
-            if ((PropertyConsts.dataTypes.get(i)
-                 & Properties.MAPPED_NUMERIC) != 0) {
-                try {
-                    Numeric[] numarray =
-                            (Numeric[])
-                                ((Method) (
-                                    PropertyConsts.mappedNumMethods
-                                      .get(Ints.consts.get(i))
-                                    ))
-                                .invoke(null, null);
-                    mappedNumericArrays.put(Ints.consts.get(i),numarray);
-                } catch (IllegalAccessException e) {
-                    throw new PropertyException(e.getMessage());
-                } catch (InvocationTargetException e) {
-                    throw new PropertyException(e.getMessage());
-                }
-            }
-        }
     }
 
     /**
@@ -195,21 +185,6 @@ public class FOTree extends Tree implements Runnable {
                 (new PropertyTriplet(property, value));
     }
 
-    /**
-     * @param property <tt>int</t> property index
-     * @param enumIndex <tt>int</t> enumerated value index into array
-     *  of mapped <tt>Numeric</tt> values
-     * @return <tt>Numeric</tt> corresponding to the <tt>MAPPED_NUMERIC</tt>
-     *  enumeration token for this property
-     */
-    public Numeric getMappedNumArrayValue(int property, int enumIndex)
-    {
-        return
-            ((Numeric[])
-                (mappedNumericArrays.get(Ints.consts.get(property)))
-             )[enumIndex];
-    }
-
     /**
      * @return a <tt>TextDecorations</tt> object containing the current
      * text decorations
index b165247875b2ecb12781b53d005bb8ebfcd116d3..718757aab160c50499cb877bbca2023770cfe8d7 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.fop.fo.FOTree;
 import org.apache.fop.fo.PropNames;
 import org.apache.fop.fo.Properties;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.datatypes.Numeric;
 import org.apache.fop.datatypes.Ints;
 import org.apache.fop.datastructs.ROIntArray;
 import org.apache.fop.datastructs.ROStringArray;
@@ -145,6 +146,26 @@ public class PropertyConsts {
         }
     }
 
+    public static Numeric getMappedNumeric(int property, int enum)
+        throws PropertyException
+    {
+        Method method;
+        if ((method =
+             (Method)(mappednummethods.get(Ints.consts.get(property))))
+            == null)
+            throw new PropertyException("No mappedLength method in "
+                                             + classes[property].getName());
+        try {
+            return (Numeric)
+                    (method.invoke
+                     (null, new Object[] {Ints.consts.get(enum)}));
+        } catch (IllegalAccessException iae) {
+            throw new PropertyException(iae.getMessage());
+        } catch (InvocationTargetException ite) {
+            throw new PropertyException(ite.getMessage());
+        }
+    }
+
     /**
      * @param property String name of the FO property
      * @return int type of inheritance for this property
@@ -542,10 +563,11 @@ public class PropertyConsts {
                                         ("refineParsing", new Class[]
                                             {org.apache.fop.fo.FOTree.class,
                                                      PropertyValue.class});
-                if ((datatypes[i] & Properties.MAPPED_NUMERIC) != 0)
+                if ((datatypes[i] & Properties.MAPPED_LENGTH) != 0)
                     mappednummethods.put(Ints.consts.get(i),
                                      classes[i].getMethod
-                                     ("getMappedNumArray", new Class[] {}));
+                                     ("getMappedLength", new Class[]
+                                         {Integer.class}));
             }
             catch (NoSuchFieldException e) {
                 throw new RuntimeException(