From: Peter Bernard West Date: Thu, 4 Jul 2002 02:34:37 +0000 (+0000) Subject: Removed handling of MappedEnumType. Removed initialValueMethods array and its usage... X-Git-Tag: Alt-Design_pre_Properties_split~170 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9797eef842ab16751479b48db23a09f06db988eb;p=xmlgraphics-fop.git Removed handling of MappedEnumType. Removed initialValueMethods array and its usage. Initial values now derived on demand by invoking the getInitialValue method of each property through the property Class objects. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@194956 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/PropertyConsts.java b/src/org/apache/fop/fo/PropertyConsts.java index 612b0f453..f7ce7c970 100644 --- a/src/org/apache/fop/fo/PropertyConsts.java +++ b/src/org/apache/fop/fo/PropertyConsts.java @@ -118,6 +118,33 @@ public class PropertyConsts { return initialValueTypes[propertyIndex]; } + /** + * @param property int index of the property + * @return PropertyValue from property's getInitialValue + * method + * @exception PropertyException + */ + public static PropertyValue getInitialValue(int property) + throws PropertyException + { + Method method = null; + try { + method = classes[property].getMethod + ("getInitialValue", new Class[] {int.class}); + return (PropertyValue) + (method.invoke + (null, new Object[] {Ints.consts.get(property)})); + } catch (NoSuchMethodException nsme) { + throw new PropertyException + ("No getInitialValue method in " + + classes[property].getName() + ": " + nsme.getMessage()); + } 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 @@ -273,35 +300,6 @@ public class PropertyConsts { return ((ROStringArray)enums).get(enumIndex); } - /** - * @param property int property index. - * @param enumIndex int containing the enumeration index. - * @return String containing the mapped enumeration value. - * @exception PropertyException - */ - public static String getMappedEnumValue(int property, int enumIndex) - throws PropertyException - { - // Get the object represented by the enumMappings field in the - // property class - Object values; - try { - values = - classes[property].getField("enumMappings").get(null); - } - catch (NoSuchFieldException e) { - throw new PropertyException( - "Missing field \"" + e.getMessage() + "\"" - + " in class " + classNames[property]); - } - catch (IllegalAccessException e) { - throw new PropertyException( - "Illegal access on \"" + e.getMessage() + "\" in class " + - classNames[property]); - } - return enumIndexToMapping(enumIndex, (ROStringArray)values); - } - /** * A String[] array of the property class names. This array is * effectively 1-based, with the first element being unused. @@ -347,12 +345,6 @@ public class PropertyConsts { */ private static final HashMap toIndex; - /** - * An unmodifiable Map of property name to property index. It is derived - * from the HashMap toIndex, above. - */ - //public static final Map propertyToIndex; - /** * A HashMap whose elements are an integer index value keyed by the name * of a property class. the index value is the index of the property @@ -361,12 +353,6 @@ public class PropertyConsts { */ private static final HashMap classToIndex; - /** - * An unmodifiable Map of property class name to property index. It is - * derived from the HashMap classToIndex, above. - */ - //public static final Map propertyClassToIndex; - /**

* An int[] array of values specifying the type of inheritance of a * property. The array is indexed by the index value constants that are @@ -456,22 +442,18 @@ public class PropertyConsts { public static final List complexMethods; /** - * A sparsely populated array of Method objects. Although this - * array has a slot for every property, only positions corresponding to - * properties which have a setInitialValue() method for creating - * initial property value objects, will hold a valid - * Method object. + * A HashMap of Method objects. It contains the + * getMappedNumMap methods from properties which support a + * MAPPED_NUMERIC datatype. The map is indexed by the + * integer index of the property. */ - private static final Method[] initialvaluemethods; + private static final HashMap mappednummethods; /** - * An unmodifiable List of the property setInitialValue methods. - * This random access list is derived from initialvaluemethods, - * above. - * It can be indexed by the property name constants defined in - * the PropNames class. + * An unmodifiable map of the property getMappedNumMap methods. + * It is derived from the mappednummethods map, above. */ - public static final List initialValueMethods; + public static final Map mappedNumMethods; static { String prefix = packageName + "." + "Properties" + "$"; @@ -487,7 +469,7 @@ public class PropertyConsts { datatypes = new int[PropNames.LAST_PROPERTY_INDEX + 1]; classes = new Class[PropNames.LAST_PROPERTY_INDEX + 1]; complexmethods = new Method[PropNames.LAST_PROPERTY_INDEX + 1]; - initialvaluemethods = new Method[PropNames.LAST_PROPERTY_INDEX + 1]; + mappednummethods = new HashMap(); for (int i = 0; i <= PropNames.LAST_PROPERTY_INDEX; i++) { cname = ""; @@ -558,15 +540,12 @@ public class PropertyConsts { complexmethods[i] = classes[i].getMethod ("complex", new Class[] - {int.class, + {org.apache.fop.fo.FOTree.class, PropertyValue.class}); - if ((initialValueTypes[i] & Properties.USE_SET_FUNCTION_IT) - != 0) - initialvaluemethods[i] = - classes[i].getMethod - ("getInitialValue", - new Class[] - {org.apache.fop.fo.FOTree.class}); + if ((datatypes[i] & Properties.MAPPED_NUMERIC) != 0) + mappednummethods.put(Ints.consts.get(i), + classes[i].getMethod + ("getMappedNumArray", new Class[] {})); } catch (NoSuchFieldException e) { throw new RuntimeException( @@ -594,8 +573,7 @@ public class PropertyConsts { dataTypes = new ROIntArray(datatypes); complexMethods = Collections.unmodifiableList (Arrays.asList(complexmethods)); - initialValueMethods = Collections.unmodifiableList - (Arrays.asList(initialvaluemethods)); + mappedNumMethods = Collections.unmodifiableMap(mappednummethods); }