]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
More String->Int conversions.
authorGlen Mazza <gmazza@apache.org>
Tue, 6 Jan 2004 00:49:40 +0000 (00:49 +0000)
committerGlen Mazza <gmazza@apache.org>
Tue, 6 Jan 2004 00:49:40 +0000 (00:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197143 13f79535-47bb-0310-9956-ffa450edef68

src/codegen/properties.xsl
src/java/org/apache/fop/datatypes/CompoundDatatype.java
src/java/org/apache/fop/datatypes/CondLength.java
src/java/org/apache/fop/datatypes/Keep.java
src/java/org/apache/fop/datatypes/LengthPair.java
src/java/org/apache/fop/datatypes/LengthRange.java
src/java/org/apache/fop/datatypes/Space.java

index d4646237d2e7699919b20c71100257226334da82..2adb422cecce67fd58caa85ca101f831cea6a970 100644 (file)
@@ -566,24 +566,24 @@ public class </xsl:text>
     protected Property setSubprop(Property baseProp, int subpropId,
                                   Property subProp) {
         </xsl:text>
-        String subpropName = FOPropertyMapping.getPropertyName(subpropId);
         <xsl:value-of select="datatype"/>
         <xsl:text> val = baseProp.get</xsl:text>
         <xsl:value-of select="datatype"/>
         <xsl:text>();
         // Do some type checking???
         // Check if one of our subproperties???
-        val.setComponent(subpropName, subProp, false);
+        val.setComponent(subpropId, subProp, false);
         return baseProp;
     }
 
     public Property getSubpropValue(Property baseProp, String subpropName) {
+        int subpropId = org.apache.fop.fo.properties.FOPropertyMapping.getSubPropertyId(subpropName);
         </xsl:text>
         <xsl:value-of select="datatype"/>
         <xsl:text> val = baseProp.get</xsl:text>
         <xsl:value-of select="datatype"/>
         <xsl:text>();
-        return val.getComponent(subpropName);
+        return val.getComponent(subpropId);
     }
 </xsl:text>
       <xsl:choose>
@@ -630,9 +630,11 @@ public class </xsl:text>
         <xsl:text>").make(pList, getDefaultFor</xsl:text>
         <xsl:value-of select='$spname'/>
         <xsl:text>(), fo);
