author | lana |
Thu, 11 May 2017 18:11:13 +0000 | |
changeset 45111 | 6aa4e0cafe2e |
parent 28969 | f980bee32887 |
child 47026 | 94c45ad89b9c |
permissions | -rw-r--r-- |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
1 |
/* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
4 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
10 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
15 |
* accompanied this code). |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
16 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
20 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
23 |
* questions. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
24 |
*/ |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
25 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
26 |
package build.tools.charsetmapping; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
27 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
28 |
import java.io.*; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
29 |
import java.util.Scanner; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
30 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
31 |
public class SRC { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
32 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
33 |
public static void genClass(Charset cs, String srcDir, String dstDir) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
34 |
throws Exception |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
35 |
{ |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
36 |
String clzName = cs.clzName; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
37 |
String csName = cs.csName; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
38 |
String pkgName = cs.pkgName; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
39 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
40 |
try (Scanner s = new Scanner(new File(srcDir, clzName + ".java.template")); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
41 |
PrintStream out = new PrintStream(new FileOutputStream( |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
42 |
new File(dstDir, clzName + ".java")));) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
43 |
while (s.hasNextLine()) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
44 |
String line = s.nextLine(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
45 |
if (line.indexOf("$") < 0) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
46 |
out.println(line); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
47 |
continue; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
48 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
49 |
if (line.indexOf("$PACKAGE$") != -1) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
50 |
out.println(line.replace("$PACKAGE$", pkgName)); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
51 |
} else if (line.indexOf("$ALIASES$") != -1) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
52 |
if ("sun.nio.cs".equals(pkgName)) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
53 |
out.println(line.replace("$ALIASES$", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
54 |
"StandardCharsets.aliases_" + clzName)); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
55 |
else |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
56 |
out.println(line.replace("$ALIASES$", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
57 |
"ExtendedCharsets.aliasesFor(\"" + csName + "\")")); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
58 |
} else { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
59 |
out.println(line); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
60 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
61 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
62 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
63 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
64 |
} |