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.parser
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: * @(#)MethodEntry.java 1.20 07/05/05
035: */
036:
037: package com.sun.tools.corba.se.idl;
038:
039: // NOTES:
040: // - What does oneway mean?
041:
042: import java.io.PrintWriter;
043: import java.util.Enumeration;
044: import java.util.Hashtable;
045: import java.util.Vector;
046:
047: /**
048: * This is the symbol table entry for methods.
049: **/
050: public class MethodEntry extends SymtabEntry {
051: protected MethodEntry() {
052: super ();
053: } // ctor
054:
055: protected MethodEntry(MethodEntry that) {
056: super (that);
057: _exceptionNames = (Vector) that._exceptionNames.clone();
058: _exceptions = (Vector) that._exceptions.clone();
059: _contexts = (Vector) that._contexts.clone();
060: _parameters = (Vector) that._parameters.clone();
061: _oneway = that._oneway;
062: } // ctor
063:
064: protected MethodEntry(InterfaceEntry that, IDLID clone) {
065: super (that, clone);
066: if (module().equals(""))
067: module(name());
068: else if (!name().equals(""))
069: module(module() + "/" + name());
070: } // ctor
071:
072: public Object clone() {
073: return new MethodEntry(this );
074: } // clone
075:
076: /** Invoke the method generator.
077: @param symbolTable the symbol table is a hash table whose key is
078: a fully qualified type name and whose value is a SymtabEntry or
079: a subclass of SymtabEntry.
080: @param stream the stream to which the generator should sent its output.
081: @see SymtabEntry */
082: public void generate(Hashtable symbolTable, PrintWriter stream) {
083: methodGen.generate(symbolTable, this , stream);
084: } // generate
085:
086: /** Access the method generator.
087: @returns an object which implements the MethodGen interface.
088: @see MethodGen */
089: public Generator generator() {
090: return methodGen;
091: } // generator
092:
093: public void type(SymtabEntry newType) {
094: super .type(newType);
095: if (newType == null)
096: typeName("void");
097: } // type
098:
099: /** Add an exception to the exception list. */
100: public void addException(ExceptionEntry exception) {
101: _exceptions.addElement(exception);
102: } // addException
103:
104: /** This a a vector of the exceptions which this method raises. */
105: public Vector exceptions() {
106: return _exceptions;
107: } // exceptions
108:
109: /** Add an exception name to the list of exception names. */
110: public void addExceptionName(String name) {
111: _exceptionNames.addElement(name);
112: } // addExceptionName
113:
114: /** This is a vector of strings, each of which is the full name of an
115: exception which this method throws. This vector corresponds to the
116: exceptions vector. The first element of this vector is the name
117: of the first element of the exceptions vector, etc. */
118: public Vector exceptionNames() {
119: return _exceptionNames;
120: } // exceptionNames
121:
122: /* Add a context to the context list. */
123: public void addContext(String context) {
124: _contexts.addElement(context);
125: } // addContext
126:
127: /** This is a vector of strings, each of which is the name of a context. */
128: public Vector contexts() {
129: return _contexts;
130: } // contexts
131:
132: /** Add a parameter to the parameter list. */
133: public void addParameter(ParameterEntry parameter) {
134: _parameters.addElement(parameter);
135: } // addParameter
136:
137: /** This is a vector of ParameterEntry's. They are the parameters on
138: this method and their order in the vector is the order they appear
139: on the method. */
140: public Vector parameters() {
141: return _parameters;
142: } // parameters
143:
144: /** Is this a oneway method? */
145: public void oneway(boolean yes) {
146: _oneway = yes;
147: } // oneway
148:
149: /** Is this a oneway method? */
150: public boolean oneway() {
151: return _oneway;
152: } // oneway
153:
154: /** Is this a value method? */
155: public void valueMethod(boolean yes) {
156: _valueMethod = yes;
157: } // valueMethod
158:
159: /** Is this a value method? */
160: public boolean valueMethod() {
161: return _valueMethod;
162: } // valueMethod
163:
164: void exceptionsAddElement(ExceptionEntry e) {
165: addException(e);
166: addExceptionName(e.fullName());
167: } // exceptionsAddElement
168:
169: private Vector _exceptionNames = new Vector();
170: private Vector _exceptions = new Vector();
171: private Vector _contexts = new Vector();
172: private Vector _parameters = new Vector();
173: private boolean _oneway = false;
174: private boolean _valueMethod = false;
175:
176: static MethodGen methodGen;
177: } // class MethodEntry
|