summaryrefslogtreecommitdiffstats
path: root/src/org/madore
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-04-26 19:40:08 +0200
committerDavid A. Madore <david+git@madore.org>2010-04-26 19:40:08 +0200
commit51301f3a00189754e58b4042364ec55618cf57e2 (patch)
tree488021d70e386c6985513e6e0b3607e771d503d8 /src/org/madore
parentcddec9d933c4bc46e4bec6094630ea7a19fd6860 (diff)
downloadUnicodeMap-51301f3a00189754e58b4042364ec55618cf57e2.tar.gz
UnicodeMap-51301f3a00189754e58b4042364ec55618cf57e2.tar.bz2
UnicodeMap-51301f3a00189754e58b4042364ec55618cf57e2.zip
Reuse constant strings for UnicodeCharacter labels and whatnots.
Diffstat (limited to 'src/org/madore')
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeCharacter.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
index 8fb64f7..34bab47 100644
--- a/src/org/madore/android/unicodeMap/UnicodeCharacter.java
+++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
@@ -270,33 +270,45 @@ public class UnicodeCharacter implements UnicodeDisplayable {
protected final int codePoint;
protected final String name;
protected final Category category;
+ protected final String charStr;
+ protected final String label;
+
+ protected String makeCharStr() {
+ return new String(Character.toChars(codePoint));
+ }
+
+ protected String makeLabel() {
+ StringBuilder s = new StringBuilder();
+ Formatter fmt = new Formatter(s);
+ if ( codePoint < 0x10000 )
+ fmt.format("U+%04X %s", codePoint, name);
+ else
+ fmt.format("U+%X %s", codePoint, name);
+ return new String(s);
+ }
public UnicodeCharacter(int codePoint, String name, Category category) {
this.codePoint = codePoint;
this.name = name;
this.category = category;
+ this.charStr = makeCharStr();
+ this.label = makeLabel();
}
public int getCodePoint() {
- return codePoint;
+ return this.codePoint;
}
public String getName() {
- return name;
+ return this.name;
}
public String getChar() {
- return new String(Character.toChars(codePoint));
+ return this.charStr;
}
public String getLabel() {
- StringBuilder s = new StringBuilder();
- Formatter fmt = new Formatter(s);
- if ( codePoint < 0x10000 )
- fmt.format("U+%04X %s", codePoint, name);
- else
- fmt.format("U+%X %s", codePoint, name);
- return new String(s);
+ return this.label;
}
public boolean isPrintable() {