Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / org / omg / CosNaming / _NamingContextExtStub.java
bloba0bc80ac08d38a176a7d6f89eda4599c9315188c
1 /* _NamingContextExtStub.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 gnu.CORBA.NamingService.NameTransformer;
43 import org.omg.CORBA.MARSHAL;
44 import org.omg.CORBA.ObjectHelper;
45 import org.omg.CORBA.portable.ApplicationException;
46 import org.omg.CORBA.portable.Delegate;
47 import org.omg.CORBA.portable.InputStream;
48 import org.omg.CORBA.portable.OutputStream;
49 import org.omg.CORBA.portable.RemarshalException;
50 import org.omg.CosNaming.NamingContextExtPackage.AddressHelper;
51 import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
52 import org.omg.CosNaming.NamingContextExtPackage.InvalidAddressHelper;
53 import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
54 import org.omg.CosNaming.NamingContextExtPackage.URLStringHelper;
55 import org.omg.CosNaming.NamingContextPackage.CannotProceed;
56 import org.omg.CosNaming.NamingContextPackage.InvalidName;
57 import org.omg.CosNaming.NamingContextPackage.InvalidNameHelper;
58 import org.omg.CosNaming.NamingContextPackage.NotFound;
60 /**
61 * The extended naming context stub (proxy), used on the client side.
62 * The most of the {@link NamingContextExt} methods contain the code
63 * for remote invocaton. However as remote invocation is potencially an
64 * expensive step, some trivial methods, not requiring access to the
65 * naming database, are handled locally (see the method descriptions for
66 * details).
68 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
70 public class _NamingContextExtStub
71 extends _NamingContextStub
72 implements NamingContextExt
74 /**
75 * Use serialVersionUID (v1.4) for interoperability.
77 private static final long serialVersionUID = 6333293895664182866L;
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 * The local name form converter.
89 private NameTransformer converter = new NameTransformer();
91 /**
92 * Create the naming context stub.
94 public _NamingContextExtStub()
96 super();
99 /**
100 * Create the naming context stub with the given delegate.
102 public _NamingContextExtStub(Delegate delegate)
104 super(delegate);
108 * Return the array of repository ids for this object.
109 * This stub can be the base of the two CORBA objects, so it
110 * has two repository ids, for {@link NamingContext} and
111 * for {@link NamingContextExt}.
113 public String[] _ids()
115 return (String[]) __ids.clone();
118 /** {@inheritDoc} */
119 public org.omg.CORBA.Object resolve_str(String a_name_string)
120 throws NotFound, CannotProceed, InvalidName
122 InputStream in = null;
125 OutputStream _out = _request("resolve_str", true);
126 StringNameHelper.write(_out, a_name_string);
127 in = _invoke(_out);
129 return ObjectHelper.read(in);
131 catch (ApplicationException ex)
133 in = ex.getInputStream();
135 String id = ex.getId();
136 throw4(in, id);
138 // Should never happen.
139 throw new InternalError();
141 catch (RemarshalException _rm)
143 return resolve_str(a_name_string);
145 finally
147 _releaseReply(in);
152 * Converts the string name representation into the array
153 * name representation.
155 * This method is handled locally.
157 public NameComponent[] to_name(String a_name_string)
158 throws InvalidName
160 return converter.toName(a_name_string);
164 * Convert the name array representation to the name string
165 * representation.
167 * This method is handled locally.
169 public String to_string(NameComponent[] a_name)
170 throws InvalidName
172 return converter.toString(a_name);
175 /** {@inheritDoc} */
176 public String to_url(String an_address, String a_name_string)
177 throws InvalidAddress, InvalidName
179 InputStream in = null;
182 OutputStream _out = _request("to_url", true);
183 AddressHelper.write(_out, an_address);
184 StringNameHelper.write(_out, a_name_string);
185 in = _invoke(_out);
187 return URLStringHelper.read(in);
189 catch (ApplicationException ex)
191 in = ex.getInputStream();
193 String id = ex.getId();
194 if (id.equals(InvalidAddressHelper.id()))
195 throw InvalidAddressHelper.read(in);
196 else if (id.equals(InvalidNameHelper.id()))
197 throw InvalidNameHelper.read(in);
198 else
199 throw new MARSHAL(id);
201 catch (RemarshalException _rm)
203 return to_url(an_address, a_name_string);
205 finally
207 _releaseReply(in);