[FOray-commit] SF.net SVN: foray: [9286] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-04-28 20:53:54
|
Revision: 9286
http://svn.sourceforge.net/foray/?rev=9286&view=rev
Author: victormote
Date: 2007-04-28 13:53:54 -0700 (Sat, 28 Apr 2007)
Log Message:
-----------
Make all EncodingVector subclasses true singletons, and make their data private.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/charset/CharSetWindowsANSI.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java
trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/charset/CharSetWindowsANSI.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/charset/CharSetWindowsANSI.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-font/src/java/org/foray/font/charset/CharSetWindowsANSI.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -41,7 +41,7 @@
* Constructor.
*/
public CharSetWindowsANSI() {
- super("WindowsANSI", EncodingWinAnsi.CODE_POINTS);
+ super("WindowsANSI", EncodingWinAnsi.getCodePoints());
}
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingCE.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -44,10 +44,10 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingCE extends EncodingVector {
+public final class EncodingCE extends EncodingVector {
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
"A", // #0 glyph: 0x41 \101
"Aacute", // #1 glyph: 0xc1 \301
"Abreve", // #2 glyph: 0xc3 \303
@@ -265,7 +265,7 @@
"zero" // #214 glyph: 0x30 \60
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0xc1, // #1
0xc3, // #2
@@ -485,7 +485,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x22, // #2 glyph: 0x22 \42
@@ -706,7 +706,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x22, // #2
@@ -924,17 +924,30 @@
0x99 // #214
};
+ /** The singleton instance. */
+ private static EncodingCE theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "CEEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingCE() {
+ private EncodingCE() {
super("CEEncoding", GlyphList.standardSourceGlyphLists(),
EncodingCE.CODE_POINTS,
EncodingCE.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingCE getInstance() {
+ if (EncodingCE.theInstance == null) {
+ EncodingCE.theInstance = new EncodingCE();
+ }
+ return EncodingCE.theInstance;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpert.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -43,9 +43,9 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingExpert extends EncodingVector {
+public final class EncodingExpert extends EncodingVector {
-/* public static final String[] sortedGlyphNames = {
+/* private static final String[] sortedGlyphNames = {
"AEsmall", // #0 glyph: 0xe6 \346
"Aacutesmall", // #1 glyph: 0xe1 \341
"Acircumflexsmall", // #2 glyph: 0xe2 \342
@@ -213,7 +213,7 @@
"zerosuperior" // #164 glyph: 0xc8 \310
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0xe6, // #0
0xe1, // #1
0xe2, // #2
@@ -383,7 +383,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x2c, // #1 glyph: 0x2c \54
0x2d, // #2 glyph: 0x2d \55
@@ -554,7 +554,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x2c, // #1
0x2d, // #2
@@ -722,17 +722,30 @@
0x5a // #164
};
+ /** The singleton instance. */
+ private static EncodingExpert theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "ExpertEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingExpert() {
+ private EncodingExpert() {
super("ExpertEncoding", GlyphList.standardSourceGlyphLists(),
EncodingExpert.CODE_POINTS,
EncodingExpert.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingExpert getInstance() {
+ if (EncodingExpert.theInstance == null) {
+ EncodingExpert.theInstance = new EncodingExpert();
+ }
+ return EncodingExpert.theInstance;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingExpertSubset.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -43,10 +43,10 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingExpertSubset extends EncodingVector {
+public final class EncodingExpertSubset extends EncodingVector {
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
"asuperior", // [0] glyph-index: 0x0041 \101
"bsuperior", // [1] glyph-index: 0x0042 \102
"centinferior", // [2] glyph-index: 0x00dc \334
@@ -135,7 +135,7 @@
"zerosuperior" // [85] glyph-index: 0x00c8 \310
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x0041, // [0] \101 asuperior
0x0042, // [1] \102 bsuperior
0x00dc, // [2] \334 centinferior
@@ -226,7 +226,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x0020, // [0] glyph: 0x0020 \0040
0x002c, // [1] glyph: 0x002c \0054
0x002d, // [2] glyph: 0x002d \0055
@@ -318,7 +318,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x0020, // [0]
0x002c, // [1]
0x002d, // [2]
@@ -407,17 +407,30 @@
0x005a // [85]
};
+ /** The singleton instance. */
+ private static EncodingExpertSubset theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "ExpertSubsetEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingExpertSubset() {
+ private EncodingExpertSubset() {
super("ExpertSubsetEncoding", GlyphList.standardSourceGlyphLists(),
EncodingExpertSubset.CODE_POINTS,
EncodingExpertSubset.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingExpertSubset getInstance() {
+ if (EncodingExpertSubset.theInstance == null) {
+ EncodingExpertSubset.theInstance = new EncodingExpertSubset();
+ }
+ return EncodingExpertSubset.theInstance;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingFOrayLatinExtra.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -49,10 +49,10 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingFOrayLatinExtra extends EncodingVector {
+public final class EncodingFOrayLatinExtra extends EncodingVector {
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
"Amacron", // [0] glyph-index: 0x0021 \041
"Delta", // [1] glyph-index: 0x0022 \042
"Edotaccent", // [2] glyph-index: 0x0023 \043
@@ -102,7 +102,7 @@
"uogonek" // [46] glyph-index: 0x004e \116
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x0021, // [0] \041 Amacron
0x0022, // [1] \042 Delta
0x0023, // [2] \043 Edotaccent
@@ -154,7 +154,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x0020, // [0] glyph: 0x0020 \0040
0x0100, // [1] glyph: 0x0021 \0041
0x0101, // [2] glyph: 0x0032 \0062
@@ -207,7 +207,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x0020, // [0]
0x0021, // [1]
0x0032, // [2]
@@ -257,18 +257,30 @@
0x0038 // [46]
};
+ /** The singleton instance. */
+ private static EncodingFOrayLatinExtra theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass
- * "FOrayLatinExtraEncoding" to
- * {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingFOrayLatinExtra() {
+ private EncodingFOrayLatinExtra() {
super("FOrayLatinExtraEncoding", GlyphList.standardSourceGlyphLists(),
EncodingFOrayLatinExtra.CODE_POINTS,
EncodingFOrayLatinExtra.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingFOrayLatinExtra getInstance() {
+ if (EncodingFOrayLatinExtra.theInstance == null) {
+ EncodingFOrayLatinExtra.theInstance = new EncodingFOrayLatinExtra();
+ }
+ return EncodingFOrayLatinExtra.theInstance;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingISOLatin1.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -42,10 +42,10 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingISOLatin1 extends EncodingVector {
+public final class EncodingISOLatin1 extends EncodingVector {
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
"A", // #0 glyph: 0x41 \101
"AE", // #1 glyph: 0xc6 \306
"Aacute", // #2 glyph: 0xc1 \301
@@ -248,7 +248,7 @@
"zero" // #199 glyph: 0x30 \60
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0xc6, // #1
0xc1, // #2
@@ -453,7 +453,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x22, // #2 glyph: 0x22 \42
@@ -659,7 +659,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x22, // #2
@@ -862,20 +862,33 @@
0x2d // #199
};
+ /** The singleton instance. */
+ private static EncodingISOLatin1 theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "ISOLatin1Encoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingISOLatin1() {
+ private EncodingISOLatin1() {
super("ISOLatin1Encoding", GlyphList.standardSourceGlyphLists(),
EncodingISOLatin1.CODE_POINTS,
EncodingISOLatin1.CODE_POINT_INDEXES);
}
/**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingISOLatin1 getInstance() {
+ if (EncodingISOLatin1.theInstance == null) {
+ EncodingISOLatin1.theInstance = new EncodingISOLatin1();
+ }
+ return EncodingISOLatin1.theInstance;
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isPredefinedPS() {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacExpert.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -43,9 +43,9 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingMacExpert extends EncodingVector {
+public final class EncodingMacExpert extends EncodingVector {
-/* public static final String[] sortedGlyphNames = {
+/* private static final String[] sortedGlyphNames = {
"AEsmall", // #0 glyph: 0xbe \276
"Aacutesmall", // #1 glyph: 0x87 \207
"Acircumflexsmall", // #2 glyph: 0x89 \211
@@ -213,7 +213,7 @@
"zerosuperior" // #164 glyph: 0xe2 \342
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0xbe, // #0
0x87, // #1
0x89, // #2
@@ -383,7 +383,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x2c, // #1 glyph: 0x2c \54
0x2d, // #2 glyph: 0x2d \55
@@ -554,7 +554,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x2c, // #1
0x2d, // #2
@@ -722,20 +722,33 @@
0x5a // #164
};
+ /** The singleton instance. */
+ private static EncodingMacExpert theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "MacExpertEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingMacExpert() {
+ private EncodingMacExpert() {
super("MacExpertEncoding", GlyphList.standardSourceGlyphLists(),
EncodingMacExpert.CODE_POINTS,
EncodingMacExpert.CODE_POINT_INDEXES);
}
/**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingMacExpert getInstance() {
+ if (EncodingMacExpert.theInstance == null) {
+ EncodingMacExpert.theInstance = new EncodingMacExpert();
+ }
+ return EncodingMacExpert.theInstance;
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isPredefinedPDF() {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacRoman.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -43,9 +43,9 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingMacRoman extends EncodingVector {
+public final class EncodingMacRoman extends EncodingVector {
-/* public static final String[] sortedGlyphNames = {
+/* private static final String[] sortedGlyphNames = {
"A", // #0 glyph: 0x41 \101
"AE", // #1 glyph: 0xae \256
"Aacute", // #2 glyph: 0xe7 \347
@@ -255,7 +255,7 @@
"zero" // #206 glyph: 0x30 \60
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0xae, // #1
0xe7, // #2
@@ -467,7 +467,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x22, // #2 glyph: 0x22 \42
@@ -680,7 +680,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x22, // #2
@@ -890,20 +890,33 @@
0xdf // #206
};
+ /** The singleton instance. */
+ private static EncodingMacRoman theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "MacRomanEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingMacRoman() {
+ private EncodingMacRoman() {
super("MacRomanEncoding", GlyphList.standardSourceGlyphLists(),
EncodingMacRoman.CODE_POINTS,
EncodingMacRoman.CODE_POINT_INDEXES);
}
/**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingMacRoman getInstance() {
+ if (EncodingMacRoman.theInstance == null) {
+ EncodingMacRoman.theInstance = new EncodingMacRoman();
+ }
+ return EncodingMacRoman.theInstance;
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isPredefinedPDF() {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingMacStandard.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -49,10 +49,10 @@
* <p>Note that the glyphs named ".null" and "nonmarkingreturn" do not map
* to Unicode code points.</p>
*/
-public class EncodingMacStandard extends EncodingVector {
+public final class EncodingMacStandard extends EncodingVector {
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
".notdef", // [0] glyph-index: 0x0000 \000
".null", // [1] glyph-index: 0x0001 \001
"A", // [2] glyph-index: 0x0024 \044
@@ -313,7 +313,7 @@
"zero" // [257] glyph-index: 0x0013 \023
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x0000, // [0] \000 .notdef
0x0001, // [1] \001 .null
0x0024, // [2] \044 A
@@ -576,7 +576,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x0000, // [0] glyph: 0x0000 \0000
0x0000, // [1] glyph: 0x0000 \0000
0x0000, // [2] glyph: 0x0000 \0000
@@ -840,7 +840,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x0000, // [0]
0x0000, // [1]
0x0000, // [2]
@@ -1101,17 +1101,30 @@
0x00c1 // [257]
};
+ /** The singleton instance. */
+ private static EncodingMacStandard theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "MacStandardEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- EncodingMacStandard() {
+ private EncodingMacStandard() {
super(STANDARD_MACINTOSH_ORDERING, GlyphList.standardSourceGlyphLists(),
EncodingMacStandard.CODE_POINTS,
EncodingMacStandard.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingMacStandard getInstance() {
+ if (EncodingMacStandard.theInstance == null) {
+ EncodingMacStandard.theInstance = new EncodingMacStandard();
+ }
+ return EncodingMacStandard.theInstance;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingPDFDoc.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -43,9 +43,9 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingPDFDoc extends EncodingVector {
+public final class EncodingPDFDoc extends EncodingVector {
-/* public static final String[] sortedGlyphNames = {
+/* private static final String[] sortedGlyphNames = {
"A", // #0 glyph: 0x41 \101
"AE", // #1 glyph: 0xc6 \306
"Aacute", // #2 glyph: 0xc1 \301
@@ -277,7 +277,7 @@
"zero" // #228 glyph: 0x30 \60
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0xc6, // #1
0xc1, // #2
@@ -511,7 +511,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x22, // #2 glyph: 0x22 \42
@@ -746,7 +746,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x22, // #2
@@ -978,20 +978,33 @@
0x94 // #228
};
+ /** The singleton instance. */
+ private static EncodingPDFDoc theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "PDFDocEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingPDFDoc() {
+ private EncodingPDFDoc() {
super("PDFDocEncoding", GlyphList.standardSourceGlyphLists(),
EncodingPDFDoc.CODE_POINTS,
EncodingPDFDoc.CODE_POINT_INDEXES);
}
/**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingPDFDoc getInstance() {
+ if (EncodingPDFDoc.theInstance == null) {
+ EncodingPDFDoc.theInstance = new EncodingPDFDoc();
+ }
+ return EncodingPDFDoc.theInstance;
+ }
+
+ /**
* {@inheritDoc}
*/
public org.axsl.psR.EncodingVector bestBaseEncodingPDF() {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingStandard.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -45,10 +45,10 @@
* </ol>
*
*/
-public class EncodingStandard extends EncodingVector {
+public final class EncodingStandard extends EncodingVector {
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
"A", // #0 glyph: 0x41 \101
"AE", // #1 glyph: 0xe1 \341
"B", // #2 glyph: 0x42 \102
@@ -200,7 +200,7 @@
"zero" // #148 glyph: 0x30 \60
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0xe1, // #1
0x42, // #2
@@ -354,7 +354,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x22, // #2 glyph: 0x22 \42
@@ -509,7 +509,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x22, // #2
@@ -661,20 +661,33 @@
0xaf // #148
};
+ /** The singleton instance. */
+ private static EncodingStandard theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "StandardEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingStandard() {
+ private EncodingStandard() {
super("StandardEncoding", GlyphList.standardSourceGlyphLists(),
EncodingStandard.CODE_POINTS,
EncodingStandard.CODE_POINT_INDEXES);
}
/**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingStandard getInstance() {
+ if (EncodingStandard.theInstance == null) {
+ EncodingStandard.theInstance = new EncodingStandard();
+ }
+ return EncodingStandard.theInstance;
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isPredefinedPS() {
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingSymbol.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -51,9 +51,9 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingSymbol extends EncodingVector {
+public final class EncodingSymbol extends EncodingVector {
-/* public static final String[] sortedGlyphNames = {
+/* private static final String[] sortedGlyphNames = {
"Alpha", // #0 glyph: 0x41 \101
"Beta", // #1 glyph: 0x42 \102
"Chi", // #2 glyph: 0x43 \103
@@ -245,7 +245,7 @@
"zeta" // #188 glyph: 0x7a \172
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0x42, // #1
0x43, // #2
@@ -439,7 +439,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x23, // #2 glyph: 0x23 \43
@@ -634,7 +634,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x23, // #2
@@ -826,17 +826,30 @@
0xfe // #188
};
+ /** The singleton instance. */
+ private static EncodingSymbol theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "SymbolEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingSymbol() {
+ private EncodingSymbol() {
super("SymbolEncoding", GlyphList.standardSourceGlyphLists(),
EncodingSymbol.CODE_POINTS,
EncodingSymbol.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingSymbol getInstance() {
+ if (EncodingSymbol.theInstance == null) {
+ EncodingSymbol.theInstance = new EncodingSymbol();
+ }
+ return EncodingSymbol.theInstance;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingVector.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -148,31 +148,31 @@
// Otherwise, try to instantiate it.
if (name.equals("AdobeStandardEncoding")
|| name.equals("StandardEncoding")) {
- encoding = new EncodingStandard();
+ encoding = EncodingStandard.getInstance();
} else if (name.equals("ISOLatin1Encoding")) {
- encoding = new EncodingISOLatin1();
+ encoding = EncodingISOLatin1.getInstance();
} else if (name.equals("WinAnsiEncoding")) {
- encoding = new EncodingWinAnsi();
+ encoding = EncodingWinAnsi.getInstance();
} else if (name.equals("SymbolEncoding")) {
- encoding = new EncodingSymbol();
+ encoding = EncodingSymbol.getInstance();
} else if (name.equals("ZapfDingbatsEncoding")) {
- encoding = new EncodingZapfDingbats();
+ encoding = EncodingZapfDingbats.getInstance();
} else if (name.equals("CEEncoding")) {
- encoding = new EncodingCE();
+ encoding = EncodingCE.getInstance();
} else if (name.equals("MacRomanEncoding")) {
- encoding = new EncodingMacRoman();
+ encoding = EncodingMacRoman.getInstance();
} else if (name.equals("PDFDocEncoding")) {
- encoding = new EncodingPDFDoc();
+ encoding = EncodingPDFDoc.getInstance();
} else if (name.equals("MacExpertEncoding")) {
- encoding = new EncodingMacExpert();
+ encoding = EncodingMacExpert.getInstance();
} else if (name.equals("ExpertEncoding")) {
- encoding = new EncodingExpert();
+ encoding = EncodingExpert.getInstance();
} else if (name.equals("ExpertSubsetEncoding")) {
- encoding = new EncodingExpertSubset();
+ encoding = EncodingExpertSubset.getInstance();
} else if (name.equals(EncodingVector.STANDARD_MACINTOSH_ORDERING)) {
- encoding = new EncodingMacStandard();
+ encoding = EncodingMacStandard.getInstance();
} else if (name.equals("FOrayLatinExtraEncoding")) {
- encoding = new EncodingFOrayLatinExtra();
+ encoding = EncodingFOrayLatinExtra.getInstance();
} else if (name.equals("InternalEncoding")) {
/* The statement below is a bit redundant, but is included to
* document the fact that "InternalEncoding" is reserved to
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingWinAnsi.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -43,9 +43,9 @@
* <li>glyph-lists: [null]</li>
* </ol>
*/
-public class EncodingWinAnsi extends EncodingVector {
+public final class EncodingWinAnsi extends EncodingVector {
-/* public static final String[] sortedGlyphNames = {
+/* private static final String[] sortedGlyphNames = {
"A", // #0 glyph: 0x41 \101
"AE", // #1 glyph: 0xc6 \306
"Aacute", // #2 glyph: 0xc1 \301
@@ -264,7 +264,7 @@
"zero" // #215 glyph: 0x30 \60
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x41, // #0
0xc6, // #1
0xc1, // #2
@@ -485,7 +485,7 @@
*/
/** The Unicode codepoints encoded in this encoding. */
- public static final char[] CODE_POINTS = {
+ private static final char[] CODE_POINTS = {
0x20, // #0 glyph: 0x20 \40
0x21, // #1 glyph: 0x21 \41
0x22, // #2 glyph: 0x22 \42
@@ -707,7 +707,7 @@
/** The array of encoded indexes that is parallel to {@link #CODE_POINTS}.
* For the codepoint found at {@link #CODE_POINTS}[n], the encoded value
* for that codepoint is found at {@link #CODE_POINT_INDEXES}[n]. */
- public static final char[] CODE_POINT_INDEXES = {
+ private static final char[] CODE_POINT_INDEXES = {
0x20, // #0
0x21, // #1
0x22, // #2
@@ -926,24 +926,49 @@
0x99 // #215
};
+ /** The singleton instance. */
+ private static EncodingWinAnsi theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "WinAnsiEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingWinAnsi() {
+ private EncodingWinAnsi() {
super("WinAnsiEncoding", GlyphList.standardSourceGlyphLists(),
EncodingWinAnsi.CODE_POINTS,
EncodingWinAnsi.CODE_POINT_INDEXES);
}
/**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingWinAnsi getInstance() {
+ if (EncodingWinAnsi.theInstance == null) {
+ EncodingWinAnsi.theInstance = new EncodingWinAnsi();
+ }
+ return EncodingWinAnsi.theInstance;
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isPredefinedPDF() {
return true;
}
+ /**
+ * Method allowing the ANSI character set to use the same char array as
+ * this encoding.
+ * @return The character set used by this encoding.
+ */
+ public static char[] getCodePoints() {
+ /* TODO: Remove this method and instead add a constructor to
+ * org.foray.font.charset.CharSet that takes an Encoding or
+ * EncodingVector as its parameter. */
+ return EncodingWinAnsi.CODE_POINTS;
+ }
+
}
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2007-04-28 20:05:13 UTC (rev 9285)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/encode/EncodingZapfDingbats.java 2007-04-28 20:53:54 UTC (rev 9286)
@@ -49,7 +49,7 @@
* <li>glyph-lists: ZapfDingbats</li>
* </ol>
*/
-public class EncodingZapfDingbats extends EncodingVector {
+public final class EncodingZapfDingbats extends EncodingVector {
/** The array of glyph lists that should be used to map glyph names to
* Unicode code points for this font. */
@@ -60,7 +60,7 @@
};
/*
- public static final String[] sortedGlyphNames = {
+ private static final String[] sortedGlyphNames = {
"a1", // [0] glyph-index: 0x0021 \041
"a10", // [1] glyph-index: 0x0041 \101
"a100", // [2] glyph-index: 0x007e \176
@@ -265,7 +265,7 @@
"space" // [201] glyph-index: 0x0020 \040
};
- public static final short[] glyphIndexes = {
+ private static final short[] glyphIndexes = {
0x0021, // [0] \041 a1
0x0041, // [1] \101 a10
0x007e, // [2] \176 a100
@@ -885,17 +885,30 @@
0x00fe // [201]
};
+ /** The singleton instance. */
+ private static EncodingZapfDingbats theInstance;
+
/**
- * Constructor with package-level visibility.
- * This class should only be instantiated by
- * {@link EncodingVector#getPredefinedEncoding(String)}.
- * To get the singleton instance of this class, pass "ZapfDingbatsEncoding"
- * to {@link EncodingVector#getPredefinedEncoding(String)}
+ * Private Constructor. This class is a singleton and should be instantiated
+ * only internally.
+ * To obtain the singleton instance of this class, use
+ * {@link #getInstance()}.
*/
- public EncodingZapfDingbats() {
+ private EncodingZapfDingbats() {
super("ZapfDingbatsEncoding", EncodingZapfDingbats.GLYPH_LISTS_USED,
EncodingZapfDingbats.CODE_POINTS,
EncodingZapfDingbats.CODE_POINT_INDEXES);
}
+ /**
+ * Returns the singleton instance of this class.
+ * @return The singleton isntance of this class.
+ */
+ public static EncodingZapfDingbats getInstance() {
+ if (EncodingZapfDingbats.theInstance == null) {
+ EncodingZapfDingbats.theInstance = new EncodingZapfDingbats();
+ }
+ return EncodingZapfDingbats.theInstance;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|