< prev index next >

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

Print this page




  36     public static void genClass(String type,
  37                                 LinkedHashMap<String, Charset> charsets,
  38                                 String srcDir, String dstDir, String template,
  39                                 String os)
  40         throws Exception
  41     {
  42         try (Scanner s = new Scanner(new File(template));
  43              PrintStream out = new PrintStream(new FileOutputStream(
  44                  new File(dstDir, new File(
  45                      template.replace(".template", "")).getName()))); ) {
  46             if (type.startsWith("extcs")) {           // ExtendedCharsets.java
  47                 while (s.hasNextLine()) {
  48                     String line = s.nextLine();
  49                     if (line.indexOf("_CHARSETS_DEF_LIST_") == -1) {
  50                         out.println(line);
  51                     } else {
  52                         charsets.values()
  53                                 .stream()
  54                                 .filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
  55                                               !cs.isInternal &&
  56                                               (cs.os == null || cs.os.equals(os)))
  57                                 .forEach( cs -> {
  58                             out.printf("        charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
  59                             out.printf("                new String[] {%n");
  60                             for (String alias : cs.aliases) {
  61                                 out.printf("                    \"%s\",%n", alias);
  62                             }
  63                             out.printf("                });%n%n");
  64                         });
  65                     }
  66                 }
  67             } else if (type.startsWith("stdcs")) {    // StandardCharsets.java
  68                  ArrayList<String> aliasKeys = new ArrayList<>();
  69                  ArrayList<String> aliasValues = new ArrayList<>();
  70                  ArrayList<String> clzKeys = new ArrayList<>();
  71                  ArrayList<String> clzValues = new ArrayList<>();
  72                  charsets.values()
  73                          .stream()
  74                          .filter(cs -> cs.pkgName.equals("sun.nio.cs") &&
  75                                        !cs.isInternal)
  76                          .forEach( cs -> {




  36     public static void genClass(String type,
  37                                 LinkedHashMap<String, Charset> charsets,
  38                                 String srcDir, String dstDir, String template,
  39                                 String os)
  40         throws Exception
  41     {
  42         try (Scanner s = new Scanner(new File(template));
  43              PrintStream out = new PrintStream(new FileOutputStream(
  44                  new File(dstDir, new File(
  45                      template.replace(".template", "")).getName()))); ) {
  46             if (type.startsWith("extcs")) {           // ExtendedCharsets.java
  47                 while (s.hasNextLine()) {
  48                     String line = s.nextLine();
  49                     if (line.indexOf("_CHARSETS_DEF_LIST_") == -1) {
  50                         out.println(line);
  51                     } else {
  52                         charsets.values()
  53                                 .stream()
  54                                 .filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
  55                                               !cs.isInternal &&
  56                                               cs.os == null)
  57                                 .forEach( cs -> {
  58                             out.printf("        charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
  59                             out.printf("                new String[] {%n");
  60                             for (String alias : cs.aliases) {
  61                                 out.printf("                    \"%s\",%n", alias);
  62                             }
  63                             out.printf("                });%n%n");
  64                         });
  65                     }
  66                 }
  67             } else if (type.startsWith("stdcs")) {    // StandardCharsets.java
  68                  ArrayList<String> aliasKeys = new ArrayList<>();
  69                  ArrayList<String> aliasValues = new ArrayList<>();
  70                  ArrayList<String> clzKeys = new ArrayList<>();
  71                  ArrayList<String> clzValues = new ArrayList<>();
  72                  charsets.values()
  73                          .stream()
  74                          .filter(cs -> cs.pkgName.equals("sun.nio.cs") &&
  75                                        !cs.isInternal)
  76                          .forEach( cs -> {


< prev index next >