From: Glen Mazza Date: Fri, 26 Dec 2003 23:41:47 +0000 (+0000) Subject: Property.getPropertyName() switched from returning strings to X-Git-Tag: Root_Temp_KnuthStylePageBreaking~963 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4425dafeb0d69048a21d26c3b2ac9ccbf3a87942;p=xmlgraphics-fop.git Property.getPropertyName() switched from returning strings to integer constants (perh. should be renamed to getPropertyId()?); change propagated to classes calling this function. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197056 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java b/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java index ed44aeba5..97717ca06 100644 --- a/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java +++ b/src/java/org/apache/fop/datatypes/ToBeImplementedProperty.java @@ -67,6 +67,7 @@ public class ToBeImplementedProperty extends Property { if (p instanceof ToBeImplementedProperty) { return p; } + ToBeImplementedProperty val = new ToBeImplementedProperty(getPropName()); return val; @@ -77,7 +78,7 @@ public class ToBeImplementedProperty extends Property { * Constructor * @param propName name of Property */ - public ToBeImplementedProperty(String propName) { + public ToBeImplementedProperty(int propId) { //XXX: (mjg@recalldesign.com) This is a bit of a kluge, perhaps an //UnimplementedPropertyException or something similar should diff --git a/src/java/org/apache/fop/fo/BoxPropShorthandParser.java b/src/java/org/apache/fop/fo/BoxPropShorthandParser.java index 066ea472b..1b47bb5a8 100644 --- a/src/java/org/apache/fop/fo/BoxPropShorthandParser.java +++ b/src/java/org/apache/fop/fo/BoxPropShorthandParser.java @@ -49,6 +49,7 @@ * Software Foundation, please see . */ package org.apache.fop.fo; +import org.apache.fop.fo.properties.FOPropertyMapping; /** * Shorthand property parser for Box properties @@ -69,17 +70,18 @@ public class BoxPropShorthandParser extends GenericShorthandParser { * @see org.apache.fop.fo.GenericShorthandParser#convertValueForProperty(String, * Property.Maker, PropertyList) */ - protected Property convertValueForProperty(String propName, + protected Property convertValueForProperty(int propId, Property.Maker maker, PropertyList propertyList) { + String name = FOPropertyMapping.getPropertyName(propId); Property p = null; - if (propName.indexOf("-top") >= 0) { + if (name.indexOf("-top") >= 0) { p = getElement(0); - } else if (propName.indexOf("-right") >= 0) { + } else if (name.indexOf("-right") >= 0) { p = getElement(count() > 1 ? 1 : 0); - } else if (propName.indexOf("-bottom") >= 0) { + } else if (name.indexOf("-bottom") >= 0) { p = getElement(count() > 2 ? 2 : 0); - } else if (propName.indexOf("-left") >= 0) { + } else if (name.indexOf("-left") >= 0) { p = getElement(count() > 3 ? 3 : (count() > 1 ? 1 : 0)); } // if p not null, try to convert it to a value of the correct type diff --git a/src/java/org/apache/fop/fo/GenericShorthandParser.java b/src/java/org/apache/fop/fo/GenericShorthandParser.java index 62df79f91..c00fc984c 100644 --- a/src/java/org/apache/fop/fo/GenericShorthandParser.java +++ b/src/java/org/apache/fop/fo/GenericShorthandParser.java @@ -52,6 +52,7 @@ package org.apache.fop.fo; import java.util.Vector; import java.util.Enumeration; +import org.apache.fop.fo.properties.FOPropertyMapping; public class GenericShorthandParser implements ShorthandParser { @@ -72,7 +73,7 @@ public class GenericShorthandParser implements ShorthandParser { */ protected Property getElement(int index) { if (list.size() > index) { - return (Property)list.elementAt(index); + return (Property) list.elementAt(index); } else { return null; } @@ -87,7 +88,7 @@ public class GenericShorthandParser implements ShorthandParser { // Stores 1 to 3 values for border width, style, color // Used for: border, border-top, border-right etc - public Property getValueForProperty(String propName, + public Property getValueForProperty(int propId, Property.Maker maker, PropertyList propertyList) { Property prop = null; @@ -95,29 +96,30 @@ public class GenericShorthandParser implements ShorthandParser { if (count() == 1) { String sval = ((Property)list.elementAt(0)).getString(); if (sval != null && sval.equals("inherit")) { - return propertyList.getFromParent(propName); + String name = FOPropertyMapping.getPropertyName(propId); + return propertyList.getFromParent(name); } } - return convertValueForProperty(propName, maker, propertyList); + return convertValueForProperty(propId, maker, propertyList); } /** * Converts a property name into a Property - * @param propName the String containing the property name + * @param propId the property ID in the Constants interface * @param maker the Property.Maker to be used in the conversion * @param propertyList the PropertyList from which the Property should be * extracted * @return the Property matching the parameters, or null if not found */ - protected Property convertValueForProperty(String propName, + protected Property convertValueForProperty(int propId, Property.Maker maker, PropertyList propertyList) { Property prop = null; // Try each of the stored values in turn Enumeration eprop = list.elements(); while (eprop.hasMoreElements() && prop == null) { - Property p = (Property)eprop.nextElement(); + Property p = (Property) eprop.nextElement(); prop = maker.convertShorthandProperty(propertyList, p, null); } return prop; diff --git a/src/java/org/apache/fop/fo/Property.java b/src/java/org/apache/fop/fo/Property.java index 592d28863..804a4b890 100644 --- a/src/java/org/apache/fop/fo/Property.java +++ b/src/java/org/apache/fop/fo/Property.java @@ -81,8 +81,8 @@ public class Property { /** * @return the name of the property for this Maker */ - protected String getPropName() { - return FOPropertyMapping.getPropertyName(this.propId); + protected int getPropName() { + return propId; } /** diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index 558ed70eb..2344aeea0 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.java @@ -718,7 +718,7 @@ public class PropertyList extends HashMap { * @param propertyName name of property * @return the Property.Maker for this property */ - protected Property.Maker findMaker(String space, String elementName, + private Property.Maker findMaker(String space, String elementName, String propertyName) { // convert the string (e.g., "font-size") to its const value (PR_FONT_SIZE). diff --git a/src/java/org/apache/fop/fo/ShorthandParser.java b/src/java/org/apache/fop/fo/ShorthandParser.java index e82f52b0f..98ee82eaf 100644 --- a/src/java/org/apache/fop/fo/ShorthandParser.java +++ b/src/java/org/apache/fop/fo/ShorthandParser.java @@ -57,12 +57,12 @@ package org.apache.fop.fo; public interface ShorthandParser { /** - * @param propName name of the Property + * @param propId the property ID in the Constants interface * @param maker Maker object for the Property * @param propertyList list of properties * @return Property object corresponding to propName */ - Property getValueForProperty(String propName, + Property getValueForProperty(int propId, Property.Maker maker, PropertyList propertyList); }