28 import java.io.DataInputStream;
29 import java.io.InputStream;
30 import java.lang.ref.SoftReference;
31 import java.util.Arrays;
32 import java.util.zip.InflaterInputStream;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35
36 class CharacterName {
37
38 private static SoftReference<byte[]> refStrPool;
39 private static int[][] lookup;
40
41 private static synchronized byte[] initNamePool() {
42 byte[] strPool = null;
43 if (refStrPool != null && (strPool = refStrPool.get()) != null)
44 return strPool;
45 DataInputStream dis = null;
46 try {
47 dis = new DataInputStream(new InflaterInputStream(
48 AccessController.doPrivileged(new PrivilegedAction<InputStream>()
49 {
50 public InputStream run() {
51 return getClass().getResourceAsStream("uniName.dat");
52 }
53 })));
54
55 lookup = new int[(Character.MAX_CODE_POINT + 1) >> 8][];
56 int total = dis.readInt();
57 int cpEnd = dis.readInt();
58 byte ba[] = new byte[cpEnd];
59 dis.readFully(ba);
60
61 int nameOff = 0;
62 int cpOff = 0;
63 int cp = 0;
64 do {
65 int len = ba[cpOff++] & 0xff;
66 if (len == 0) {
67 len = ba[cpOff++] & 0xff;
68 // always big-endian
|
28 import java.io.DataInputStream;
29 import java.io.InputStream;
30 import java.lang.ref.SoftReference;
31 import java.util.Arrays;
32 import java.util.zip.InflaterInputStream;
33 import java.security.AccessController;
34 import java.security.PrivilegedAction;
35
36 class CharacterName {
37
38 private static SoftReference<byte[]> refStrPool;
39 private static int[][] lookup;
40
41 private static synchronized byte[] initNamePool() {
42 byte[] strPool = null;
43 if (refStrPool != null && (strPool = refStrPool.get()) != null)
44 return strPool;
45 DataInputStream dis = null;
46 try {
47 dis = new DataInputStream(new InflaterInputStream(
48 AccessController.doPrivileged(new PrivilegedAction<>()
49 {
50 public InputStream run() {
51 return getClass().getResourceAsStream("uniName.dat");
52 }
53 })));
54
55 lookup = new int[(Character.MAX_CODE_POINT + 1) >> 8][];
56 int total = dis.readInt();
57 int cpEnd = dis.readInt();
58 byte ba[] = new byte[cpEnd];
59 dis.readFully(ba);
60
61 int nameOff = 0;
62 int cpOff = 0;
63 int cp = 0;
64 do {
65 int len = ba[cpOff++] & 0xff;
66 if (len == 0) {
67 len = ba[cpOff++] & 0xff;
68 // always big-endian
|