< prev index next >

make/jdk/src/classes/build/tools/charsetmapping/Main.java

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package build.tools.charsetmapping;
  27 
  28 import java.io.*;
  29 import java.util.ArrayList;
  30 import java.util.Scanner;
  31 import java.util.LinkedHashMap;
  32 import java.util.Locale;

  33 
  34 public class Main {
  35 
  36     public static void main(String args[]) throws Throwable {
  37         int SRC_DIR  = 0;
  38         int DST_DIR  = 1;
  39         int TYPE     = 2;
  40         int CHARSETS = 3;
  41         int OS       = 4;
  42         int TEMPLATE = 5;
  43         int EXT_SRC  = 6;
  44         int COPYRIGHT_SRC  = 7;
  45 
  46         if (args.length < 3 ) {
  47             System.out.println("Usage: java -jar charsetmapping.jar src dst spiType charsets os [template]");
  48             System.exit(1);
  49         }
  50         boolean isStandard = "stdcs".equals(args[TYPE]);
  51         boolean isExtended = "extcs".equals(args[TYPE]);
  52         if (isStandard || isExtended) {


 182                     case "hisname":
 183                         cs.hisName = tokens[2];
 184                         break;
 185                     case "ascii":
 186                         cs.isASCII = Boolean.parseBoolean(tokens[2]);
 187                         break;
 188                     case "minmax":
 189                         cs.b1Min = toInteger(tokens[2]);
 190                         cs.b1Max = toInteger(tokens[3]);
 191                         cs.b2Min = toInteger(tokens[4]);
 192                         cs.b2Max = toInteger(tokens[5]);
 193                         break;
 194                     case "internal":
 195                         cs.isInternal = Boolean.parseBoolean(tokens[2]);
 196                         break;
 197                     default:  // ignore
 198                     }
 199                 }
 200             }
 201             if (cs != null) {



























 202                 cs.aliases = names.toArray(new String[names.size()]);
 203                 charsets.put(cs.clzName, cs);
 204             }
 205         }
 206         return charsets;
 207     }
 208 
 209     private static String[] getOSStdCSList(File stdcsos) throws Throwable
 210     {
 211         ArrayList<String> names = new ArrayList<>();
 212         if (stdcsos.exists()) {
 213             try (Scanner s = new Scanner(stdcsos)) {
 214                 while (s.hasNextLine()) {
 215                     String line = s.nextLine();
 216                     int i = line.indexOf('#');
 217                     if (i != -1) {
 218                         line = line.substring(0, i);
 219                     }
 220                     line = line.trim();
 221                     if (line.length() != 0) {


  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package build.tools.charsetmapping;
  27 
  28 import java.io.*;
  29 import java.util.ArrayList;
  30 import java.util.Scanner;
  31 import java.util.LinkedHashMap;
  32 import java.util.Locale;
  33 import java.util.Arrays;
  34 
  35 public class Main {
  36 
  37     public static void main(String args[]) throws Throwable {
  38         int SRC_DIR  = 0;
  39         int DST_DIR  = 1;
  40         int TYPE     = 2;
  41         int CHARSETS = 3;
  42         int OS       = 4;
  43         int TEMPLATE = 5;
  44         int EXT_SRC  = 6;
  45         int COPYRIGHT_SRC  = 7;
  46 
  47         if (args.length < 3 ) {
  48             System.out.println("Usage: java -jar charsetmapping.jar src dst spiType charsets os [template]");
  49             System.exit(1);
  50         }
  51         boolean isStandard = "stdcs".equals(args[TYPE]);
  52         boolean isExtended = "extcs".equals(args[TYPE]);
  53         if (isStandard || isExtended) {


 183                     case "hisname":
 184                         cs.hisName = tokens[2];
 185                         break;
 186                     case "ascii":
 187                         cs.isASCII = Boolean.parseBoolean(tokens[2]);
 188                         break;
 189                     case "minmax":
 190                         cs.b1Min = toInteger(tokens[2]);
 191                         cs.b1Max = toInteger(tokens[3]);
 192                         cs.b2Min = toInteger(tokens[4]);
 193                         cs.b2Max = toInteger(tokens[5]);
 194                         break;
 195                     case "internal":
 196                         cs.isInternal = Boolean.parseBoolean(tokens[2]);
 197                         break;
 198                     default:  // ignore
 199                     }
 200                 }
 201             }
 202             if (cs != null) {
 203                 cs.aliases = names.toArray(new String[names.size()]);
 204                 charsets.put(cs.clzName, cs);
 205             }
 206         }
 207         if ("AIX".equals(System.getProperty("os.name"))) {
 208             {
 209                 Charset cs = new Charset();
 210                 cs.csName = "x-IBM29626C";
 211                 cs.clzName = "IBM29626C";
 212                 ArrayList<String> names = new ArrayList<>();
 213                 names.add("cp29626c");
 214                 names.add("ibm29626c");
 215                 names.add("ibm-29626c");
 216                 names.add("29626c");
 217                 names.add("ibm-eucjp");
 218                 cs.pkgName = "sun.nio.cs";
 219                 cs.type = "template";
 220                 cs.hisName = "Cp29626C";
 221                 cs.aliases = names.toArray(new String[names.size()]);
 222                 charsets.put(cs.clzName, cs);
 223             }
 224             {
 225                 Charset cs = charsets.get("IBM964");
 226                 ArrayList<String> names = new ArrayList<>();
 227                 for(String s : cs.aliases) 
 228                     names.add(s);
 229                 names.add("ibm-euctw");
 230                 cs.aliases = names.toArray(new String[names.size()]);
 231                 charsets.put(cs.clzName, cs);
 232             }
 233         }
 234         return charsets;
 235     }
 236 
 237     private static String[] getOSStdCSList(File stdcsos) throws Throwable
 238     {
 239         ArrayList<String> names = new ArrayList<>();
 240         if (stdcsos.exists()) {
 241             try (Scanner s = new Scanner(stdcsos)) {
 242                 while (s.hasNextLine()) {
 243                     String line = s.nextLine();
 244                     int i = line.indexOf('#');
 245                     if (i != -1) {
 246                         line = line.substring(0, i);
 247                     }
 248                     line = line.trim();
 249                     if (line.length() != 0) {
< prev index next >