2
|
1 |
/*
|
715
|
2 |
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package build.tools.jdwpgen;
|
|
27 |
|
|
28 |
import java.util.*;
|
|
29 |
import java.io.*;
|
|
30 |
|
|
31 |
class ConstantSetNode extends AbstractNamedNode {
|
|
32 |
|
|
33 |
/**
|
|
34 |
* The mapping between a constant and its value.
|
|
35 |
*/
|
|
36 |
protected static Map<String, String> constantMap;
|
|
37 |
|
|
38 |
ConstantSetNode(){
|
|
39 |
if (constantMap == null) {
|
|
40 |
constantMap = new HashMap<String, String>();
|
|
41 |
}
|
|
42 |
}
|
|
43 |
|
|
44 |
void prune() {
|
|
45 |
List<Node> addons = new ArrayList<Node>();
|
|
46 |
|
|
47 |
for (Iterator it = components.iterator(); it.hasNext(); ) {
|
|
48 |
Node node = (Node)it.next();
|
|
49 |
}
|
|
50 |
if (!addons.isEmpty()) {
|
|
51 |
components.addAll(addons);
|
|
52 |
}
|
|
53 |
super.prune();
|
|
54 |
}
|
|
55 |
|
|
56 |
void constrainComponent(Context ctx, Node node) {
|
|
57 |
if (node instanceof ConstantNode) {
|
|
58 |
node.constrain(ctx);
|
|
59 |
constantMap.put(name + "_" + ((ConstantNode) node).getName(), node.comment());
|
|
60 |
} else {
|
|
61 |
error("Expected 'Constant', got: " + node);
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
void document(PrintWriter writer) {
|
|
66 |
writer.println("<h4><a name=\"" + context.whereC + "\">" + name +
|
|
67 |
" Constants</a></h4>");
|
|
68 |
writer.println(comment());
|
|
69 |
writer.println("<dd><table border=1 cellpadding=3 cellspacing=0 width=\"90%\" summary=\"\"><tr>");
|
|
70 |
writer.println("<th width=\"20%\"><th width=\"5%\"><th width=\"65%\">");
|
|
71 |
ConstantNode n;
|
|
72 |
for (Iterator it = components.iterator(); it.hasNext();) {
|
|
73 |
n = ((ConstantNode)it.next());
|
|
74 |
writer.println("<a NAME=\"" + name + "_" + n.name + "\"></a>");
|
|
75 |
n.document(writer);
|
|
76 |
}
|
|
77 |
writer.println("</table>");
|
|
78 |
}
|
|
79 |
|
|
80 |
void documentIndex(PrintWriter writer) {
|
|
81 |
writer.print("<li><a href=\"#" + context.whereC + "\">");
|
|
82 |
writer.println(name() + "</a> Constants");
|
|
83 |
// writer.println("<ul>");
|
|
84 |
// for (Iterator it = components.iterator(); it.hasNext();) {
|
|
85 |
// ((Node)it.next()).documentIndex(writer);
|
|
86 |
// }
|
|
87 |
// writer.println("</ul>");
|
|
88 |
}
|
|
89 |
|
|
90 |
void genJavaClassSpecifics(PrintWriter writer, int depth) {
|
|
91 |
}
|
|
92 |
|
|
93 |
void genJava(PrintWriter writer, int depth) {
|
|
94 |
genJavaClass(writer, depth);
|
|
95 |
}
|
|
96 |
|
|
97 |
public static String getConstant(String key){
|
|
98 |
if (constantMap == null) {
|
|
99 |
return "";
|
|
100 |
}
|
51
|
101 |
String com = constantMap.get(key);
|
2
|
102 |
if(com == null){
|
|
103 |
return "";
|
|
104 |
} else {
|
|
105 |
return com;
|
|
106 |
}
|
|
107 |
}
|
|
108 |
|
|
109 |
}
|