From 596a99559b12770c03ce9fa6b3ae88091856f021 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Tue, 6 Jan 2004 00:49:40 +0000 Subject: [PATCH] More String->Int conversions. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197143 13f79535-47bb-0310-9956-ffa450edef68 --- src/codegen/properties.xsl | 22 +++++++++------ .../fop/datatypes/CompoundDatatype.java | 8 +++--- .../org/apache/fop/datatypes/CondLength.java | 16 +++++------ src/java/org/apache/fop/datatypes/Keep.java | 26 ++++++++--------- .../org/apache/fop/datatypes/LengthPair.java | 24 ++++++---------- .../org/apache/fop/datatypes/LengthRange.java | 28 ++++++++----------- src/java/org/apache/fop/datatypes/Space.java | 26 ++++++++--------- 7 files changed, 67 insertions(+), 83 deletions(-) diff --git a/src/codegen/properties.xsl b/src/codegen/properties.xsl index d4646237d..2adb422ce 100644 --- a/src/codegen/properties.xsl +++ b/src/codegen/properties.xsl @@ -566,24 +566,24 @@ public class protected Property setSubprop(Property baseProp, int subpropId, Property subProp) { - String subpropName = FOPropertyMapping.getPropertyName(subpropId); val = baseProp.get (); // 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); val = baseProp.get (); - return val.getComponent(subpropName); + return val.getComponent(subpropId); } @@ -630,9 +630,11 @@ public class ").make(pList, getDefaultFor (), fo); - p.setComponent(" - - ", subProp, true); + p.setComponent(Constants.CP_ + + + + , subProp, true); return new @@ -695,9 +697,11 @@ public class (); - pval.setComponent(" - - ", p, false); + pval.setComponent(Constants.CP_ + + + + , p, false); return prop; diff --git a/src/java/org/apache/fop/datatypes/CompoundDatatype.java b/src/java/org/apache/fop/datatypes/CompoundDatatype.java index 137911497..097b966d4 100644 --- a/src/java/org/apache/fop/datatypes/CompoundDatatype.java +++ b/src/java/org/apache/fop/datatypes/CompoundDatatype.java @@ -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); } diff --git a/src/java/org/apache/fop/datatypes/CondLength.java b/src/java/org/apache/fop/datatypes/CondLength.java index 4ae19cdc7..75c37e6f7 100644 --- a/src/java/org/apache/fop/datatypes/CondLength.java +++ b/src/java/org/apache/fop/datatypes/CondLength.java @@ -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; diff --git a/src/java/org/apache/fop/datatypes/Keep.java b/src/java/org/apache/fop/datatypes/Keep.java index 43606c7b9..9089c5d46 100644 --- a/src/java/org/apache/fop/datatypes/Keep.java +++ b/src/java/org/apache/fop/datatypes/Keep.java @@ -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; diff --git a/src/java/org/apache/fop/datatypes/LengthPair.java b/src/java/org/apache/fop/datatypes/LengthPair.java index c16941c72..21863d2a1 100644 --- a/src/java/org/apache/fop/datatypes/LengthPair.java +++ b/src/java/org/apache/fop/datatypes/LengthPair.java @@ -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 diff --git a/src/java/org/apache/fop/datatypes/LengthRange.java b/src/java/org/apache/fop/datatypes/LengthRange.java index 1fca6f28e..139fc5326 100644 --- a/src/java/org/apache/fop/datatypes/LengthRange.java +++ b/src/java/org/apache/fop/datatypes/LengthRange.java @@ -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 diff --git a/src/java/org/apache/fop/datatypes/Space.java b/src/java/org/apache/fop/datatypes/Space.java index b3469c513..c4879f7d4 100644 --- a/src/java/org/apache/fop/datatypes/Space.java +++ b/src/java/org/apache/fop/datatypes/Space.java @@ -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); } } -- 2.39.5