jdk/make/src/classes/build/tools/generatecharacter/CharacterScript.java
author vromero
Thu, 31 Mar 2016 17:25:58 -0400
changeset 36776 5e260fa5208a
parent 21805 c7d7946239de
permissions -rw-r--r--
8150733: NPE when compiling module-info.java with a class declaration in a non-module mode Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12317
9670c1610c53 7074397: Build infrastructure changes (makefile re-write)
ohair
parents: 5610
diff changeset
     1
package build.tools.generatecharacter;
9670c1610c53 7074397: Build infrastructure changes (makefile re-write)
ohair
parents: 5610
diff changeset
     2
5610
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     3
import java.util.regex.*;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     4
import java.util.*;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     5
import java.io.*;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     6
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     7
public class CharacterScript {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     8
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
     9
    // generate the code needed for j.l.C.UnicodeScript
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    10
    static void fortest(String fmt, Object... o) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    11
        //System.out.printf(fmt, o);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    12
    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    13
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    14
    static void print(String fmt, Object... o) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    15
        System.out.printf(fmt, o);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    16
    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    17
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    18
    static void debug(String fmt, Object... o) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    19
        //System.out.printf(fmt, o);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    20
    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    21
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    22
    public static void main(String args[]){
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    23
        try {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    24
            if (args.length != 1) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    25
                System.out.println("java CharacterScript script.txt out");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    26
                System.exit(1);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    27
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    28
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    29
            int i, j;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    30
            BufferedReader sbfr = new BufferedReader(new FileReader(args[0]));
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    31
            HashMap<String,Integer> scriptMap = new HashMap<String,Integer>();
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    32
            String line = null;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    33
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    34
            Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s+;\\s+(\\w+)\\s+#.*").matcher("");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    35
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    36
            int prevS = -1;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    37
            int prevE = -1;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    38
            String prevN = null;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    39
            int[][] scripts = new int[1024][3];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    40
            int scriptSize = 0;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    41
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    42
            while ((line = sbfr.readLine()) != null) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    43
                if (line.length() <= 1 || line.charAt(0) == '#') {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    44
                    continue;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    45
                }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    46
                m.reset(line);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    47
                if (m.matches()) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    48
                    int start = Integer.parseInt(m.group(1), 16);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    49
                    int end = (m.group(2)==null)?start
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    50
                              :Integer.parseInt(m.group(2), 16);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    51
                    String name = m.group(3);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    52
                    if (name.equals(prevN) && start == prevE + 1) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    53
                        prevE = end;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    54
                    } else {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    55
                        if (prevS != -1) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    56
                            if (scriptMap.get(prevN) == null) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    57
                                scriptMap.put(prevN, scriptMap.size());
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    58
                            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    59
                            scripts[scriptSize][0] = prevS;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    60
                            scripts[scriptSize][1] = prevE;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    61
                            scripts[scriptSize][2] = scriptMap.get(prevN);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    62
                            scriptSize++;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    63
                        }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    64
                        debug("%x-%x\t%s%n", prevS, prevE, prevN);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    65
                        prevS = start; prevE = end; prevN = name;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    66
                    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    67
                } else {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    68
                    debug("Warning: Unrecognized line <%s>%n", line);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    69
                }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    70
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    71
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    72
            //last one.
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    73
            if (scriptMap.get(prevN) == null) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    74
                scriptMap.put(prevN, scriptMap.size());
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    75
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    76
            scripts[scriptSize][0] = prevS;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    77
            scripts[scriptSize][1] = prevE;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    78
            scripts[scriptSize][2] = scriptMap.get(prevN);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    79
            scriptSize++;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    80
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    81
            debug("%x-%x\t%s%n", prevS, prevE, prevN);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    82
            debug("-----------------%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    83
            debug("Total scripts=%s%n", scriptMap.size());
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    84
            debug("-----------------%n%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    85
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    86
            String[] names = new String[scriptMap.size()];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    87
            for (String name: scriptMap.keySet()) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    88
                names[scriptMap.get(name).intValue()] = name;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    89
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    90
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    91
            for (j = 0; j < scriptSize; j++) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    92
                for (int cp = scripts[j][0]; cp <= scripts[j][1]; cp++) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    93
                    String name = names[scripts[j][2]].toUpperCase(Locale.ENGLISH);;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    94
                    if (cp > 0xffff)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    95
                        System.out.printf("%05X    %s%n", cp, name);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    96
                    else
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    97
                        System.out.printf("%05X    %s%n", cp, name);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    98
                }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
    99
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   100
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   101
            Arrays.sort(scripts, 0, scriptSize,
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   102
                        new Comparator<int[]>() {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   103
                            public int compare(int[] a1, int[] a2) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   104
                                return a1[0] - a2[0];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   105
                            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   106
                            public boolean compare(Object obj) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   107
                                return obj == this;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   108
                            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   109
                         });
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   110
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   111
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   112
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   113
            // Consolidation: there are lots of "reserved" code points
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   114
            // embedded in those otherwise "sequential" blocks.
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   115
            // To make the lookup table smaller, we combine those
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   116
            // separated segments with the assumption that the lookup
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   117
            // implementation checks
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   118
            //    Character.getType() !=  Character.UNASSIGNED
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   119
            // first (return UNKNOWN for unassigned)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   120
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   121
            ArrayList<int[]> list = new ArrayList();
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   122
            list.add(scripts[0]);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   123
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   124
            int[] last = scripts[0];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   125
            for (i = 1; i < scriptSize; i++) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   126
                if (scripts[i][0] != (last[1] + 1)) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   127
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   128
                    boolean isNotUnassigned = false;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   129
                    for (int cp = last[1] + 1; cp < scripts[i][0]; cp++) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   130
                        if (Character.getType(cp) != Character.UNASSIGNED) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   131
                            isNotUnassigned = true;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   132
                            debug("Warning: [%x] is ASSIGNED but in NON script%n", cp);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   133
                            break;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   134
                        }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   135
                    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   136
                    if (isNotUnassigned) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   137
                        // surrogates only?
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   138
                        int[] a = new int[3];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   139
                        a[0] = last[1] + 1;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   140
                        a[1] = scripts[i][0] - 1;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   141
                        a[2] = -1;  // unknown
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   142
                        list.add(a);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   143
                    } else {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   144
                        if (last[2] == scripts[i][2]) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   145
                            //combine
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   146
                            last[1] = scripts[i][1];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   147
                            continue;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   148
                        } else {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   149
                            // expand last
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   150
                            last[1] = scripts[i][0] - 1;
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   151
                        }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   152
                    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   153
                }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   154
                list.add(scripts[i]);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   155
                last = scripts[i];
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   156
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   157
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   158
            for (i = 0; i < list.size(); i++) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   159
                int[] a = (int[])list.get(i);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   160
                String name = "UNKNOWN";
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   161
                if (a[2] != -1)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   162
                    name = names[a[2]].toUpperCase(Locale.US);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   163
                debug("0x%05x, 0x%05x  %s%n", a[0], a[1], name);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   164
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   165
            debug("--->total=%d%n", list.size());
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   166
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   167
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   168
            //////////////////OUTPUT//////////////////////////////////
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   169
            print("public class Scripts {%n%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   170
            print("    public static enum UnicodeScript {%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   171
            for (i = 0; i < names.length; i++) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   172
                print("        /**%n         * Unicode script \"%s\".%n         */%n", names[i]);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   173
                print("        %s,%n%n",  names[i].toUpperCase(Locale.US));
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   174
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   175
            print("        /**%n         * Unicode script \"Unknown\".%n         */%n        UNKNOWN;%n%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   176
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   177
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   178
            // lookup table
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   179
            print("        private static final int[] scriptStarts = {%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   180
            for (int[] a : list) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   181
                String name = "UNKNOWN";
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   182
                if (a[2] != -1)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   183
                    name = names[a[2]].toUpperCase(Locale.US);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   184
                if (a[0] < 0x10000)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   185
                    print("            0x%04X,   // %04X..%04X; %s%n",
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   186
                          a[0], a[0], a[1], name);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   187
                else
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   188
                    print("            0x%05X,  // %05X..%05X; %s%n",
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   189
                          a[0], a[0], a[1], name);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   190
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   191
            last = list.get(list.size() -1);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   192
            if (last[1] != Character.MAX_CODE_POINT)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   193
                print("            0x%05X   // %05X..%06X; %s%n",
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   194
                      last[1] + 1, last[1] + 1, Character.MAX_CODE_POINT,
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   195
                      "UNKNOWN");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   196
            print("%n        };%n%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   197
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   198
            print("        private static final UnicodeScript[] scripts = {%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   199
            for (int[] a : list) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   200
                String name = "UNKNOWN";
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   201
                if (a[2] != -1)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   202
                    name = names[a[2]].toUpperCase(Locale.US);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   203
                print("            %s,%n", name);
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   204
            }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   205
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   206
            if (last[1] != Character.MAX_CODE_POINT)
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   207
                print("            UNKNOWN%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   208
            print("        };%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   209
            print("    }%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   210
            print("}%n");
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   211
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   212
        } catch (Exception e) {
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   213
            e.printStackTrace();
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   214
        }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   215
    }
fd2427610c7f 6945564: Unicode script support in Character class
sherman
parents:
diff changeset
   216
}