author | vadim |
Fri, 13 May 2016 11:31:05 +0300 | |
changeset 38415 | acea5f7d354b |
parent 23067 | 7b20ffccad89 |
permissions | -rw-r--r-- |
2306
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
1 |
/* |
5555 | 2 |
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. |
2306
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
4 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5555 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2306
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5555 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2306
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
10 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
15 |
* accompanied this code). |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
16 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
20 |
* |
5555 | 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. |
|
2306
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
24 |
*/ |
23067 | 25 |
package build.tools.logutil; |
2306
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
26 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
27 |
import java.io.File; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
28 |
import java.io.FileNotFoundException; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
29 |
import java.io.FileOutputStream; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
30 |
import java.io.IOException; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
31 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
32 |
import java.util.Arrays; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
33 |
import java.util.Date; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
34 |
import java.util.Formatter; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
35 |
import java.util.List; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
36 |
import java.util.Queue; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
37 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
38 |
public class MC { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
39 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
40 |
private static final String VERSION = "1.0"; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
41 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
42 |
private static final List<String> SUN_EXCEPTION_GROUPS = Arrays.asList(new String[] |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
43 |
{ "SUNBASE", "ORBUTIL", "ACTIVATION", "NAMING", "INTERCEPTORS", "POA", "IOR", "UTIL" }); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
44 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
45 |
private static final List<String> EXCEPTIONS = Arrays.asList(new String[] |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
46 |
{ "UNKNOWN", "BAD_PARAM", "NO_MEMORY", "IMP_LIMIT", "COMM_FAILURE", "INV_OBJREF", "NO_PERMISSION", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
47 |
"INTERNAL", "MARSHAL", "INITIALIZE", "NO_IMPLEMENT", "BAD_TYPECODE", "BAD_OPERATION", "NO_RESOURCES", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
48 |
"NO_RESPONSE", "PERSIST_STORE", "BAD_INV_ORDER", "TRANSIENT", "FREE_MEM", "INV_IDENT", "INV_FLAG", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
49 |
"INTF_REPOS", "BAD_CONTEXT", "OBJ_ADAPTER", "DATA_CONVERSION", "OBJECT_NOT_EXIST", "TRANSACTION_REQUIRED", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
50 |
"TRANSACTION_ROLLEDBACK", "INVALID_TRANSACTION", "INV_POLICY", "CODESET_INCOMPATIBLE", "REBIND", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
51 |
"TIMEOUT", "TRANSACTION_UNAVAILABLE", "BAD_QOS", "INVALID_ACTIVITY", "ACTIVITY_COMPLETED", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
52 |
"ACTIVITY_REQUIRED" }); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
53 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
54 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
55 |
* Read the minor codes from the input file and |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
56 |
* write out a resource file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
57 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
58 |
* @param inFile the file to read the codes from. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
59 |
* @param outDir the directory to write the resource file to. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
60 |
* @throws FileNotFoundException if the input file can not be found. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
61 |
* @throws IOException if an I/O error occurs. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
62 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
63 |
private void makeResource(String inFile, String outDir) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
64 |
throws FileNotFoundException, IOException { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
65 |
writeResource(outDir, new Input(inFile)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
66 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
67 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
68 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
69 |
* Create a new Java source file using the specified Scheme input file, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
70 |
* and writing the result to the given output directory. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
71 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
72 |
* @param inFile the file to read the data from. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
73 |
* @param outDir the directory to write the Java class to. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
74 |
* @throws FileNotFoundException if the input file can not be found. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
75 |
* @throws IOException if an I/O error occurs. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
76 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
77 |
private void makeClass(String inFile, String outDir) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
78 |
throws FileNotFoundException, IOException { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
79 |
writeClass(inFile, outDir, new Input(inFile)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
80 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
81 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
82 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
83 |
* Writes out a Java source file using the data from the given |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
84 |
* {@link Input} object. The result is written to {@code outDir}. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
85 |
* The name of the input file is just used in the header of the |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
86 |
* resulting source file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
87 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
88 |
* @param inFile the name of the file the data was read from. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
89 |
* @param outDir the directory to write the Java class to. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
90 |
* @param input the parsed input data. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
91 |
* @throws FileNotFoundException if the output file can't be written. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
92 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
93 |
private void writeClass(String inFile, String outDir, Input input) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
94 |
throws FileNotFoundException { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
95 |
String packageName = input.getPackageName(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
96 |
String className = input.getClassName(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
97 |
String groupName = input.getGroupName(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
98 |
Queue<InputException> exceptions = input.getExceptions(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
99 |
FileOutputStream file = new FileOutputStream(outDir + File.separator + className + ".java"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
100 |
IndentingPrintWriter pw = new IndentingPrintWriter(file); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
101 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
102 |
writeClassHeader(inFile, groupName, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
103 |
pw.printMsg("package @ ;", packageName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
104 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
105 |
pw.println("import java.util.logging.Logger ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
106 |
pw.println("import java.util.logging.Level ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
107 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
108 |
pw.println("import org.omg.CORBA.OMGVMCID ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
109 |
pw.println( "import com.sun.corba.se.impl.util.SUNVMCID ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
110 |
pw.println( "import org.omg.CORBA.CompletionStatus ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
111 |
pw.println( "import org.omg.CORBA.SystemException ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
112 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
113 |
pw.println( "import com.sun.corba.se.spi.orb.ORB ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
114 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
115 |
pw.println( "import com.sun.corba.se.spi.logging.LogWrapperFactory;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
116 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
117 |
pw.println( "import com.sun.corba.se.spi.logging.LogWrapperBase;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
118 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
119 |
writeImports(exceptions, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
120 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
121 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
122 |
pw.printMsg("public class @ extends LogWrapperBase {", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
123 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
124 |
pw.printMsg("public @( Logger logger )", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
125 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
126 |
pw.println( "{"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
127 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
128 |
pw.println( "super( logger ) ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
129 |
pw.println( "}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
130 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
131 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
132 |
writeFactoryMethod(className, groupName, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
133 |
writeExceptions(groupName, exceptions, className, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
134 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
135 |
pw.println( ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
136 |
pw.println( "}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
137 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
138 |
pw.close(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
139 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
140 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
141 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
142 |
* Writes out the header of a Java source file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
143 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
144 |
* @param inFile the input file the file was generated from. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
145 |
* @param groupName the group of exceptions the Java source file is for. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
146 |
* @param pw the print writer used to write the output. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
147 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
148 |
private void writeClassHeader(String inFile, String groupName, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
149 |
IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
150 |
if (groupName.equals("OMG")) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
151 |
pw.println("// Log wrapper class for standard exceptions"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
152 |
else |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
153 |
pw.printMsg("// Log wrapper class for Sun private system exceptions in group @", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
154 |
groupName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
155 |
pw.println("//"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
156 |
pw.printMsg("// Generated by MC.java version @, DO NOT EDIT BY HAND!", VERSION); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
157 |
pw.printMsg("// Generated from input file @ on @", inFile, new Date()); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
158 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
159 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
160 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
161 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
162 |
* Write out the import list for the exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
163 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
164 |
* @param groups the exceptions that were parsed. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
165 |
* @param pw the {@link IndentingPrintWriter} for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
166 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
167 |
private void writeImports(Queue<InputException> exceptions, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
168 |
IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
169 |
if (exceptions == null) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
170 |
return; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
171 |
for (InputException e : exceptions) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
172 |
pw.println("import org.omg.CORBA." + e.getName() + " ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
173 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
174 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
175 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
176 |
* Write out the factory method for this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
177 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
178 |
* @param className the name of the generated class. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
179 |
* @param groupName the name of this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
180 |
* @param pw the {@link IndentingPrintWriter} for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
181 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
182 |
private void writeFactoryMethod(String className, String groupName, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
183 |
IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
184 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
185 |
pw.println( "private static LogWrapperFactory factory = new LogWrapperFactory() {"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
186 |
pw.println( "public LogWrapperBase create( Logger logger )" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
187 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
188 |
pw.println( "{"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
189 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
190 |
pw.printMsg("return new @( logger ) ;", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
191 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
192 |
pw.println( "}" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
193 |
pw.println( "} ;" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
194 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
195 |
pw.printMsg("public static @ get( ORB orb, String logDomain )", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
196 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
197 |
pw.println( "{"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
198 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
199 |
pw.printMsg( "@ wrapper = ", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
200 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
201 |
pw.printMsg( "(@) orb.getLogWrapper( logDomain, ", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
202 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
203 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
204 |
pw.printMsg( "\"@\", factory ) ;", groupName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
205 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
206 |
pw.println( "return wrapper ;" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
207 |
pw.println( "} " ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
208 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
209 |
pw.printMsg( "public static @ get( String logDomain )", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
210 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
211 |
pw.println( "{"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
212 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
213 |
pw.printMsg( "@ wrapper = ", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
214 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
215 |
pw.printMsg( "(@) ORB.staticGetLogWrapper( logDomain, ", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
216 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
217 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
218 |
pw.printMsg( "\"@\", factory ) ;", groupName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
219 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
220 |
pw.println( "return wrapper ;" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
221 |
pw.println( "} " ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
222 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
223 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
224 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
225 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
226 |
* Writes out the exceptions themselves. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
227 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
228 |
* @param groupName the name of this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
229 |
* @param exceptions the exceptions to write out. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
230 |
* @param className the name of the generated class. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
231 |
* @param pw the {@link IndentingPrintWriter} for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
232 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
233 |
private void writeExceptions(String groupName, Queue<InputException> exceptions, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
234 |
String className, IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
235 |
for (InputException e : exceptions) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
236 |
pw.println("///////////////////////////////////////////////////////////"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
237 |
pw.printMsg("// @", e.getName()); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
238 |
pw.println("///////////////////////////////////////////////////////////"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
239 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
240 |
for (InputCode c : e.getCodes()) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
241 |
writeMethods(groupName, e.getName(), c.getName(), c.getCode(), |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
242 |
c.getLogLevel(), className, StringUtil.countArgs(c.getMessage()), pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
243 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
244 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
245 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
246 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
247 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
248 |
* Writes out the methods for a particular error. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
249 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
250 |
* @param groupName the name of this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
251 |
* @param exceptionName the name of this particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
252 |
* @param errorName the name of this particular error. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
253 |
* @param code the minor code for this particular error. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
254 |
* @param ident the name of the error in mixed-case identifier form. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
255 |
* @param level the level at which to place log messages. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
256 |
* @param className the name of the class for this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
257 |
* @param numParams the number of parameters the detail message takes. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
258 |
* @param pw the print writer for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
259 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
260 |
private void writeMethods(String groupName, String exceptionName, String errorName, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
261 |
int code, String level, String className, int numParams, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
262 |
IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
263 |
String ident = StringUtil.toMixedCase(errorName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
264 |
pw.printMsg("public static final int @ = @ ;", errorName, getBase(groupName, code)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
265 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
266 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
267 |
writeMethodStatusCause(groupName, exceptionName, errorName, ident, level, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
268 |
numParams, className, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
269 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
270 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
271 |
writeMethodStatus(exceptionName, ident, numParams, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
272 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
273 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
274 |
writeMethodCause(exceptionName, ident, numParams, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
275 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
276 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
277 |
writeMethodNoArgs(exceptionName, ident, numParams, pw); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
278 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
279 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
280 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
281 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
282 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
283 |
* Writes out a method for an error that takes a |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
284 |
* {@link org.omg.CORBA.CompletionStatus} and a cause. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
285 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
286 |
* @param groupName the name of this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
287 |
* @param exceptionName the name of this particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
288 |
* @param errorName the name of this particular error. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
289 |
* @param ident the name of the error in mixed-case identifier form. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
290 |
* @param logLevel the level at which to place log messages. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
291 |
* @param numParams the number of parameters the detail message takes. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
292 |
* @param className the name of the class for this group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
293 |
* @param pw the print writer for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
294 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
295 |
private void writeMethodStatusCause(String groupName, String exceptionName, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
296 |
String errorName, String ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
297 |
String logLevel, int numParams, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
298 |
String className, IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
299 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
300 |
pw.printMsg( "public @ @( CompletionStatus cs, Throwable t@) {", exceptionName, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
301 |
ident, makeDeclArgs(true, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
302 |
pw.printMsg( "@ exc = new @( @, cs ) ;", exceptionName, exceptionName, errorName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
303 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
304 |
pw.println( "if (t != null)" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
305 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
306 |
pw.println( "exc.initCause( t ) ;" ); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
307 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
308 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
309 |
pw.printMsg( "if (logger.isLoggable( Level.@ )) {", logLevel); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
310 |
if (numParams > 0) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
311 |
pw.printMsg( "Object[] parameters = new Object[@] ;", numParams); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
312 |
for (int a = 0; a < numParams; ++a) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
313 |
pw.printMsg("parameters[@] = arg@ ;", a, a); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
314 |
} else |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
315 |
pw.println( "Object[] parameters = null ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
316 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
317 |
pw.printMsg( "doLog( Level.@, \"@.@\",", logLevel, groupName, ident); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
318 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
319 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
320 |
pw.printMsg( "parameters, @.class, exc ) ;", className); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
321 |
pw.println( "}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
322 |
pw.println(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
323 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
324 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
325 |
pw.println( "return exc ;"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
326 |
pw.println( "}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
327 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
328 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
329 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
330 |
* Writes out a method for an error that takes a |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
331 |
* {@link org.omg.CORBA.CompletionStatus}. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
332 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
333 |
* @param exceptionName the name of this particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
334 |
* @param ident the name of the error in mixed-case identifier form. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
335 |
* @param numParams the number of parameters the detail message takes. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
336 |
* @param pw the print writer for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
337 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
338 |
private void writeMethodStatus(String exceptionName, String ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
339 |
int numParams, IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
340 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
341 |
pw.printMsg("public @ @( CompletionStatus cs@) {", exceptionName, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
342 |
ident, makeDeclArgs(true, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
343 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
344 |
pw.printMsg("return @( cs, null@ ) ;", ident, makeCallArgs(true, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
345 |
pw.println("}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
346 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
347 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
348 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
349 |
* Writes out a method for an error that takes a cause. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
350 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
351 |
* @param exceptionName the name of this particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
352 |
* @param ident the name of the error in mixed-case identifier form. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
353 |
* @param numParams the number of parameters the detail message takes. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
354 |
* @param pw the print writer for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
355 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
356 |
private void writeMethodCause(String exceptionName, String ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
357 |
int numParams, IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
358 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
359 |
pw.printMsg("public @ @( Throwable t@) {", exceptionName, ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
360 |
makeDeclArgs(true, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
361 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
362 |
pw.printMsg("return @( CompletionStatus.COMPLETED_NO, t@ ) ;", ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
363 |
makeCallArgs(true, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
364 |
pw.println("}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
365 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
366 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
367 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
368 |
* Writes out a method for an error that takes no arguments. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
369 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
370 |
* @param exceptionName the name of this particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
371 |
* @param ident the name of the error in mixed-case identifier form. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
372 |
* @param numParams the number of parameters the detail message takes. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
373 |
* @param pw the print writer for writing to the file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
374 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
375 |
private void writeMethodNoArgs(String exceptionName, String ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
376 |
int numParams, IndentingPrintWriter pw) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
377 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
378 |
pw.indent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
379 |
pw.printMsg("public @ @( @) {", exceptionName, ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
380 |
makeDeclArgs(false, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
381 |
pw.undent(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
382 |
pw.printMsg("return @( CompletionStatus.COMPLETED_NO, null@ ) ;", |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
383 |
ident, makeCallArgs(true, numParams)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
384 |
pw.println("}"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
385 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
386 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
387 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
388 |
* Returns a list of comma-separated arguments with type declarations. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
389 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
390 |
* @param leadingComma true if the list should start with a comma. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
391 |
* @param numArgs the number of arguments to generate. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
392 |
* @return the generated string. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
393 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
394 |
private String makeDeclArgs(boolean leadingComma, int numArgs) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
395 |
return makeArgString("Object arg", leadingComma, numArgs); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
396 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
397 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
398 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
399 |
* Returns a list of comma-separated arguments without type declarations. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
400 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
401 |
* @param leadingComma true if the list should start with a comma. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
402 |
* @param numArgs the number of arguments to generate. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
403 |
* @return the generated string. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
404 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
405 |
private String makeCallArgs(boolean leadingComma, int numArgs) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
406 |
return makeArgString("arg", leadingComma, numArgs); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
407 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
408 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
409 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
410 |
* Returns a list of comma-separated arguments. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
411 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
412 |
* @param prefixString the string with which to prefix each argument. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
413 |
* @param leadingComma true if the list should start with a comma. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
414 |
* @param numArgs the number of arguments to generate. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
415 |
* @return the generated string. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
416 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
417 |
private String makeArgString(String prefixString, boolean leadingComma, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
418 |
int numArgs) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
419 |
if (numArgs == 0) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
420 |
return " "; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
421 |
if (numArgs == 1) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
422 |
if (leadingComma) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
423 |
return ", " + prefixString + (numArgs - 1); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
424 |
else |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
425 |
return " " + prefixString + (numArgs - 1); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
426 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
427 |
return makeArgString(prefixString, leadingComma, numArgs - 1) + |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
428 |
", " + prefixString + (numArgs - 1); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
429 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
430 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
431 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
432 |
* Returns the {@link String} containing the calculation of the |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
433 |
* error code. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
434 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
435 |
* @param groupName the group of exception to which the code belongs. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
436 |
* @param code the minor code number representing the exception within the group. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
437 |
* @return the unique error code. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
438 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
439 |
private String getBase(String groupName, int code) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
440 |
if (groupName.equals("OMG")) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
441 |
return "OMGVMCID.value + " + code; |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
442 |
else |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
443 |
return "SUNVMCID.value + " + (code + getSunBaseNumber(groupName)); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
444 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
445 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
446 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
447 |
* Returns the base number for Sun-specific exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
448 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
449 |
* @return the base number. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
450 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
451 |
private int getSunBaseNumber(String groupName) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
452 |
return 200 * SUN_EXCEPTION_GROUPS.indexOf(groupName); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
453 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
454 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
455 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
456 |
* Writes out a resource file using the data from the given |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
457 |
* {@link Input} object. The result is written to {@code outDir}. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
458 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
459 |
* @param outDir the directory to write the Java class to. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
460 |
* @param input the parsed input data. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
461 |
* @throws FileNotFoundException if the output file can't be written. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
462 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
463 |
private void writeResource(String outDir, Input input) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
464 |
throws FileNotFoundException { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
465 |
FileOutputStream file = new FileOutputStream(outDir + File.separator + |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
466 |
input.getClassName() + ".resource"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
467 |
IndentingPrintWriter pw = new IndentingPrintWriter(file); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
468 |
String groupName = input.getGroupName(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
469 |
for (InputException e : input.getExceptions()) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
470 |
String exName = e.getName(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
471 |
for (InputCode c : e.getCodes()) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
472 |
String ident = StringUtil.toMixedCase(c.getName()); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
473 |
pw.printMsg("@.@=\"@: (@) @\"", groupName, ident, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
474 |
getMessageID(groupName, exName, c.getCode()), exName, c.getMessage()); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
475 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
476 |
pw.flush(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
477 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
478 |
pw.close(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
479 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
480 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
481 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
482 |
* Returns the message ID corresponding to the given group name, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
483 |
* exception name and error code. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
484 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
485 |
* @param groupName the name of the group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
486 |
* @param exception the name of the particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
487 |
* @param code an error code from the given exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
488 |
* @return the message ID. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
489 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
490 |
private String getMessageID(String groupName, String exceptionName, int code) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
491 |
if (groupName.equals("OMG")) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
492 |
return getStandardMessageID(exceptionName, code); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
493 |
else |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
494 |
return getSunMessageID(groupName, exceptionName, code); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
495 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
496 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
497 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
498 |
* Returns the standard (OMG) message ID corresponding to the given |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
499 |
* exception name and error code. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
500 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
501 |
* @param exceptionName the name of the particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
502 |
* @param code an error code from the given exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
503 |
* @return the message ID. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
504 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
505 |
private String getStandardMessageID(String exceptionName, int code) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
506 |
return new Formatter().format("IOP%s0%04d", getExceptionID(exceptionName), |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
507 |
code).toString(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
508 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
509 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
510 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
511 |
* Returns the Sun message ID corresponding to the given group name, |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
512 |
* exception name and error code. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
513 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
514 |
* @param groupName the name of the group of exceptions. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
515 |
* @param exceptionName the name of the particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
516 |
* @param code an error code from the given exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
517 |
* @return the message ID. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
518 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
519 |
private String getSunMessageID(String groupName, String exceptionName, int code) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
520 |
return new Formatter().format("IOP%s1%04d", getExceptionID(exceptionName), |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
521 |
getSunBaseNumber(groupName) + code).toString(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
522 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
523 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
524 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
525 |
* Returns the exception ID corresponding to the given exception name. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
526 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
527 |
* @param exceptionName the name of the particular exception. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
528 |
* @return the message ID. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
529 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
530 |
private String getExceptionID(String exceptionName) { |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
531 |
return new Formatter().format("%03d", EXCEPTIONS.indexOf(exceptionName)).toString(); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
532 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
533 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
534 |
/** |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
535 |
* Entry point for running the generator from the command |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
536 |
* line. Users can specify either "make-class" or "make-resource" |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
537 |
* as the first argument to generate the specified type of file. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
538 |
* |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
539 |
* @param args the command-line arguments. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
540 |
* @throws FileNotFoundException if the input file can not be found. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
541 |
* @throws IOException if an I/O error occurs. |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
542 |
*/ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
543 |
public static void main(String[] args) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
544 |
throws FileNotFoundException, IOException |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
545 |
{ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
546 |
if (args.length < 3) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
547 |
{ |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
548 |
System.err.println("(make-class|make-resource) <input file> <output dir>"); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
549 |
System.exit(-1); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
550 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
551 |
if (args[0].equals("make-class")) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
552 |
new MC().makeClass(args[1], args[2]); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
553 |
else if (args[0].equals("make-resource")) |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
554 |
new MC().makeResource(args[1], args[2]); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
555 |
else |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
556 |
System.err.println("Invalid command: " + args[0]); |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
557 |
} |
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
558 |
|
70ca22b481e1
6695776: corba jscheme jar files in repository could be built from source
tbell
parents:
diff
changeset
|
559 |
} |