-          p.setComponent("</xsl:text>
-        <xsl:value-of select='.'/>
-        <xsl:text>", subProp, true);</xsl:text>
+       p.setComponent(Constants.CP_</xsl:text>
+        <xsl:call-template name="makeEnumConstant">
+          <xsl:with-param name="propstr" select="."/>
+        </xsl:call-template>
+        <xsl:text>, subProp, true);</xsl:text>
       </xsl:for-each>
       <xsl:text>
         return new </xsl:text>
@@ -695,9 +697,11 @@ public class </xsl:text>
       <xsl:text>();</xsl:text>
       <xsl:for-each select="compound/subproperty[@set-by-shorthand='true']">
         <xsl:text>
-            pval.setComponent("</xsl:text>
-        <xsl:value-of select='name'/>
-        <xsl:text>", p, false);</xsl:text>
+            pval.setComponent(Constants.CP_</xsl:text>
+        <xsl:call-template name="makeEnumConstant">
+          <xsl:with-param name="propstr" select="name"/>
+        </xsl:call-template>
+        <xsl:text>, p, false);</xsl:text>
       </xsl:for-each>
       <xsl:text>
             return prop;
index 13791149790d9f8c832264c1a690aaa57714cd7a..097b966d41b86bd605e539975227e10edaf54b78 100644 (file)
@@ -59,16 +59,16 @@ public interface CompoundDatatype {
     
     /**
      * Sets a component of the compound datatype.
-     * @param sCmpnName name of the component
+     * @param Constants ID of the component
      * @param cmpnValue value of the component
      * @param bIsDefault Indicates if it's the default value
      */
-    void setComponent(String sCmpnName, Property cmpnValue, boolean bIsDefault);
+    void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault);
 
     /**
      * Returns a component of the compound datatype.
-     * @param sCmpnName name of the component
+     * @param Constants ID of the component
      * @return the value of the component
      */
-    Property getComponent(String sCmpnName);
+    Property getComponent(int cmpId);
 }
index 4ae19cdc730f15809660a7b63f613ff8dfbfee49..75c37e6f79be77307c2cd66370b13f8421d36ed3 100644 (file)
@@ -63,24 +63,24 @@ public class CondLength implements CompoundDatatype {
     private Property conditionality;
 
     /**
-     * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(String, Property, boolean)
+     * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
      */
-    public void setComponent(String sCmpnName, Property cmpnValue,
+    public void setComponent(int cmpId, Property cmpnValue,
                              boolean bIsDefault) {
-        if (sCmpnName.equals("length")) {
+        if (cmpId == Constants.CP_LENGTH) {
             length = cmpnValue;
-        } else if (sCmpnName.equals("conditionality")) {
+        } else if (cmpId == Constants.CP_CONDITIONALITY) {
             conditionality = cmpnValue;
         }
     }
 
     /**
-     * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(String)
+     * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int)
      */
-    public Property getComponent(String sCmpnName) {
-        if (sCmpnName.equals("length")) {
+    public Property getComponent(int cmpId) {
+        if (cmpId == Constants.CP_LENGTH) {
             return length;
-        } else if (sCmpnName.equals("conditionality")) {
+        } else if (cmpId == Constants.CP_CONDITIONALITY) {
             return conditionality;
         } else {
             return null;
index 43606c7b9af22f4c7f1c9ec0add681d09b05d9e0..9089c5d46c72092debd3e16a8a9a0794e832f855 100644 (file)
@@ -51,6 +51,7 @@
 package org.apache.fop.datatypes;
 
 import org.apache.fop.fo.Property;
+import org.apache.fop.fo.Constants;
 
 /**
  * XSL FO Keep Property datatype (keep-together, etc)
@@ -68,33 +69,28 @@ public class Keep implements CompoundDatatype {
 
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName name of compound property to set
-     * @param cmpnValue property containing value to be set
-     * @param bIsDefault not used (??)
+     * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
      */
-    public void setComponent(String sCmpnName, Property cmpnValue,
+    public void setComponent(int cmpId, Property cmpnValue,
                              boolean bIsDefault) {
-        if (sCmpnName.equals("within-line")) {
+        if (cmpId == Constants.CP_WITHIN_LINE) {
             setWithinLine(cmpnValue, bIsDefault);
-        } else if (sCmpnName.equals("within-column")) {
+        } else if (cmpId == Constants.CP_WITHIN_COLUMN) {
             setWithinColumn(cmpnValue, bIsDefault);
-        } else if (sCmpnName.equals("within-page")) {
+        } else if (cmpId == Constants.CP_WITHIN_PAGE) {
             setWithinPage(cmpnValue, bIsDefault);
         }
     }
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName compound property name
-     * @return property corresponding to compound property string
+     * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int)
      */
-    public Property getComponent(String sCmpnName) {
-        if (sCmpnName.equals("within-line")) {
+    public Property getComponent(int cmpId) {
+        if (cmpId == Constants.CP_WITHIN_LINE) {
             return getWithinLine();
-        } else if (sCmpnName.equals("within-column")) {
+        } else if (cmpId == Constants.CP_WITHIN_COLUMN) {
             return getWithinColumn();
-        } else if (sCmpnName.equals("within-page")) {
+        } else if (cmpId == Constants.CP_WITHIN_PAGE) {
             return getWithinPage();
         } else {
             return null;
index c16941c72c5cdb93716ec4a477ed0931e4e24652..21863d2a15bc221af590b08daeb9aa8dd05a9478 100644 (file)
@@ -51,6 +51,7 @@
 package org.apache.fop.datatypes;
 
 import org.apache.fop.fo.Property;
+import org.apache.fop.fo.Constants;
 
 /**
  * Models a pair of lengths, one specifiying the dimensions for the
@@ -63,31 +64,24 @@ public class LengthPair implements CompoundDatatype {
     private Property bpd;
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName component name ("block-progression-direction" or
-     * "inline-progression-direction") which is being set
-     * @param cmpnValue Property containing the value to be set
-     * @param bIsDefault true if this is the default property (??)
+     * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
      */
-    public void setComponent(String sCmpnName, Property cmpnValue,
+    public void setComponent(int cmpId, Property cmpnValue,
                              boolean bIsDefault) {
-        if (sCmpnName.equals("block-progression-direction")) {
+        if (cmpId == Constants.CP_BLOCK_PROGRESSION_DIRECTION) {
             bpd = cmpnValue;
-        } else if (sCmpnName.equals("inline-progression-direction")) {
+        } else if (cmpId == Constants.CP_INLINE_PROGRESSION_DIRECTION) {
             ipd = cmpnValue;
         }
     }
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName component name ("block-progression-direction" or
-     * "inline-progression-direction") for which the length is sought
-     * @return Property containing the length sought
+     * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int)
      */
-    public Property getComponent(String sCmpnName) {
-        if (sCmpnName.equals("block-progression-direction")) {
+    public Property getComponent(int cmpId) {
+        if (cmpId == Constants.CP_BLOCK_PROGRESSION_DIRECTION) {
             return getBPD();
-        } else if (sCmpnName.equals("inline-progression-direction")) {
+        } else if (cmpId == Constants.CP_INLINE_PROGRESSION_DIRECTION) {
             return getIPD();
         } else {
             return null;    // SHOULDN'T HAPPEN
index 1fca6f28ee3fb381f8f37595da61ab1abd0003c8..139fc5326fa65c12a9714ad8dcf1d12becfc73b4 100644 (file)
@@ -51,6 +51,7 @@
 package org.apache.fop.datatypes;
 
 import org.apache.fop.fo.Property;
+import org.apache.fop.fo.Constants;
 
 /**
  * A "progression-dimension" quantity.
@@ -69,35 +70,28 @@ public class LengthRange implements CompoundDatatype {
     private boolean bChecked = false;
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName component name ("minimum", "maximum", or "optimum")
-     * which is being set
-     * @param cmpnValue Property object to be set
-     * @param bIsDefault true of this is the default value (??)
+     * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
      */
-    public void setComponent(String sCmpnName, Property cmpnValue,
+    public void setComponent(int cmpId, Property cmpnValue,
                              boolean bIsDefault) {
-        if (sCmpnName.equals("minimum")) {
+        if (cmpId == Constants.CP_MINIMUM) {
             setMinimum(cmpnValue, bIsDefault);
-        } else if (sCmpnName.equals("optimum")) {
+        } else if (cmpId == Constants.CP_OPTIMUM) {
             setOptimum(cmpnValue, bIsDefault);
-        } else if (sCmpnName.equals("maximum")) {
+        } else if (cmpId == Constants.CP_MAXIMUM) {
             setMaximum(cmpnValue, bIsDefault);
         }
     }
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName component name ("minimum", "maximum", or "optimum")
-     * for which the length is sought
-     * @return the requested Property, or null if the component name is invalid
+     * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int)
      */
-    public Property getComponent(String sCmpnName) {
-        if (sCmpnName.equals("minimum")) {
+    public Property getComponent(int cmpId) {
+        if (cmpId == Constants.CP_MINIMUM) {
             return getMinimum();
-        } else if (sCmpnName.equals("optimum")) {
+        } else if (cmpId == Constants.CP_OPTIMUM) {
             return getOptimum();
-        } else if (sCmpnName.equals("maximum")) {
+        } else if (cmpId == Constants.CP_MAXIMUM) {
             return getMaximum();
         } else {
             return null;    // SHOULDN'T HAPPEN
index b3469c51317a269d1c2be9cfdc62e04352ab2865..c4879f7d4829a7e6caab3f2072152f9b9e7fca4f 100644 (file)
@@ -51,6 +51,7 @@
 package org.apache.fop.datatypes;
 
 import org.apache.fop.fo.Property;
+import org.apache.fop.fo.Constants;
 
 /**
  * a space quantity in XSL (space-before, space-after)
@@ -61,34 +62,29 @@ public class Space extends LengthRange {
     private Property conditionality;
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName name of component
-     * @param cmpnValue Property object for the component
-     * @param bIsDefault true if this is the default (??)
+     * @see org.apache.fop.datatypes.CompoundDatatype#setComponent(int, Property, boolean)
      */
-    public void setComponent(String sCmpnName, Property cmpnValue,
+    public void setComponent(int cmpId, Property cmpnValue,
                              boolean bIsDefault) {
-        if (sCmpnName.equals("precedence")) {
+        if (cmpId == Constants.CP_PRECEDENCE) {
             setPrecedence(cmpnValue, bIsDefault);
-        } else if (sCmpnName.equals("conditionality")) {
+        } else if (cmpId == Constants.CP_CONDITIONALITY) {
             setConditionality(cmpnValue, bIsDefault);
         } else {
-            super.setComponent(sCmpnName, cmpnValue, bIsDefault);
+            super.setComponent(cmpId, cmpnValue, bIsDefault);
         }
     }
 
     /**
-     * From CompoundDatatype
-     * @param sCmpnName name of component
-     * @return Property matching the component name
+     * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int)
      */
-    public Property getComponent(String sCmpnName) {
-        if (sCmpnName.equals("precedence")) {
+    public Property getComponent(int cmpId) {
+        if (cmpId == Constants.CP_PRECEDENCE) {
             return getPrecedence();
-        } else if (sCmpnName.equals("conditionality")) {
+        } else if (cmpId == Constants.CP_CONDITIONALITY) {
             return getConditionality();
         } else {
-            return super.getComponent(sCmpnName);
+            return super.getComponent(cmpId);
         }
     }