From 680e02cc8ef11c9dbb6acf43eaaa1e63dea6b8e6 Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Thu, 1 May 2003 05:57:33 +0000 Subject: [PATCH] Refactor: extract overloaded method convertAttributeToProperty() from the "for" loop in makeList(). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196383 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/fo/PropertyListBuilder.java | 84 ++++++++++--------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/src/java/org/apache/fop/fo/PropertyListBuilder.java b/src/java/org/apache/fop/fo/PropertyListBuilder.java index 56b2c5075..2a6c5a319 100644 --- a/src/java/org/apache/fop/fo/PropertyListBuilder.java +++ b/src/java/org/apache/fop/fo/PropertyListBuilder.java @@ -160,50 +160,58 @@ public class PropertyListBuilder { for (int i = 0; i < attributes.getLength(); i++) { String attributeName = attributes.getQName(i); - /* Handle "compound" properties, ex. space-before.minimum */ - String basePropName = findBasePropertyName(attributeName); - String subPropName = findSubPropertyName(attributeName); - Property propVal = null; - - Property.Maker propertyMaker = findMaker(validProperties, basePropName); - - if (propertyMaker != null) { - try { - if (subPropName != null) { - Property baseProp = p.getExplicitBaseProp(basePropName); - if (baseProp == null) { - // See if it is specified later in this list - String baseValue = attributes.getValue(basePropName); - if (baseValue != null) { - baseProp = propertyMaker.make(p, baseValue, - parentFO); - } - // else baseProp = propertyMaker.makeCompound(p, parentFO); + convertAttributeToProperty(attributes, attributeName, validProperties, p, parentFO, i); + } + return p; + } + + private void convertAttributeToProperty(Attributes attributes, + String attributeName, + HashMap validProperties, + PropertyList p, + FObj parentFO, + int i) { + /* Handle "compound" properties, ex. space-before.minimum */ + String basePropName = findBasePropertyName(attributeName); + String subPropName = findSubPropertyName(attributeName); + Property propVal = null; + + Property.Maker propertyMaker = findMaker(validProperties, basePropName); + + if (propertyMaker != null) { + try { + if (subPropName != null) { + Property baseProp = p.getExplicitBaseProp(basePropName); + if (baseProp == null) { + // See if it is specified later in this list + String baseValue = attributes.getValue(basePropName); + if (baseValue != null) { + baseProp = propertyMaker.make(p, baseValue, + parentFO); } - propVal = propertyMaker.make(baseProp, subPropName, - p, - attributes.getValue(i), - parentFO); - } else { - propVal = propertyMaker.make(p, - attributes.getValue(i), - parentFO); - } - if (propVal != null) { - p.put(basePropName, propVal); + // else baseProp = propertyMaker.makeCompound(p, parentFO); } - } catch (FOPException e) { /* Do other props. */ - //log.error(e.getMessage()); + propVal = propertyMaker.make(baseProp, subPropName, + p, + attributes.getValue(i), + parentFO); + } else { + propVal = propertyMaker.make(p, + attributes.getValue(i), + parentFO); } - } else { - if (!attributeName.startsWith("xmlns")) { - //log.error("property '" - // + attributeName + "' ignored"); + if (propVal != null) { + p.put(basePropName, propVal); } + } catch (FOPException e) { /* Do other props. */ + //log.error(e.getMessage()); + } + } else { + if (!attributeName.startsWith("xmlns")) { + //log.error("property '" + // + attributeName + "' ignored"); } } - - return p; } /** -- 2.39.5