001/* Any.java --
002   Copyright (C) 2005 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038
039package org.omg.CORBA;
040
041import java.io.Serializable;
042
043import org.omg.CORBA.portable.IDLEntity;
044
045/**
046 * A container that can store a value of either user defined or
047 * primitive IDL type.
048 *
049 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
050 */
051public abstract class Any
052  implements Serializable, IDLEntity
053{
054  /**
055   * Using v 1.4 serialVersionUID for interoperability.
056   */
057  private static final long serialVersionUID = 1217179597823814463L;
058
059  /**
060   * Creates an input stream from that this Any object's value can be
061   * read (unmarshalled).
062   */
063  public abstract org.omg.CORBA.portable.InputStream create_input_stream();
064
065  /**
066   * Creates an output stream into which this <code>Any</code> object's
067   * value can be written (marshalled).
068   *
069   * @return the newly created output stream.
070   */
071  public abstract org.omg.CORBA.portable.OutputStream create_output_stream();
072
073  /**
074   * Compare this <code>Any</code> with another <code>Any</code>.
075   *
076   * @param other the other instance to compare with.
077   *
078   * @return true if both values and value typecodes are equal,
079   * false otherwise.
080   */
081  public abstract boolean equal(Any other);
082
083  /**
084   * Extract the CORBA <code>Object</code> from this <code>Any</code>
085   * @throws BAD_OPERATION  if this instance contains value other
086   * than <code>Object</code> or the value has not been set.
087   */
088  public abstract org.omg.CORBA.Object extract_Object()
089                                               throws BAD_OPERATION;
090
091  /**
092   * Extract the CORBA <code>Principal</code> from this <code>Any</code>
093   *
094   * @throws NO_IMPLEMENT, always.
095   *
096   * @deprecated by CORBA 2.2.
097   */
098  public Principal extract_Principal()
099  {
100    throw new NO_IMPLEMENT();
101  }
102
103  /**
104   * Extract an arbitrary {@link org.omg.CORBA.portable.Streamable } from
105   * this <code>Any</code>.
106   *
107   * @throws BAD_INV_ORDER if the caller has invoked operations in the
108   * wrong order.
109   *
110   * @throws NO_IMPLEMENT, always (override to get functionality).
111   */
112  public org.omg.CORBA.portable.Streamable extract_Streamable()
113    throws org.omg.CORBA.BAD_INV_ORDER
114  {
115    throw new NO_IMPLEMENT();
116  }
117
118  /**
119   * Extract the TypeCode from this <code>Any</code> value field.
120   *
121   * @throws BAD_OPERATION  if this instance contains value other
122   * than <code>TypeCode</code> or the value has not been set.
123   */
124  public abstract TypeCode extract_TypeCode()
125                                     throws BAD_OPERATION;
126
127  /**
128   * Extract the CORBA <code>Value</code> from this <code>Any</code>
129   * @throws BAD_OPERATION  if this instance contains value other
130   * than <code>Value</code> or the value has not been set.
131   */
132  public abstract java.io.Serializable extract_Value()
133                                              throws BAD_OPERATION;
134
135  /**
136   * Extract another <code>Any</code> from this <code>Any</code>.
137   *
138   * @throws BAD_OPERATION  if this instance contains value other
139   * than <code>any</code> or the value has not been set.
140   */
141  public abstract Any extract_any()
142                           throws BAD_OPERATION;
143
144  /**
145   * Extract the CORBA <code>boolean</code> from this <code>Any</code>.
146   *
147   * @throws BAD_OPERATION  if this instance contains value other
148   * than <code>boolean</code> or the value has not been set.
149   */
150  public abstract boolean extract_boolean()
151                                   throws BAD_OPERATION;
152
153  /**
154   * Extract the CORBA <code>char</code> from this <code>Any</code>.
155   *
156   * @throws BAD_OPERATION  if this instance contains value other
157   * than <code>char</code> or the value has not been set.
158   */
159  public abstract char extract_char()
160                             throws BAD_OPERATION;
161
162  /**
163   * Extract the CORBA <code>double</code> from this <code>Any</code>.
164   *
165   * @throws BAD_OPERATION  if this instance contains value other
166   * than <code>double</code> or the value has not been set.
167   */
168  public abstract double extract_double()
169                                 throws BAD_OPERATION;
170
171  /**
172   * Extract the CORBA <code>fixed</code> from this <code>Any</code>.
173   *
174   * @throws BAD_OPERATION  if this instance contains value other
175   * than <code>fixed</code> or the value has not been set.
176   *
177   * @throws NO_IMPLEMENT, always (override to get functionality).
178   */
179  public java.math.BigDecimal extract_fixed()
180                                     throws BAD_OPERATION
181  {
182    throw new NO_IMPLEMENT();
183  }
184
185  /**
186   * Extract the CORBA <code>float</code> from this <code>Any</code>.
187   *
188   * @throws BAD_OPERATION  if this instance contains value other
189   * than <code>float</code> or the value has not been set.
190   */
191  public abstract float extract_float()
192                               throws BAD_OPERATION;
193
194  /**
195   * Extract the CORBA <code>long</code> from this <code>Any</code>.
196   *
197   * @throws BAD_OPERATION  if this instance contains value other
198   * than <code>long</code> or the value has not been set.
199   */
200  public abstract int extract_long()
201                            throws BAD_OPERATION;
202
203  /**
204   * Extract the CORBA <code>long long</code> from this <code>Any</code>.
205   *
206   * @throws BAD_OPERATION  if this instance contains value other
207   * than <code>longlong</code> or the value has not been set.
208   */
209  public abstract long extract_longlong()
210                                 throws BAD_OPERATION;
211
212  /**
213   * Extract the CORBA <code>octet</code> from this <code>Any</code>.
214   *
215   * @throws BAD_OPERATION  if this instance contains value other
216   * than <code>octet</code> or the value has not been set.
217   */
218  public abstract byte extract_octet()
219                              throws BAD_OPERATION;
220
221  /**
222   * Extract the CORBA <code>short</code> from this <code>Any</code>.
223   *
224   * @throws BAD_OPERATION  if this instance contains value other
225   * than <code>short</code> or the value has not been set.
226   */
227  public abstract short extract_short()
228                               throws BAD_OPERATION;
229
230  /**
231   * Extract the CORBA <code>string</code> from this <code>Any</code>.
232   *
233   * @throws BAD_OPERATION  if this instance contains value other
234   * than <code>string</code> or the value has not been set.
235   */
236  public abstract String extract_string()
237                                 throws BAD_OPERATION;
238
239  /**
240   * Extract the CORBA unsigned <code>long</code> from this <code>Any</code>
241   * @throws BAD_OPERATION  if this instance contains value other
242   * than unsigned <code>long</code> or the value has not been set.
243   */
244  public abstract int extract_ulong()
245                             throws BAD_OPERATION;
246
247  /**
248   * Extract the CORBA unsigned <code>long long</code> from this
249   * <code>Any</code>.
250   *
251   * @throws BAD_OPERATION  if this instance contains value other
252   * than unsigned <code>long long</code> or the value has not been set.
253   */
254  public abstract long extract_ulonglong()
255                                  throws BAD_OPERATION;
256
257  /**
258   * Extract the CORBA unsigned <code>short</code> from this <code>Any</code>
259   * @throws BAD_OPERATION  if this instance contains value other
260   * than unsigned <code>short</code> or the value has not been set.
261   */
262  public abstract short extract_ushort()
263                                throws BAD_OPERATION;
264
265  /**
266   * Extract the CORBA <code>wchar</code> from this <code>Any</code>
267   * @throws BAD_OPERATION  if this instance contains value other
268   * than <code>wchar</code> or the value has not been set.
269   */
270  public abstract char extract_wchar()
271                              throws BAD_OPERATION;
272
273  /**
274   * Extract the CORBA <code>wstring</code> from this <code>Any</code>
275   * @throws BAD_OPERATION  if this instance contains value other
276   * than <code>wstring</code> or the value has not been set.
277   */
278  public abstract String extract_wstring()
279                                  throws BAD_OPERATION;
280
281  /**
282   * Insert the CORBA <code>Object</code> into this <code>Any</code>
283   */
284  public abstract void insert_Object(org.omg.CORBA.Object x, TypeCode typecode);
285
286  /**
287   * Insert the CORBA <code>Object</code> into this <code>Any</code>
288   */
289  public abstract void insert_Object(org.omg.CORBA.Object x);
290
291  /**
292   * Insert the CORBA <code>Principal</code> into this <code>Any</code>.
293   * @deprecated by CORBA 2.2.
294   */
295  public void insert_Principal(Principal x)
296  {
297    throw new NO_IMPLEMENT();
298  }
299
300  /**
301   * Insert the CORBA <code>Streamable</code> into this <code>Any</code>
302   */
303  public void insert_Streamable(org.omg.CORBA.portable.Streamable x)
304  {
305    throw new NO_IMPLEMENT();
306  }
307
308  /**
309   * Insert the CORBA <code>TypeCode</code> into this <code>Any</code>
310   * value field.
311   */
312  public abstract void insert_TypeCode(TypeCode typecode);
313
314  /**
315   * Insert the CORBA <code>Value</code> into this <code>Any</code>.
316   *
317   * The type of the Any should be set (by {@link #type(TypeCode)})
318   * before inserting the value.
319   */
320  public abstract void insert_Value(Serializable x, TypeCode typecode);
321
322  /**
323   * Insert the CORBA <code>Value</code> into this <code>Any</code>.
324   *
325   * The type of the Any should be set (by {@link #type(TypeCode)})
326   * before inserting the value.
327   */
328  public abstract void insert_Value(Serializable x);
329
330  /**
331   * Insert the CORBA <code>any</code> into this <code>Any</code>
332   */
333  public abstract void insert_any(Any x);
334
335  /**
336   * Insert the CORBA <code>boolean</code> into this <code>Any</code>
337   */
338  public abstract void insert_boolean(boolean x);
339
340  /**
341   * Insert the CORBA <code>char</code> into this <code>Any</code>
342   */
343  public abstract void insert_char(char x);
344
345  /**
346   * Insert the CORBA <code>double</code> into this <code>Any</code>
347   */
348  public abstract void insert_double(double x);
349
350  /**
351   * Insert the CORBA <code>fixed</code> into this <code>Any</code>
352   */
353  public void insert_fixed(java.math.BigDecimal x, TypeCode typecode)
354  {
355    throw new NO_IMPLEMENT();
356  }
357
358  /**
359   * Insert the CORBA <code>fixed</code> into this <code>Any</code>
360   */
361  public void insert_fixed(java.math.BigDecimal x)
362  {
363    throw new NO_IMPLEMENT();
364  }
365
366  /**
367   * Insert the CORBA <code>float</code> into this <code>Any</code>
368   */
369  public abstract void insert_float(float x);
370
371  /**
372   * Insert the CORBA <code>long</code> into this <code>Any</code>
373   */
374  public abstract void insert_long(int x);
375
376  /**
377   * Insert the CORBA <code>longlong</code> into this <code>Any</code>
378   */
379  public abstract void insert_longlong(long x);
380
381  /**
382   * Insert the CORBA <code>octet</code> into this <code>Any</code>
383   */
384  public abstract void insert_octet(byte x);
385
386  /**
387   * Insert the CORBA <code>short</code> into this <code>Any</code>
388   */
389  public abstract void insert_short(short x);
390
391  /**
392   * Insert the CORBA <code>string</code> into this <code>Any</code>
393   */
394  public abstract void insert_string(String x);
395
396  /**
397   * Insert the CORBA <code>ulong</code> into this <code>Any</code>
398   */
399  public abstract void insert_ulong(int x);
400
401  /**
402   * Insert the CORBA <code>ulonglong</code> into this <code>Any</code>
403   */
404  public abstract void insert_ulonglong(long x);
405
406  /**
407   * Insert the CORBA <code>ushort</code> into this <code>Any</code>
408   */
409  public abstract void insert_ushort(short x);
410
411  /**
412   * Insert the CORBA <code>wchar</code> into this <code>Any</code>
413   */
414  public abstract void insert_wchar(char x);
415
416  /**
417   * Insert the CORBA <code>wstring</code> into this <code>Any</code>
418   */
419  public abstract void insert_wstring(String x);
420
421  /**
422   * Read the value into this <code>Any</code> from the given input stream.
423   *
424   * @param input a CORBA stream to read from.
425   * @param type a TypeCode of the object being read.
426   *
427   * @throws org.omg.CORBA.MARSHAL if the given TypeCode does not match
428   * the TypeCode of the object, found in the stream.
429   */
430  public abstract void read_value(org.omg.CORBA.portable.InputStream input,
431                                  TypeCode type
432                                 )
433                           throws MARSHAL;
434
435  /**
436   * Set the type of the object, stored in this <code>Any</code>, to the
437   * given TypeCode. Clear the value.
438   *
439   * @param valueTypeCode the type of the object that is expected to be stored
440   * in this <code>any</code>.
441   */
442  public abstract void type(TypeCode valueTypeCode);
443
444  /**
445   * Returns the TypeCode of the object, stored in this <code>Any</code>
446   * @return the TypeCode
447   */
448  public abstract TypeCode type();
449
450  /**
451   * Writes out the value (without the typecode of the value), stored in
452   * this <code>Any</code>.
453   *
454   * @param output the CORBA stream to write into.
455   *
456   * @throws NullPointerException if the value of this <code>Any</code>
457   * has not been set.
458   */
459  public abstract void write_value(org.omg.CORBA.portable.OutputStream output);
460}