aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/PropertyList.java
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2004-01-04 22:04:08 +0000
committerGlen Mazza <gmazza@apache.org>2004-01-04 22:04:08 +0000
commite0a1a992ffef380e24005f5bc045fc180e04afbc (patch)
treed37417e25844c3bd2f03fd65ce676bd1089a2df0 /src/java/org/apache/fop/fo/PropertyList.java
parent7e5da4ee9ea802605745a4e384cc787b6eb6b9c4 (diff)
downloadxmlgraphics-fop-e0a1a992ffef380e24005f5bc045fc180e04afbc.tar.gz
xmlgraphics-fop-e0a1a992ffef380e24005f5bc045fc180e04afbc.zip
more String->int conversions.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197111 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/PropertyList.java')
-rw-r--r--src/java/org/apache/fop/fo/PropertyList.java150
1 files changed, 78 insertions, 72 deletions
diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java
index cb2b29645..b8ec2cc99 100644
--- a/src/java/org/apache/fop/fo/PropertyList.java
+++ b/src/java/org/apache/fop/fo/PropertyList.java
@@ -161,6 +161,20 @@ public class PropertyList extends HashMap {
}
/**
+ * @return the namespace of this element
+ */
+ public String getNameSpace() {
+ return namespace;
+ }
+
+ /**
+ * @return element name for this
+ */
+ public String getElement() {
+ return elementName;
+ }
+
+ /**
* Return the value explicitly specified on this FO.
* @param propertyName The name of the property whose value is desired.
* It may be a compound name, such as space-before.optimum.
@@ -169,6 +183,8 @@ public class PropertyList extends HashMap {
*/
public Property getExplicitOrShorthand(String propertyName) {
/* Handle request for one part of a compound property */
+ int propId = FOPropertyMapping.getPropertyId(propertyName);
+
int sepchar = propertyName.indexOf('.');
String baseName;
if (sepchar > -1) {
@@ -181,9 +197,7 @@ public class PropertyList extends HashMap {
p = getShorthand(namespace, elementName, baseName);
}
if (p != null && sepchar > -1) {
- return getSubpropValue(namespace, elementName, baseName, p,
- propertyName.substring(sepchar
- + 1));
+ return getSubpropValue(namespace, elementName, p, propId);
}
return p;
}
@@ -195,14 +209,15 @@ public class PropertyList extends HashMap {
* @return The value if the property is explicitly set, otherwise null.
*/
public Property getExplicit(String propertyName) {
+ int propId = FOPropertyMapping.getPropertyId(propertyName);
+
/* Handle request for one part of a compound property */
int sepchar = propertyName.indexOf('.');
if (sepchar > -1) {
String baseName = propertyName.substring(0, sepchar);
Property p = getExplicitBaseProp(baseName);
if (p != null) {
- return getSubpropValue(namespace, elementName, baseName, p,
- propertyName.substring(sepchar + 1));
+ return getSubpropValue(namespace, elementName, p, propId);
} else {
return null;
}
@@ -227,14 +242,15 @@ public class PropertyList extends HashMap {
* @return The inherited value, otherwise null.
*/
public Property getInherited(String propertyName) {
+ int propId = FOPropertyMapping.getPropertyId(propertyName);
+
if (parentPropertyList != null
&& isInherited(namespace, elementName, propertyName)) {
- int propertyId = FOPropertyMapping.getPropertyId(propertyName);
- return parentPropertyList.get(propertyId);
+ return parentPropertyList.get(propId);
} else {
// return the "initial" value
try {
- return makeProperty(namespace, elementName, propertyName);
+ return makeProperty(namespace, elementName, propId);
} catch (org.apache.fop.apps.FOPException e) {
//log.error("Exception in getInherited(): property="
// + propertyName + " : " + e);
@@ -243,37 +259,6 @@ public class PropertyList extends HashMap {
return null; // Exception in makeProperty!
}
- /*
- * If the property is a relative property with a corresponding absolute
- * value specified, the absolute value is used. This is also true of
- * the inheritance priority (I think...)
- * If the property is an "absolute" property and it isn't specified, then
- * we try to compute it from the corresponding relative property: this
- * happends in computeProperty.
- */
- private Property findProperty(String propertyName, boolean bTryInherit) {
- Property p = null;
- if (isCorrespondingForced(namespace, elementName, propertyName)) {
- p = computeProperty(namespace, elementName, propertyName);
- } else {
- p = getExplicitBaseProp(propertyName);
- if (p == null) {
- p = this.computeProperty(namespace, elementName, propertyName);
- }
- if (p == null) { // check for shorthand specification
- p = getShorthand(namespace, elementName, propertyName);
- }
- if (p == null && bTryInherit) {
- // else inherit (if has parent and is inheritable)
- if (this.parentPropertyList != null
- && isInherited(namespace, elementName, propertyName)) {
- p = parentPropertyList.findProperty(propertyName, true);
- }
- }
- }
- return p;
- }
-
/**
* Return the property on the current FlowObject. If it isn't set explicitly,
* this will try to compute it based on other properties, or if it is
@@ -283,8 +268,7 @@ public class PropertyList extends HashMap {
* @return the Property corresponding to that name
*/
public Property get(int propId) {
- String propertyName = FOPropertyMapping.getPropertyName(propId);
- return get(propertyName, true, true);
+ return get(propId, true, true);
}
/**
@@ -293,21 +277,15 @@ public class PropertyList extends HashMap {
* inheritable, to return the inherited value. If all else fails, it returns
* the default value.
*/
- private Property get(String propertyName, boolean bTryInherit,
+ private Property get(int propId, boolean bTryInherit,
boolean bTryDefault) {
- /* Handle request for one part of a compound property */
- int sepchar = propertyName.indexOf('.');
- String subpropName = null;
- if (sepchar > -1) {
- subpropName = propertyName.substring(sepchar + 1);
- propertyName = propertyName.substring(0, sepchar);
- }
-
- Property p = findProperty(propertyName, bTryInherit);
+ Property p = findProperty(propId & Constants.PROPERTY_MASK,
+ bTryInherit);
if (p == null && bTryDefault) { // default value for this FO!
try {
- p = makeProperty(namespace, elementName, propertyName);
+ p = makeProperty(namespace, elementName,
+ propId & Constants.PROPERTY_MASK);
} catch (FOPException e) {
// don't know what to do here
}
@@ -317,30 +295,50 @@ public class PropertyList extends HashMap {
// parent
if (p != null && "inherit".equals(p.getSpecifiedValue())) {
if (this.parentPropertyList != null) {
- p = parentPropertyList.get(propertyName, true, false);
+ p = parentPropertyList.get(propId, true, false);
}
}
- if (subpropName != null && p != null) {
- return getSubpropValue(namespace, elementName, propertyName, p,
- subpropName);
+ if ((propId & Constants.COMPOUND_MASK) != 0 && p != null) {
+ return getSubpropValue(namespace, elementName, p,
+ propId);
} else {
return p;
}
}
- /**
- * @return the namespace of this element
+ /*
+ * If the property is a relative property with a corresponding absolute
+ * value specified, the absolute value is used. This is also true of
+ * the inheritance priority (I think...)
+ * If the property is an "absolute" property and it isn't specified, then
+ * we try to compute it from the corresponding relative property: this
+ * happends in computeProperty.
*/
- public String getNameSpace() {
- return namespace;
- }
+ private Property findProperty(int propId, boolean bTryInherit) {
- /**
- * @return element name for this
- */
- public String getElement() {
- return elementName;
+ String propertyName = FOPropertyMapping.getPropertyName(propId);
+
+ Property p = null;
+ if (isCorrespondingForced(namespace, elementName, propertyName)) {
+ p = computeProperty(namespace, elementName, propertyName);
+ } else {
+ p = getExplicitBaseProp(propertyName);
+ if (p == null) {
+ p = this.computeProperty(namespace, elementName, propertyName);
+ }
+ if (p == null) { // check for shorthand specification
+ p = getShorthand(namespace, elementName, propertyName);
+ }
+ if (p == null && bTryInherit) {
+ // else inherit (if has parent and is inheritable)
+ if (this.parentPropertyList != null
+ && isInherited(namespace, elementName, propertyName)) {
+ p = parentPropertyList.findProperty(propId, true);
+ }
+ }
+ }
+ return p;
}
/**
@@ -351,6 +349,8 @@ public class PropertyList extends HashMap {
* ancestor of the current FO, else the initial value.
*/
public Property getNearestSpecified(String propertyName) {
+ int propId = FOPropertyMapping.getPropertyId(propertyName);
+
Property p = null;
for (PropertyList plist = this; p == null && plist != null;
plist = plist.parentPropertyList) {
@@ -359,7 +359,7 @@ public class PropertyList extends HashMap {
if (p == null) {
// If no explicit setting found, return initial (default) value.
try {
- p = makeProperty(namespace, elementName, propertyName);
+ p = makeProperty(namespace, elementName, propId);
} catch (FOPException e) {
//log.error("Exception in getNearestSpecified(): property="
// + propertyName + " : " + e);
@@ -382,7 +382,7 @@ public class PropertyList extends HashMap {
return parentPropertyList.get(propId);
} else {
try {
- return makeProperty(namespace, elementName, propertyName);
+ return makeProperty(namespace, elementName, propId);
} catch (org.apache.fop.apps.FOPException e) {
//log.error("Exception in getFromParent(): property="
// + propertyName + " : " + e);
@@ -597,8 +597,14 @@ public class PropertyList extends HashMap {
* @return the sub-property
*/
public Property getSubpropValue(String space, String element,
- String propertyName, Property p,
- String subpropName) {
+ Property p, int propId) {
+
+ String propertyName = FOPropertyMapping.getPropertyName(propId &
+ Constants.PROPERTY_MASK);
+
+ String subpropName = FOPropertyMapping.getPropertyName(propId &
+ Constants.COMPOUND_MASK);
+
Property.Maker maker = findMaker(space, element, propertyName);
if (maker != null) {
return maker.getSubpropValue(p, subpropName);
@@ -651,8 +657,9 @@ public class PropertyList extends HashMap {
* @throws FOPException for errors in the input
*/
public Property makeProperty(String space, String element,
- String propertyName) throws FOPException {
+ int propId) throws FOPException {
+ String propertyName = FOPropertyMapping.getPropertyName(propId);
Property p = null;
Property.Maker propertyMaker = findMaker(space, element,
@@ -668,7 +675,6 @@ public class PropertyList extends HashMap {
/**
*
- * @param propertyList collection of properties
* @param space namespace of element
* @param element name of element
* @param propertyName name of property