aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Victor Mote <vmote@apache.org>2003-05-01 05:39:03 +0000
committerWilliam Victor Mote <vmote@apache.org>2003-05-01 05:39:03 +0000
commit61e23f934c8089be1f0b94bbe024af026f310e81 (patch)
tree5bf2ae5614bd8c3a301a400409f1d303f6494b43 /src
parentee2b8152997a5c17e158624755c421a53301c82d (diff)
downloadxmlgraphics-fop-61e23f934c8089be1f0b94bbe024af026f310e81.tar.gz
xmlgraphics-fop-61e23f934c8089be1f0b94bbe024af026f310e81.zip
Refactor: extract method convertAttributeToProperty() from makeList()
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196382 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/PropertyListBuilder.java53
1 files changed, 37 insertions, 16 deletions
diff --git a/src/java/org/apache/fop/fo/PropertyListBuilder.java b/src/java/org/apache/fop/fo/PropertyListBuilder.java
index 2c49f2e6e..56b2c5075 100644
--- a/src/java/org/apache/fop/fo/PropertyListBuilder.java
+++ b/src/java/org/apache/fop/fo/PropertyListBuilder.java
@@ -146,27 +146,17 @@ public class PropertyListBuilder {
PropertyList p = new PropertyList(parentProperties, nameSpaceURIToUse,
elementName);
p.setBuilder(this);
- HashMap table;
- table = (HashMap)elementTable.get(elementName);
+ HashMap validProperties;
+ validProperties = (HashMap)elementTable.get(elementName);
/*
* If font-size is set on this FO, must set it first, since
* other attributes specified in terms of "ems" depend on it.
- * When we do "shorthand" properties, must handle the "font"
+ */
+ /** @todo When we do "shorthand" properties, must handle the "font"
* property as well to see if font-size is set.
*/
- String fontsizeval = attributes.getValue(FONTSIZEATTR);
- if (fontsizeval != null) {
- Property.Maker propertyMaker = findMaker(table, FONTSIZEATTR);
- if (propertyMaker != null) {
- try {
- p.put(FONTSIZEATTR,
- propertyMaker.make(p, fontsizeval, parentFO));
- } catch (FOPException e) {
- /**@todo log this exception */
- }
- }
- }
+ convertAttributeToProperty(attributes, FONTSIZEATTR, validProperties, p, parentFO);
for (int i = 0; i < attributes.getLength(); i++) {
String attributeName = attributes.getQName(i);
@@ -175,7 +165,7 @@ public class PropertyListBuilder {
String subPropName = findSubPropertyName(attributeName);
Property propVal = null;
- Property.Maker propertyMaker = findMaker(table, basePropName);
+ Property.Maker propertyMaker = findMaker(validProperties, basePropName);
if (propertyMaker != null) {
try {
@@ -217,6 +207,37 @@ public class PropertyListBuilder {
}
/**
+ *
+ * @param attributes Collection of attributes
+ * @param attributeName Attribute name to convert
+ * @param validProperties Collection of valid properties
+ * @param propList PropertyList in which to add the newly created Property
+ * @param parentFO Parent FO of the object for which this property is being
+ * built
+ */
+ private void convertAttributeToProperty(Attributes attributes,
+ String attributeName,
+ HashMap validProperties,
+ PropertyList propList,
+ FObj parentFO) {
+ String attributeValue = attributes.getValue(attributeName);
+ if (attributeValue == null) {
+ return;
+ }
+ Property.Maker propertyMaker = findMaker(validProperties, attributeName);
+ if (propertyMaker == null) {
+ return;
+ }
+ try {
+ propList.put(attributeName,
+ propertyMaker.make(propList, attributeValue, parentFO));
+ }
+ catch (FOPException e) {
+ /**@todo log this exception */
+ }
+ }
+
+ /**
* 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".