From 6b78b19472cd4dcd67859c958b1e5f85bdc731c5 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Wed, 7 Jan 2004 21:10:38 +0000 Subject: [PATCH] Last of string->int conversions (more structural improvements still can be done in PropertyList from Finn's patch, however). Made Constants values inherent to CompoundDatatype class. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197144 13f79535-47bb-0310-9956-ffa450edef68 --- src/codegen/properties.xsl | 3 +-- .../org/apache/fop/datatypes/CompoundDatatype.java | 3 ++- src/java/org/apache/fop/datatypes/CondLength.java | 8 ++++---- src/java/org/apache/fop/datatypes/Keep.java | 12 ++++++------ src/java/org/apache/fop/datatypes/LengthPair.java | 8 ++++---- src/java/org/apache/fop/fo/Property.java | 4 ++-- src/java/org/apache/fop/fo/PropertyList.java | 9 +++------ 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/codegen/properties.xsl b/src/codegen/properties.xsl index 2adb422ce..5a4970963 100644 --- a/src/codegen/properties.xsl +++ b/src/codegen/properties.xsl @@ -576,8 +576,7 @@ public class return baseProp; } - public Property getSubpropValue(Property baseProp, String subpropName) { - int subpropId = org.apache.fop.fo.properties.FOPropertyMapping.getSubPropertyId(subpropName); + public Property getSubpropValue(Property baseProp, int subpropId) { val = baseProp.get diff --git a/src/java/org/apache/fop/datatypes/CompoundDatatype.java b/src/java/org/apache/fop/datatypes/CompoundDatatype.java index 097b966d4..14e32b711 100644 --- a/src/java/org/apache/fop/datatypes/CompoundDatatype.java +++ b/src/java/org/apache/fop/datatypes/CompoundDatatype.java @@ -51,11 +51,12 @@ package org.apache.fop.datatypes; import org.apache.fop.fo.Property; +import org.apache.fop.fo.Constants; /** * This interface is used as a base for compound datatypes. */ -public interface CompoundDatatype { +public interface CompoundDatatype extends Constants { /** * Sets a component of the compound datatype. diff --git a/src/java/org/apache/fop/datatypes/CondLength.java b/src/java/org/apache/fop/datatypes/CondLength.java index 75c37e6f7..18ca33d2b 100644 --- a/src/java/org/apache/fop/datatypes/CondLength.java +++ b/src/java/org/apache/fop/datatypes/CondLength.java @@ -67,9 +67,9 @@ public class CondLength implements CompoundDatatype { */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { - if (cmpId == Constants.CP_LENGTH) { + if (cmpId == CP_LENGTH) { length = cmpnValue; - } else if (cmpId == Constants.CP_CONDITIONALITY) { + } else if (cmpId == CP_CONDITIONALITY) { conditionality = cmpnValue; } } @@ -78,9 +78,9 @@ public class CondLength implements CompoundDatatype { * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) */ public Property getComponent(int cmpId) { - if (cmpId == Constants.CP_LENGTH) { + if (cmpId == CP_LENGTH) { return length; - } else if (cmpId == Constants.CP_CONDITIONALITY) { + } else if (cmpId == 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 9089c5d46..3c68ad5e6 100644 --- a/src/java/org/apache/fop/datatypes/Keep.java +++ b/src/java/org/apache/fop/datatypes/Keep.java @@ -73,11 +73,11 @@ public class Keep implements CompoundDatatype { */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { - if (cmpId == Constants.CP_WITHIN_LINE) { + if (cmpId == CP_WITHIN_LINE) { setWithinLine(cmpnValue, bIsDefault); - } else if (cmpId == Constants.CP_WITHIN_COLUMN) { + } else if (cmpId == CP_WITHIN_COLUMN) { setWithinColumn(cmpnValue, bIsDefault); - } else if (cmpId == Constants.CP_WITHIN_PAGE) { + } else if (cmpId == CP_WITHIN_PAGE) { setWithinPage(cmpnValue, bIsDefault); } } @@ -86,11 +86,11 @@ public class Keep implements CompoundDatatype { * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) */ public Property getComponent(int cmpId) { - if (cmpId == Constants.CP_WITHIN_LINE) { + if (cmpId == CP_WITHIN_LINE) { return getWithinLine(); - } else if (cmpId == Constants.CP_WITHIN_COLUMN) { + } else if (cmpId == CP_WITHIN_COLUMN) { return getWithinColumn(); - } else if (cmpId == Constants.CP_WITHIN_PAGE) { + } else if (cmpId == 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 21863d2a1..ac2de9c8b 100644 --- a/src/java/org/apache/fop/datatypes/LengthPair.java +++ b/src/java/org/apache/fop/datatypes/LengthPair.java @@ -68,9 +68,9 @@ public class LengthPair implements CompoundDatatype { */ public void setComponent(int cmpId, Property cmpnValue, boolean bIsDefault) { - if (cmpId == Constants.CP_BLOCK_PROGRESSION_DIRECTION) { + if (cmpId == CP_BLOCK_PROGRESSION_DIRECTION) { bpd = cmpnValue; - } else if (cmpId == Constants.CP_INLINE_PROGRESSION_DIRECTION) { + } else if (cmpId == CP_INLINE_PROGRESSION_DIRECTION) { ipd = cmpnValue; } } @@ -79,9 +79,9 @@ public class LengthPair implements CompoundDatatype { * @see org.apache.fop.datatypes.CompoundDatatype#getComponent(int) */ public Property getComponent(int cmpId) { - if (cmpId == Constants.CP_BLOCK_PROGRESSION_DIRECTION) { + if (cmpId == CP_BLOCK_PROGRESSION_DIRECTION) { return getBPD(); - } else if (cmpId == Constants.CP_INLINE_PROGRESSION_DIRECTION) { + } else if (cmpId == CP_INLINE_PROGRESSION_DIRECTION) { return getIPD(); } else { return null; // SHOULDN'T HAPPEN diff --git a/src/java/org/apache/fop/fo/Property.java b/src/java/org/apache/fop/fo/Property.java index 0fd2ba732..febf164a0 100644 --- a/src/java/org/apache/fop/fo/Property.java +++ b/src/java/org/apache/fop/fo/Property.java @@ -155,7 +155,7 @@ public class Property { * property. * @param p A property value for a compound property type such as * SpaceProperty. - * @param subprop The name of the component whose value is to be + * @param subprop The Constants ID of the component whose value is to be * returned. * NOTE: this is only to ease porting when calls are made to * PropertyList.get() using a component name of a compound property, @@ -165,7 +165,7 @@ public class Property { * compound properties. * @return the Property containing the subproperty */ - public Property getSubpropValue(Property p, String subprop) { + public Property getSubpropValue(Property p, int subpropId) { return null; } diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java index cfb8396c4..8c69f0e88 100644 --- a/src/java/org/apache/fop/fo/PropertyList.java +++ b/src/java/org/apache/fop/fo/PropertyList.java @@ -521,8 +521,8 @@ public class PropertyList extends HashMap { /* If the baseProperty has already been created, return it * e.g. */ - int propId = FOPropertyMapping.getPropertyId(basePropName); - Property baseProperty = getExplicitBaseProp(propId); + + Property baseProperty = (Property) super.get(basePropName); if (baseProperty != null) { return baseProperty; @@ -588,13 +588,10 @@ public class PropertyList extends HashMap { */ private Property getSubpropValue(Property p, int propId) { - String subpropName = FOPropertyMapping.getPropertyName(propId & - Constants.COMPOUND_MASK); - Property.Maker maker = findMaker(propId & Constants.PROPERTY_MASK); if (maker != null) { - return maker.getSubpropValue(p, subpropName); + return maker.getSubpropValue(p, propId & Constants.COMPOUND_MASK); } else { return null; } -- 2.39.5