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