aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorWilliam Victor Mote <vmote@apache.org>2003-04-28 00:38:21 +0000
committerWilliam Victor Mote <vmote@apache.org>2003-04-28 00:38:21 +0000
commitc28ba5b19280feafac0a0660ac110466fc1fc77c (patch)
tree61739b70a3248a095b2c7a1c4bdd3be88647d516 /src/java/org
parentc48b2ebbd3781a3248aba345fa02685d342c044e (diff)
downloadxmlgraphics-fop-c28ba5b19280feafac0a0660ac110466fc1fc77c.tar.gz
xmlgraphics-fop-c28ba5b19280feafac0a0660ac110466fc1fc77c.zip
Refactor: extract methods findBasePropertyName and findSubPropertyName from makeList, and clean up logic using them.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196358 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/fo/PropertyListBuilder.java60
1 files changed, 41 insertions, 19 deletions
diff --git a/src/java/org/apache/fop/fo/PropertyListBuilder.java b/src/java/org/apache/fop/fo/PropertyListBuilder.java
index 4d8341336..811b35528 100644
--- a/src/java/org/apache/fop/fo/PropertyListBuilder.java
+++ b/src/java/org/apache/fop/fo/PropertyListBuilder.java
@@ -165,37 +165,27 @@ public class PropertyListBuilder {
for (int i = 0; i < attributes.getLength(); i++) {
String attributeName = attributes.getQName(i);
/* Handle "compound" properties, ex. space-before.minimum */
- int sepchar = attributeName.indexOf('.');
- String propName = attributeName;
- String subpropName = null;
+ String basePropName = findBasePropertyName(attributeName);
+ String subPropName = findSubPropertyName(attributeName);
Property propVal = null;
- if (sepchar > -1) {
- propName = attributeName.substring(0, sepchar);
- subpropName = attributeName.substring(sepchar + 1);
- } else if (propsDone.toString().indexOf(' ' + propName + ' ')
- != -1) {
- // Already processed this property (base property
- // for a property with sub-components or font-size)
- continue;
- }
- Property.Maker propertyMaker = findMaker(table, propName);
+ Property.Maker propertyMaker = findMaker(table, basePropName);
if (propertyMaker != null) {
try {
- if (subpropName != null) {
- Property baseProp = p.getExplicitBaseProp(propName);
+ if (subPropName != null) {
+ Property baseProp = p.getExplicitBaseProp(basePropName);
if (baseProp == null) {
// See if it is specified later in this list
- String baseValue = attributes.getValue(propName);
+ String baseValue = attributes.getValue(basePropName);
if (baseValue != null) {
baseProp = propertyMaker.make(p, baseValue,
parentFO);
- propsDone.append(propName + ' ');
+ propsDone.append(basePropName + ' ');
}
// else baseProp = propertyMaker.makeCompound(p, parentFO);
}
- propVal = propertyMaker.make(baseProp, subpropName,
+ propVal = propertyMaker.make(baseProp, subPropName,
p,
attributes.getValue(i),
parentFO);
@@ -205,7 +195,7 @@ public class PropertyListBuilder {
parentFO);
}
if (propVal != null) {
- p.put(propName, propVal);
+ p.put(basePropName, propVal);
}
} catch (FOPException e) { /* Do other props. */
//log.error(e.getMessage());
@@ -221,6 +211,38 @@ public class PropertyListBuilder {
return p;
}
+ /**
+ * Finds the first or base part (up to any period) of an attribute name.
+ * For example, if input is "space-before.minimum", should return
+ * "space-before".
+ * @param attributeName String to be atomized
+ * @return the base portion of the attribute
+ */
+ public static String findBasePropertyName(String attributeName) {
+ int sepCharIndex = attributeName.indexOf('.');
+ String basePropName = attributeName;
+ if (sepCharIndex > -1) {
+ basePropName = attributeName.substring(0, sepCharIndex);
+ }
+ return basePropName;
+ }
+
+ /**
+ * Finds the second or sub part (portion past any period) of an attribute
+ * name. For example, if input is "space-before.minimum", should return
+ * "minimum".
+ * @param attributeName String to be atomized
+ * @return the sub portion of the attribute
+ */
+ public static String findSubPropertyName(String attributeName) {
+ int sepCharIndex = attributeName.indexOf('.');
+ String subPropName = null;
+ if (sepCharIndex > -1) {
+ subPropName = attributeName.substring(sepCharIndex + 1);
+ }
+ return subPropName;
+ }
+
public Property getSubpropValue(String space, String element,
String propertyName, Property p,
String subpropName) {