aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/properties/CharacterProperty.java
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2007-07-19 23:31:55 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2007-07-19 23:31:55 +0000
commit4f6fbb2785bf742bbc98f1778277fd469988b2fc (patch)
treead28cc3d5f16ad162175faf1576bfe22c835b637 /src/java/org/apache/fop/fo/properties/CharacterProperty.java
parent6c3da8eca79bdd1983cf1abb9c3118fd688500db (diff)
downloadxmlgraphics-fop-4f6fbb2785bf742bbc98f1778277fd469988b2fc.tar.gz
xmlgraphics-fop-4f6fbb2785bf742bbc98f1778277fd469988b2fc.zip
Cache CharacterProperty
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@557814 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/properties/CharacterProperty.java')
-rw-r--r--src/java/org/apache/fop/fo/properties/CharacterProperty.java38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/fo/properties/CharacterProperty.java b/src/java/org/apache/fop/fo/properties/CharacterProperty.java
index 79b0ebc07..1496f5f86 100644
--- a/src/java/org/apache/fop/fo/properties/CharacterProperty.java
+++ b/src/java/org/apache/fop/fo/properties/CharacterProperty.java
@@ -25,8 +25,8 @@ import org.apache.fop.fo.PropertyList;
/**
* Superclass for properties that wrap a character value
*/
-public class CharacterProperty extends Property {
-
+public final class CharacterProperty extends Property {
+
/**
* Inner class for creating instances of CharacterProperty
*/
@@ -42,19 +42,27 @@ public class CharacterProperty extends Property {
public Property make(PropertyList propertyList, String value,
FObj fo) {
char c = value.charAt(0);
- return new CharacterProperty(c);
+ return CharacterProperty.getInstance(c);
}
- } // end Character.Maker
+ }
+
+ /** cache containing all canonical CharacterProperty instances */
+ private static final PropertyCache cache = new PropertyCache();
- private char character;
+ private final char character;
/**
* @param character character value to be wrapped in this property
*/
- public CharacterProperty(char character) {
+ private CharacterProperty(char character) {
this.character = character;
}
+
+ public static CharacterProperty getInstance(char character) {
+ return (CharacterProperty) cache.fetch(
+ new CharacterProperty(character));
+ }
/**
* @return this.character cast as an Object
@@ -77,4 +85,22 @@ public class CharacterProperty extends Property {
return new Character(character).toString();
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof CharacterProperty) {
+ return (((CharacterProperty)obj).character == this.character);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode() {
+ return (int) character;
+ }
+
}