01: /*
02: * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * 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 com.sun.tools.jdwpgen;
27:
28: import java.util.*;
29: import java.io.*;
30:
31: abstract class AbstractTypeNode extends AbstractNamedNode implements
32: TypeNode {
33:
34: abstract String docType();
35:
36: public abstract void genJavaWrite(PrintWriter writer, int depth,
37: String writeLabel);
38:
39: abstract String javaRead();
40:
41: void document(PrintWriter writer) {
42: docRowStart(writer);
43: writer.println("<td colspan="
44: + (maxStructIndent - structIndent) + ">");
45: writer.println(docType() + "<td><i>" + name() + "</i><td>"
46: + comment() + " ");
47: }
48:
49: String javaType() {
50: return docType(); // default
51: }
52:
53: public void genJavaRead(PrintWriter writer, int depth,
54: String readLabel) {
55: indent(writer, depth);
56: writer.print(readLabel);
57: writer.print(" = ");
58: writer.print(javaRead());
59: writer.println(";");
60: genJavaDebugRead(writer, depth, readLabel,
61: debugValue(readLabel));
62: }
63:
64: public void genJavaDeclaration(PrintWriter writer, int depth) {
65: writer.println();
66: genJavaComment(writer, depth);
67: indent(writer, depth);
68: writer.print("final ");
69: writer.print(javaType());
70: writer.print(" " + name);
71: writer.println(";");
72: }
73:
74: public String javaParam() {
75: return javaType() + " " + name;
76: }
77: }
|