001: /*
002: * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.jdwpgen;
027:
028: import java.util.*;
029: import java.io.*;
030:
031: abstract class AbstractGroupNode extends AbstractTypeListNode {
032:
033: void document(PrintWriter writer) {
034: for (Iterator it = components.iterator(); it.hasNext();) {
035: ((Node) it.next()).document(writer);
036: }
037: }
038:
039: String javaType() {
040: return name();
041: }
042:
043: void genJava(PrintWriter writer, int depth) {
044: genJavaClass(writer, depth);
045: }
046:
047: void genJavaWriteMethod(PrintWriter writer, int depth) {
048: genJavaWriteMethod(writer, depth, "private ");
049: }
050:
051: void genJavaWriteMethod(PrintWriter writer, int depth,
052: String modifier) {
053: writer.println();
054: indent(writer, depth);
055: writer.print(modifier);
056: writer.println("void write(PacketStream ps) {");
057: genJavaWrites(writer, depth + 1);
058: indent(writer, depth);
059: writer.println("}");
060: }
061:
062: void genJavaClassSpecifics(PrintWriter writer, int depth) {
063: switch (context.state) {
064: case Context.readingReply:
065: genJavaReadingClassBody(writer, depth, name());
066: break;
067:
068: case Context.writingCommand:
069: genJavaWritingClassBody(writer, depth, name());
070: genJavaWriteMethod(writer, depth);
071: break;
072:
073: default:
074: error("Group in outer");
075: break;
076: }
077: }
078:
079: public void genJavaDeclaration(PrintWriter writer, int depth) {
080: writer.println();
081: genJavaComment(writer, depth);
082: indent(writer, depth);
083: writer.print("final ");
084: writer.print(name());
085: writer.print(" a" + name());
086: writer.println(";");
087: }
088:
089: public String javaParam() {
090: return name() + " a" + name();
091: }
092:
093: public void genJavaWrite(PrintWriter writer, int depth,
094: String writeLabel) {
095: genJavaDebugWrite(writer, depth, writeLabel, "\"\"");
096: indent(writer, depth);
097: writer.println(writeLabel + ".write(ps);");
098: }
099:
100: String javaRead() {
101: error("Internal - Should not call AbstractGroupNode.javaRead()");
102: return "";
103: }
104:
105: public void genJavaRead(PrintWriter writer, int depth,
106: String readLabel) {
107: genJavaDebugRead(writer, depth, readLabel, "\"\"");
108: indent(writer, depth);
109: writer.print(readLabel);
110: writer.print(" = new ");
111: writer.print(name());
112: writer.println("(vm, ps);");
113: }
114: }
|