aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/properties
diff options
context:
space:
mode:
authorSimon Pepping <spepping@apache.org>2006-12-20 08:34:28 +0000
committerSimon Pepping <spepping@apache.org>2006-12-20 08:34:28 +0000
commit057128e23fa539021ed00d801619d98b7850e7f7 (patch)
tree4263ed3dbb20dd7fc331bf1d94404c7175f02ff3 /src/java/org/apache/fop/fo/properties
parent471c26061f650f931ab4ce5ae316f013f33d2d71 (diff)
downloadxmlgraphics-fop-057128e23fa539021ed00d801619d98b7850e7f7.tar.gz
xmlgraphics-fop-057128e23fa539021ed00d801619d98b7850e7f7.zip
Comment out unused properties. Patch by Richard Wheeldon
<richardw@geoquip-rnd.demon.co.uk>. ASF Bugzilla Bug 41044, attachment 19177. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@488960 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/properties')
-rwxr-xr-xsrc/java/org/apache/fop/fo/properties/EnumNumber.java19
-rw-r--r--src/java/org/apache/fop/fo/properties/EnumProperty.java36
-rw-r--r--src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java4
-rw-r--r--src/java/org/apache/fop/fo/properties/NumberProperty.java2
-rw-r--r--src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java6
-rwxr-xr-xsrc/java/org/apache/fop/fo/properties/PositionShorthandParser.java14
-rw-r--r--src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java2
-rw-r--r--src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java70
-rw-r--r--src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java8
9 files changed, 103 insertions, 58 deletions
diff --git a/src/java/org/apache/fop/fo/properties/EnumNumber.java b/src/java/org/apache/fop/fo/properties/EnumNumber.java
index 032aaeb60..a5679cbcc 100755
--- a/src/java/org/apache/fop/fo/properties/EnumNumber.java
+++ b/src/java/org/apache/fop/fo/properties/EnumNumber.java
@@ -19,17 +19,32 @@
package org.apache.fop.fo.properties;
+import java.util.Map;
+import java.util.WeakHashMap;
+
/**
* A number quantity in XSL which is specified as an enum, such as "no-limit".
*/
public class EnumNumber extends NumberProperty {
- private Property enumProperty;
+
+ private static final Map cache = new WeakHashMap();
+
+ private final EnumProperty enumProperty;
- public EnumNumber(Property enumProperty) {
+ private EnumNumber(EnumProperty enumProperty) {
super(null);
this.enumProperty = enumProperty;
}
+ public static EnumNumber getInstance(Property enumProperty) {
+ EnumNumber en = (EnumNumber)cache.get(enumProperty);
+ if (en == null) {
+ en = new EnumNumber((EnumProperty)enumProperty);
+ cache.put(enumProperty, en);
+ }
+ return en;
+ }
+
public int getEnum() {
return enumProperty.getEnum();
}
diff --git a/src/java/org/apache/fop/fo/properties/EnumProperty.java b/src/java/org/apache/fop/fo/properties/EnumProperty.java
index 9919e6df8..93dab72e2 100644
--- a/src/java/org/apache/fop/fo/properties/EnumProperty.java
+++ b/src/java/org/apache/fop/fo/properties/EnumProperty.java
@@ -23,6 +23,9 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
+import java.util.Map;
+import java.util.WeakHashMap;
+
/**
* Superclass for properties that wrap an enumeration value
*/
@@ -62,18 +65,31 @@ public class EnumProperty extends Property {
}
}
- private int value;
- private String text;
+ private static final Map propertyCache = new WeakHashMap();
+
+ private final int value;
+ private final String text;
/**
* @param explicitValue enumerated value to be set for this property
* @param text the string value of the enum.
*/
- public EnumProperty(int explicitValue, String text) {
+ private EnumProperty(int explicitValue, String text) {
this.value = explicitValue;
this.text = text;
}
+ public static EnumProperty getInstance(int explicitValue, String text) {
+ EnumProperty ep = new EnumProperty(explicitValue, text);
+ EnumProperty cacheEntry = (EnumProperty)propertyCache.get(ep);
+ if (cacheEntry == null) {
+ propertyCache.put(ep, ep);
+ return ep;
+ } else {
+ return cacheEntry;
+ }
+ }
+
/**
* @return this.value
*/
@@ -88,5 +104,19 @@ public class EnumProperty extends Property {
return text;
}
+ public boolean equals(Object obj) {
+ if (obj instanceof EnumProperty) {
+ EnumProperty ep = (EnumProperty)obj;
+ return ep.value == this.value &&
+ ((ep.text == null && this.text == null)
+ || ep.text.equals(this.text));
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return value + text.hashCode();
+ }
}
diff --git a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
index 86472b81a..e6f4ec393 100644
--- a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
@@ -54,9 +54,9 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker {
*/
Property p = super.make(propertyList, value, fo);
p.getSpace().setConditionality(
- new EnumProperty(Constants.EN_RETAIN, "RETAIN"), true);
+ EnumProperty.getInstance(Constants.EN_RETAIN, "RETAIN"), true);
p.getSpace().setPrecedence(
- new EnumProperty(Constants.EN_FORCE, "FORCE"), true);
+ EnumProperty.getInstance(Constants.EN_FORCE, "FORCE"), true);
return p;
}
diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java
index c8d44e417..21ffd32e7 100644
--- a/src/java/org/apache/fop/fo/properties/NumberProperty.java
+++ b/src/java/org/apache/fop/fo/properties/NumberProperty.java
@@ -58,7 +58,7 @@ public class NumberProperty extends Property implements Numeric {
return p;
}
if (p instanceof EnumProperty) {
- return new EnumNumber(p);
+ return EnumNumber.getInstance(p);
}
Number val = p.getNumber();
if (val != null) {
diff --git a/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java b/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
index 95ba938b0..c2bf559a2 100644
--- a/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
@@ -49,11 +49,11 @@ public class PageBreakShorthandParser implements ShorthandParser {
|| propId == Constants.PR_BREAK_AFTER) {
switch (property.getEnum()) {
case Constants.EN_ALWAYS:
- return new EnumProperty(Constants.EN_PAGE, "PAGE");
+ return EnumProperty.getInstance(Constants.EN_PAGE, "PAGE");
case Constants.EN_LEFT:
- return new EnumProperty(Constants.EN_EVEN_PAGE, "EVEN_PAGE");
+ return EnumProperty.getInstance(Constants.EN_EVEN_PAGE, "EVEN_PAGE");
case Constants.EN_RIGHT:
- return new EnumProperty(Constants.EN_ODD_PAGE, "ODD_PAGE");
+ return EnumProperty.getInstance(Constants.EN_ODD_PAGE, "ODD_PAGE");
case Constants.EN_AVOID:
default:
//nop;
diff --git a/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java b/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java
index d26f35bd5..a6a9671da 100755
--- a/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/PositionShorthandParser.java
@@ -41,11 +41,11 @@ public class PositionShorthandParser implements ShorthandParser {
switch (propVal) {
case Constants.EN_STATIC:
case Constants.EN_RELATIVE:
- return new EnumProperty(Constants.EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(Constants.EN_AUTO, "AUTO");
case Constants.EN_ABSOLUTE:
- return new EnumProperty(Constants.EN_ABSOLUTE, "ABSOLUTE");
+ return EnumProperty.getInstance(Constants.EN_ABSOLUTE, "ABSOLUTE");
case Constants.EN_FIXED:
- return new EnumProperty(Constants.EN_FIXED, "FIXED");
+ return EnumProperty.getInstance(Constants.EN_FIXED, "FIXED");
default:
//nop
}
@@ -53,13 +53,13 @@ public class PositionShorthandParser implements ShorthandParser {
if (propId == Constants.PR_RELATIVE_POSITION) {
switch (propVal) {
case Constants.EN_STATIC:
- return new EnumProperty(Constants.EN_STATIC, "STATIC");
+ return EnumProperty.getInstance(Constants.EN_STATIC, "STATIC");
case Constants.EN_RELATIVE:
- return new EnumProperty(Constants.EN_RELATIVE, "RELATIVE");
+ return EnumProperty.getInstance(Constants.EN_RELATIVE, "RELATIVE");
case Constants.EN_ABSOLUTE:
- return new EnumProperty(Constants.EN_STATIC, "STATIC");
+ return EnumProperty.getInstance(Constants.EN_STATIC, "STATIC");
case Constants.EN_FIXED:
- return new EnumProperty(Constants.EN_STATIC, "STATIC");
+ return EnumProperty.getInstance(Constants.EN_STATIC, "STATIC");
default:
//nop
}
diff --git a/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java b/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java
index c7de88341..e5c572952 100644
--- a/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java
@@ -43,7 +43,7 @@ public class SpacePropertyMaker extends CorrespondingPropertyMaker {
Property prop = super.compute(propertyList);
if (prop != null && prop instanceof SpaceProperty) {
((SpaceProperty)prop).setConditionality(
- new EnumProperty(Constants.EN_RETAIN, "RETAIN"), false);
+ EnumProperty.getInstance(Constants.EN_RETAIN, "RETAIN"), false);
}
return prop;
}
diff --git a/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java b/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java
index 86330948d..92d6095ca 100644
--- a/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java
@@ -40,101 +40,101 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
case EN_BASELINE:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_BASELINE, "BASELINE");
+ return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_TOP:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_BEFORE_EDGE, "BEFORE_EDGE");
+ return EnumProperty.getInstance(EN_BEFORE_EDGE, "BEFORE_EDGE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_TEXT_TOP:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_TEXT_BEFORE_EDGE, "TEXT_BEFORE_EDGE");
+ return EnumProperty.getInstance(EN_TEXT_BEFORE_EDGE, "TEXT_BEFORE_EDGE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_MIDDLE:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_MIDDLE, "MIDDLE");
+ return EnumProperty.getInstance(EN_MIDDLE, "MIDDLE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_BOTTOM:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_AFTER_EDGE, "AFTER_EDGE");
+ return EnumProperty.getInstance(EN_AFTER_EDGE, "AFTER_EDGE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_TEXT_BOTTOM:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_TEXT_AFTER_EDGE, "TEXT_AFTER_EDGE");
+ return EnumProperty.getInstance(EN_TEXT_AFTER_EDGE, "TEXT_AFTER_EDGE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_SUB:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_BASELINE, "BASELINE");
+ return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_SUB, "SUB"));
+ return new EnumLength(EnumProperty.getInstance(EN_SUB, "SUB"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
case EN_SUPER:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_BASELINE, "BASELINE");
+ return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
case PR_ALIGNMENT_ADJUST:
- return new EnumLength(new EnumProperty(EN_AUTO, "AUTO"));
+ return new EnumLength(EnumProperty.getInstance(EN_AUTO, "AUTO"));
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_SUPER, "SUPER"));
+ return new EnumLength(EnumProperty.getInstance(EN_SUPER, "SUPER"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
default:
switch (propId) {
case PR_ALIGNMENT_BASELINE:
- return new EnumProperty(EN_BASELINE, "BASELINE");
+ return EnumProperty.getInstance(EN_BASELINE, "BASELINE");
case PR_ALIGNMENT_ADJUST:
return property;
case PR_BASELINE_SHIFT:
- return new EnumLength(new EnumProperty(EN_BASELINE, "BASELINE"));
+ return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
- return new EnumProperty(EN_AUTO, "AUTO");
+ return EnumProperty.getInstance(EN_AUTO, "AUTO");
}
}
return null;
diff --git a/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java b/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java
index 10fc75e93..d7b13b540 100644
--- a/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java
@@ -42,17 +42,17 @@ public class WhiteSpaceShorthandParser implements ShorthandParser {
switch (propId) {
case Constants.PR_LINEFEED_TREATMENT:
case Constants.PR_WHITE_SPACE_TREATMENT:
- return new EnumProperty(Constants.EN_PRESERVE, "PRESERVE");
+ return EnumProperty.getInstance(Constants.EN_PRESERVE, "PRESERVE");
case Constants.PR_WHITE_SPACE_COLLAPSE:
- return new EnumProperty(Constants.EN_FALSE, "FALSE");
+ return EnumProperty.getInstance(Constants.EN_FALSE, "FALSE");
case Constants.PR_WRAP_OPTION:
- return new EnumProperty(Constants.EN_NO_WRAP, "NO_WRAP");
+ return EnumProperty.getInstance(Constants.EN_NO_WRAP, "NO_WRAP");
default:
//nop
}
case Constants.EN_NO_WRAP:
if (propId == Constants.PR_WRAP_OPTION) {
- return new EnumProperty(Constants.EN_NO_WRAP, "NO_WRAP");
+ return EnumProperty.getInstance(Constants.EN_NO_WRAP, "NO_WRAP");
}
case Constants.EN_NORMAL:
default: