001: /*
002: * Copyright 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: * COMPONENT_NAME: idl.toJava
027: *
028: * ORIGINS: 27
029: *
030: * Licensed Materials - Property of IBM
031: * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
032: * RMI-IIOP v1.0
033: *
034: * @(#)ForwardValueGen.java 1.20 07/05/05
035: */
036:
037: package com.sun.tools.corba.se.idl.toJavaPortable;
038:
039: // NOTES:
040: // -D61056 <klr> Use Util.helperName
041:
042: import java.io.File;
043: import java.io.PrintWriter;
044: import java.util.Hashtable;
045: import java.util.Enumeration;
046: import java.util.Vector;
047:
048: import com.sun.tools.corba.se.idl.GenFileStream;
049: import com.sun.tools.corba.se.idl.InterfaceEntry;
050: import com.sun.tools.corba.se.idl.SymtabEntry;
051: import com.sun.tools.corba.se.idl.TypedefEntry;
052: import com.sun.tools.corba.se.idl.ForwardValueEntry;
053: import com.sun.tools.corba.se.idl.InterfaceState;
054: import com.sun.tools.corba.se.idl.MethodEntry;
055:
056: /**
057: *
058: **/
059: public class ForwardValueGen implements
060: com.sun.tools.corba.se.idl.ForwardValueGen, JavaGenerator {
061: /**
062: * Public zero-argument constructor.
063: **/
064: public ForwardValueGen() {
065: } // ctor
066:
067: /**
068: *
069: **/
070: public void generate(Hashtable symbolTable, ForwardValueEntry v,
071: PrintWriter str) {
072: this .symbolTable = symbolTable;
073: this .v = v;
074:
075: openStream();
076: if (stream == null)
077: return;
078: generateHelper();
079: generateHolder();
080: generateStub();
081: writeHeading();
082: writeBody();
083: writeClosing();
084: closeStream();
085: } // generate
086:
087: /**
088: *
089: **/
090: protected void openStream() {
091: stream = Util.stream(v, ".java");
092: } // openStream
093:
094: /**
095: *
096: **/
097: protected void generateHelper() {
098: ((Factories) Compile.compiler.factories()).helper().generate(
099: symbolTable, v);
100: } // generateHelper
101:
102: /**
103: *
104: **/
105: protected void generateHolder() {
106: ((Factories) Compile.compiler.factories()).holder().generate(
107: symbolTable, v);
108: } // generateHolder
109:
110: /**
111: *
112: **/
113: protected void generateStub() {
114: } // generateStub
115:
116: /**
117: *
118: **/
119: protected void writeHeading() {
120: Util.writePackage(stream, v);
121: Util.writeProlog(stream, ((GenFileStream) stream).name());
122:
123: if (v.comment() != null)
124: v.comment().generate("", stream);
125:
126: stream.print("public class " + v.name()
127: + " implements org.omg.CORBA.portable.IDLEntity");
128: // There should ALWAYS be at least one: ValueBase
129:
130: stream.println("{");
131: } // writeHeading
132:
133: /**
134: *
135: **/
136: protected void writeBody() {
137: } // writeBody
138:
139: /**
140: *
141: **/
142: protected void writeClosing() {
143: stream.println("} // class " + v.name());
144: } // writeClosing
145:
146: /**
147: *
148: **/
149: protected void closeStream() {
150: stream.close();
151: } // closeStream
152:
153: ///////////////
154: // From JavaGenerator
155:
156: public int helperType(int index, String indent,
157: TCOffsets tcoffsets, String name, SymtabEntry entry,
158: PrintWriter stream) {
159: return index;
160: } // helperType
161:
162: public int type(int index, String indent, TCOffsets tcoffsets,
163: String name, SymtabEntry entry, PrintWriter stream) {
164: stream.println(indent + name + " = "
165: + Util.helperName(entry, true) + ".type ();"); // <d61056>
166: return index;
167: } // type
168:
169: public void helperRead(String entryName, SymtabEntry entry,
170: PrintWriter stream) {
171: stream.println(" " + entryName + " value = new " + entryName
172: + " ();");
173: read(0, " ", "value", entry, stream);
174: stream.println(" return value;");
175: } // helperRead
176:
177: public int read(int index, String indent, String name,
178: SymtabEntry entry, PrintWriter stream) {
179: return index;
180: } // read
181:
182: public void helperWrite(SymtabEntry entry, PrintWriter stream) {
183: write(0, " ", "value", entry, stream);
184: } // helperWrite
185:
186: public int write(int index, String indent, String name,
187: SymtabEntry entry, PrintWriter stream) {
188: return index;
189: } // write
190:
191: // From JavaGenerator
192: ///////////////
193:
194: /**
195: *
196: **/
197: protected void writeAbstract() {
198: } // writeAbstract
199:
200: protected Hashtable symbolTable = null;
201: protected ForwardValueEntry v = null;
202: protected PrintWriter stream = null;
203: } // class ForwardValueGen
|