Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / org / omg / CosNaming / _NamingContextExtImplBase.java
blob03630f8d6742fc53d1ea27a4d817f6d4a2088ebd
1 /* _NamingContextExtImplBase.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package org.omg.CosNaming;
41 import org.omg.CORBA.ObjectHolder;
42 import org.omg.CORBA.ServerRequest;
43 import org.omg.CORBA.StringHolder;
44 import org.omg.CORBA.portable.InputStream;
45 import org.omg.CORBA.portable.InvokeHandler;
46 import org.omg.CORBA.portable.OutputStream;
47 import org.omg.CORBA.portable.ResponseHandler;
48 import org.omg.CORBA.portable.Streamable;
49 import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
50 import org.omg.CosNaming.NamingContextExtPackage.InvalidAddressHelper;
51 import org.omg.CosNaming.NamingContextPackage.CannotProceed;
52 import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
53 import org.omg.CosNaming.NamingContextPackage.InvalidName;
54 import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
55 import org.omg.CosNaming.NamingContextPackage.NotFound;
56 import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
58 import java.util.Hashtable;
60 /**
61 * The extended naming context implementation base.
63 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
65 public abstract class _NamingContextExtImplBase
66 extends _NamingContextImplBase
67 implements NamingContextExt, InvokeHandler
69 static Hashtable _methods = new Hashtable();
71 static
73 _methods.put("to_string", new java.lang.Integer(0));
74 _methods.put("to_name", new java.lang.Integer(1));
75 _methods.put("to_url", new java.lang.Integer(2));
76 _methods.put("resolve_str", new java.lang.Integer(3));
79 /**
80 * This stub can be the base of the two CORBA objects, so it
81 * has two repository ids.
83 private static String[] __ids =
84 { NamingContextExtHelper.id(), NamingContextHelper.id() };
86 /**
87 * Return the array of repository ids for this object.
88 * This stub can be the base of the two CORBA objects, so it
89 * has two repository ids, for {@link NamingContext} and
90 * for {@link NamingContextExt}.
92 public String[] _ids()
94 return __ids;
97 public OutputStream _invoke(String method, InputStream in, ResponseHandler rh)
99 Integer call_method = (Integer) _methods.get(method);
101 if (call_method == null)
103 // The older methods are handled by the parent class.
104 return super._invoke(method, in, rh);
106 OutputStream out = null;
108 switch (call_method.intValue())
110 case 0 : // to_string
114 NameComponent[] a_name = NameHelper.read(in);
115 String result = null;
116 result = this.to_string(a_name);
117 out = rh.createReply();
118 out.write_string(result);
120 catch (InvalidName ex)
122 out = rh.createExceptionReply();
123 InvalidNameHelper.write(out, ex);
125 break;
128 case 1 : // to_name
132 String a_name_string = in.read_string();
133 NameComponent[] result = to_name(a_name_string);
134 out = rh.createReply();
135 NameHelper.write(out, result);
137 catch (InvalidName ex)
139 out = rh.createExceptionReply();
140 InvalidNameHelper.write(out, ex);
142 break;
145 case 2 : // to_url
149 String an_address = in.read_string();
150 String a_name_string = in.read_string();
151 String result = to_url(an_address, a_name_string);
152 out = rh.createReply();
153 out.write_string(result);
155 catch (InvalidAddress ex)
157 out = rh.createExceptionReply();
158 InvalidAddressHelper.write(out, ex);
160 catch (InvalidName ex)
162 out = rh.createExceptionReply();
163 InvalidNameHelper.write(out, ex);
165 break;
168 case 3 : // resolve_str
172 String a_name_string = in.read_string();
173 org.omg.CORBA.Object result = resolve_str(a_name_string);
174 out = rh.createReply();
175 org.omg.CORBA.ObjectHelper.write(out, result);
177 catch (NotFound ex)
179 out = rh.createExceptionReply();
180 NotFoundHelper.write(out, ex);
182 catch (CannotProceed ex)
184 out = rh.createExceptionReply();
185 CannotProceedHelper.write(out, ex);
187 catch (InvalidName ex)
189 out = rh.createExceptionReply();
190 InvalidNameHelper.write(out, ex);
192 break;
195 return out;
199 * The obsolete invocation using server request. Implemented for
200 * compatibility reasons, but is it more effectinve to use
201 * {@link #_invoke}.
203 * @param request a server request.
205 public void invoke(ServerRequest request)
207 Streamable result = null;
209 Integer call_method = (Integer) _methods.get(request.operation());
211 if (call_method == null)
213 super.invoke(request);
214 return;
217 switch (call_method.intValue())
219 case 0 : // to_string, String
220 result = new StringHolder();
221 break;
223 case 1 : // to_name, Name
224 result = new NameHolder();
225 break;
227 case 2 : // to_url, String
228 result = new StringHolder();
229 break;
231 case 3 : // resolve_str, Object
232 result = new ObjectHolder();
233 break;
235 gnu.CORBA.ServiceRequestAdapter.invoke(request, this, result);