MethodEntry.java revision 672:2bb058ce572e
1/* 2 * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25/* 26 * COMPONENT_NAME: idl.parser 27 * 28 * ORIGINS: 27 29 * 30 * Licensed Materials - Property of IBM 31 * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999 32 * RMI-IIOP v1.0 33 * 34 */ 35 36package com.sun.tools.corba.se.idl; 37 38// NOTES: 39// - What does oneway mean? 40 41import java.io.PrintWriter; 42import java.util.Enumeration; 43import java.util.Hashtable; 44import java.util.Vector; 45 46/** 47 * This is the symbol table entry for methods. 48 **/ 49public class MethodEntry extends SymtabEntry 50{ 51 protected MethodEntry () 52 { 53 super (); 54 } // ctor 55 56 protected MethodEntry (MethodEntry that) 57 { 58 super (that); 59 _exceptionNames = (Vector)that._exceptionNames.clone (); 60 _exceptions = (Vector)that._exceptions.clone (); 61 _contexts = (Vector)that._contexts.clone (); 62 _parameters = (Vector)that._parameters.clone (); 63 _oneway = that._oneway; 64 } // ctor 65 66 protected MethodEntry (InterfaceEntry that, IDLID clone) 67 { 68 super (that, clone); 69 if (module ().equals ("")) 70 module (name ()); 71 else if (!name ().equals ("")) 72 module (module () + "/" + name ()); 73 } // ctor 74 75 public Object clone () 76 { 77 return new MethodEntry (this); 78 } // clone 79 80 /** Invoke the method generator. 81 @param symbolTable the symbol table is a hash table whose key is 82 a fully qualified type name and whose value is a SymtabEntry or 83 a subclass of SymtabEntry. 84 @param stream the stream to which the generator should sent its output. 85 @see SymtabEntry */ 86 public void generate (Hashtable symbolTable, PrintWriter stream) 87 { 88 methodGen.generate (symbolTable, this, stream); 89 } // generate 90 91 /** Access the method generator. 92 @return an object which implements the MethodGen interface. 93 @see MethodGen */ 94 public Generator generator () 95 { 96 return methodGen; 97 } // generator 98 99 public void type (SymtabEntry newType) 100 { 101 super.type (newType); 102 if (newType == null) 103 typeName ("void"); 104 } // type 105 106 /** Add an exception to the exception list. */ 107 public void addException (ExceptionEntry exception) 108 { 109 _exceptions.addElement (exception); 110 } // addException 111 112 /** This a a vector of the exceptions which this method raises. */ 113 public Vector exceptions () 114 { 115 return _exceptions; 116 } // exceptions 117 118 /** Add an exception name to the list of exception names. */ 119 public void addExceptionName (String name) 120 { 121 _exceptionNames.addElement (name); 122 } // addExceptionName 123 124 /** This is a vector of strings, each of which is the full name of an 125 exception which this method throws. This vector corresponds to the 126 exceptions vector. The first element of this vector is the name 127 of the first element of the exceptions vector, etc. */ 128 public Vector exceptionNames () 129 { 130 return _exceptionNames; 131 } // exceptionNames 132 133 /* Add a context to the context list. */ 134 public void addContext (String context) 135 { 136 _contexts.addElement (context); 137 } // addContext 138 139 /** This is a vector of strings, each of which is the name of a context. */ 140 public Vector contexts () 141 { 142 return _contexts; 143 } // contexts 144 145 /** Add a parameter to the parameter list. */ 146 public void addParameter (ParameterEntry parameter) 147 { 148 _parameters.addElement (parameter); 149 } // addParameter 150 151 /** This is a vector of ParameterEntry's. They are the parameters on 152 this method and their order in the vector is the order they appear 153 on the method. */ 154 public Vector parameters () 155 { 156 return _parameters; 157 } // parameters 158 159 /** Is this a oneway method? */ 160 public void oneway (boolean yes) 161 { 162 _oneway = yes; 163 } // oneway 164 165 /** Is this a oneway method? */ 166 public boolean oneway () 167 { 168 return _oneway; 169 } // oneway 170 171 /** Is this a value method? */ 172 public void valueMethod (boolean yes) 173 { 174 _valueMethod = yes; 175 } // valueMethod 176 177 /** Is this a value method? */ 178 public boolean valueMethod () 179 { 180 return _valueMethod; 181 } // valueMethod 182 183 void exceptionsAddElement (ExceptionEntry e) 184 { 185 addException (e); 186 addExceptionName (e.fullName ()); 187 } // exceptionsAddElement 188 189 private Vector _exceptionNames = new Vector (); 190 private Vector _exceptions = new Vector (); 191 private Vector _contexts = new Vector (); 192 private Vector _parameters = new Vector (); 193 private boolean _oneway = false; 194 private boolean _valueMethod = false; 195 196 static MethodGen methodGen; 197} // class MethodEntry 198