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: * @(#)Helper24.java 1.18 07/05/05
035: */
036:
037: package com.sun.tools.corba.se.idl.toJavaPortable;
038:
039: // NOTES:
040: // -D62023 <klr> New file to implement CORBA 2.4 RTF
041:
042: import java.io.PrintWriter;
043:
044: import java.util.Enumeration;
045: import java.util.Vector;
046:
047: import com.sun.tools.corba.se.idl.GenFileStream;
048: import com.sun.tools.corba.se.idl.InterfaceEntry;
049: import com.sun.tools.corba.se.idl.MethodEntry;
050: import com.sun.tools.corba.se.idl.ParameterEntry;
051: import com.sun.tools.corba.se.idl.SymtabEntry;
052: import com.sun.tools.corba.se.idl.ValueEntry;
053: import com.sun.tools.corba.se.idl.ValueBoxEntry;
054: import com.sun.tools.corba.se.idl.TypedefEntry;
055: import com.sun.tools.corba.se.idl.InterfaceState;
056: import com.sun.tools.corba.se.idl.PrimitiveEntry;
057: import com.sun.tools.corba.se.idl.StructEntry;
058:
059: /**
060: *
061: **/
062: public class Helper24 extends Helper {
063: /**
064: * Public zero-argument constructor.
065: **/
066: public Helper24() {
067: } // ctor
068:
069: /**
070: * Generate the heading, including package, imports, class statements,
071: * and open curly.
072: * <d62023> - don't implement ValueHelper, make non-boxed helpers abstract
073: **/
074: protected void writeHeading() {
075: Util.writePackage(stream, entry, Util.HelperFile);
076: Util.writeProlog(stream, stream.name());
077:
078: // Transfer comment to target <30jul1997daz>.
079: if (entry.comment() != null)
080: entry.comment().generate("", stream);
081:
082: if (entry instanceof ValueBoxEntry) {
083: stream.print("public final class " + helperClass);
084: stream
085: .println(" implements org.omg.CORBA.portable.BoxedValueHelper");
086: } else
087: stream.println("abstract public class " + helperClass);
088: stream.println('{');
089: }
090:
091: /**
092: * Generate the instance variables.
093: * <d62023> - no helper instance except for boxed valuetypes.
094: * - move truncatable_ids to mapped class.
095: **/
096: protected void writeInstVars() {
097: stream.println(" private static String _id = \""
098: + Util.stripLeadingUnderscoresFromID(entry
099: .repositoryID().ID()) + "\";");
100: if (entry instanceof ValueEntry) {
101: stream.println();
102: if (entry instanceof ValueBoxEntry) {
103: stream.println(" private static " + helperClass
104: + " _instance = new " + helperClass + " ();");
105: stream.println();
106: }
107: }
108: stream.println();
109: } // writeInstVars
110:
111: /**
112: * <d62023> generate members of BoxedValueHelper interface if boxed
113: *
114: * <d62023> Hook in here to write factory methods for non-boxed ValueTypes
115: * into Helper.
116: **/
117: protected void writeValueHelperInterface() {
118: if (entry instanceof ValueBoxEntry) {
119: writeGetID();
120: } else if (entry instanceof ValueEntry) {
121: writeHelperFactories();
122: }
123: } // writeValueHelperInterface
124:
125: /**
126: *
127: **/
128: protected void writeHelperFactories() {
129: Vector init = ((ValueEntry) entry).initializers();
130: if (init != null) {
131: stream.println();
132: for (int i = 0; i < init.size(); i++) {
133: MethodEntry element = (MethodEntry) init.elementAt(i);
134: element.valueMethod(true); //tag value method if not tagged previously
135: ((MethodGen24) element.generator())
136: .helperFactoryMethod(symbolTable, element,
137: entry, stream);
138: }
139: }
140: } // writeHelperFactories
141:
142: /**
143: * <d62023> Generate constructors only for boxed valuetype helpers
144: * All other helpers are abstract.
145: **/
146: protected void writeCtors() {
147: if (entry instanceof ValueBoxEntry) {
148: stream.println(" public " + helperClass + "()");
149: stream.println(" {");
150: stream.println(" }");
151: stream.println();
152: }
153: } // writeCtors
154: }
|