001    /* DynAny.java --
002       Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    
039    package org.omg.CORBA;
040    
041    import org.omg.CORBA.DynAnyPackage.Invalid;
042    import org.omg.CORBA.DynAnyPackage.InvalidValue;
043    import org.omg.CORBA.DynAnyPackage.TypeMismatch;
044    
045    import java.io.Serializable;
046    
047    /**
048     * The DynAny interface provides possibility to access the components of
049     * the CORBA object, stored inside the {@link Any}. The {@link Any} itself
050     * allows to read, write and pass as parameter the stored value without
051     * knowning its exact data type. The DynAny and derived classes additionally
052     * allows to access the members of the sequence, structure, union and get the
053     * data about enumeration, value type and CORBA <code>fixed</code> without
054     * knowing the exact type at the run time. The returned members are also
055     * wrapped into DynAny objects, allowing them to be the nested structures.
056     *
057     * @deprecated by {@link org.omg.DynamicAny.DynAny}
058     *
059     * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
060     */
061    public interface DynAny
062      extends org.omg.CORBA.Object
063    {
064      /**
065       * Copy one DynAny into another.
066       *
067       * @param from the DynAny to copy from.
068       * @throws Invalid if the source DynAny is invalid.
069       */
070      void assign(DynAny from)
071           throws Invalid;
072    
073      /**
074       * Clones this DynAny.
075       */
076      DynAny copy();
077    
078      /**
079       * Returns the focused component of this DynAny. The DynAny has the internal
080       * pointer (reference) that can point to one of its components. The returned
081       * DynAny can be used to get or set the value of the focused component.
082       * If the DynAny holds a primitive type with no components, this
083       * implementation returns <code>this</code>.
084       */
085      DynAny current_component();
086    
087      /**
088       * Destroys this DynAny, freeing the used resources. In java, resources
089       * are freed by the garbage collectors, so this method typically returns
090       * without action.
091       */
092      void destroy();
093    
094      /**
095       * Makes a DynAny from the {@link Any}. The passed {@link Any} becomes the
096       * enclosed instance of this DynAny, allowing to change/traverse the
097       * {@link Any} fields by the {@link DynAny} methods.
098       */
099      void from_any(Any an_any)
100             throws Invalid;
101    
102      /**
103       * Retrieves the {@link Any}, stored inside this DynAny.
104       *
105       * @throws TypeMismatch if the typecode of the accessed Any
106       * is not the same as the typecode of this DynAny.
107       */
108      Any get_any()
109           throws TypeMismatch;
110    
111      /**
112       * Extract the boolean value that is expected to be
113       * stored in this DynAny.
114       *
115       * @throws TypeMismatch if this DynAny holds the value of the
116       * different type.
117       */
118      boolean get_boolean()
119                   throws TypeMismatch;
120    
121      /**
122       * Extract the char value that is expected to be
123       * stored in this DynAny.
124       *
125       * @throws TypeMismatch if this DynAny holds the value of the
126       * different type.
127       */
128      char get_char()
129             throws TypeMismatch;
130    
131      /**
132       * Extract the <code>double</code> value that is expected to be
133       * stored in this DynAny.
134       *
135       * @throws TypeMismatch if this DynAny holds the value of the
136       * different type.
137       */
138      double get_double()
139                 throws TypeMismatch;
140    
141      /**
142       * Extract the <code>float</code> value that is expected to be
143       * stored in this DynAny.
144       *
145       * @throws TypeMismatch if this DynAny holds the value of the
146       * different type.
147       */
148      float get_float()
149               throws TypeMismatch;
150    
151      /**
152       * Extract the int (CORBA long) value that is expected to be
153       * stored in this DynAny.
154       *
155       * @throws TypeMismatch if this DynAny holds the value of the
156       * different type.
157       */
158      int get_long()
159            throws TypeMismatch;
160    
161      /**
162       * Extract the long (CORBA long long) value that is expected to be
163       * stored in this DynAny.
164       *
165       * @throws TypeMismatch if this DynAny holds the value of the
166       * different type.
167       */
168      long get_longlong()
169                 throws TypeMismatch;
170    
171      /**
172       * Extract the byte (CORBA octet) value that is expected to be
173       * stored in this DynAny.
174       *
175       * @throws TypeMismatch if this DynAny holds the value of the
176       * different type.
177       */
178      byte get_octet()
179              throws TypeMismatch;
180    
181      /**
182       * Extract the CORBA object reference that is expected to be
183       * stored in this DynAny.
184       *
185       * @throws TypeMismatch if this DynAny holds the value of the
186       * different type.
187       */
188      Object get_reference()
189                    throws TypeMismatch;
190    
191      /**
192       * Extract the <code>short</code> value that is expected to be
193       * stored in this DynAny.
194       *
195       * @throws TypeMismatch if this DynAny holds the value of the
196       * different type.
197       */
198      short get_short()
199               throws TypeMismatch;
200    
201      /**
202       * Extract the string value that is expected to be
203       * stored in this DynAny.
204       *
205       * @throws TypeMismatch if this DynAny holds the value of the
206       * different type.
207       */
208      String get_string()
209                 throws TypeMismatch;
210    
211      /**
212       * Extract the {@link TypeCode} value that is expected to be
213       * stored in this DynAny.
214       *
215       * @throws TypeMismatch if this DynAny holds the value of the
216       * different type.
217       */
218      TypeCode get_typecode()
219                     throws TypeMismatch;
220    
221      /**
222       * Extract the unsigned int (CORBA ulong) value that is expected to be
223       * stored in this DynAny.
224       *
225       * @throws TypeMismatch if this DynAny holds the value of the
226       * different type.
227       */
228      int get_ulong()
229             throws TypeMismatch;
230    
231      /**
232       * Extract the unsingel long (CORBA unsigned long long )value that
233       * is expected to be stored in this DynAny.
234       *
235       * @throws TypeMismatch if this DynAny holds the value of the
236       * different type.
237       */
238      long get_ulonglong()
239                  throws TypeMismatch;
240    
241      /**
242       * Extract the unsigned short value that is expected to be
243       * stored in this DynAny.
244       *
245       * @throws TypeMismatch if this DynAny holds the value of the
246       * different type.
247       */
248      short get_ushort()
249                throws TypeMismatch;
250    
251      /**
252       * Extract the value that is expected to be
253       * stored in this DynAny.
254       *
255       * @throws TypeMismatch if this DynAny holds the value of the
256       * different type.
257       */
258      Serializable get_val()
259                    throws TypeMismatch;
260    
261      /**
262       * Extract the wide (usually UTF-16) character value that is expected to be
263       * stored in this DynAny.
264       *
265       * @throws TypeMismatch if this DynAny holds the value of the
266       * different type.
267       */
268      char get_wchar()
269              throws TypeMismatch;
270    
271      /**
272       * Extract the wide (usually UFT-16) string that is expected to be
273       * stored in this DynAny.
274       *
275       * @throws TypeMismatch if this DynAny holds the value of the
276       * different type.
277       */
278      String get_wstring()
279                  throws TypeMismatch;
280    
281      /**
282       * Insert the {@link Any} value into the enclosed
283       * {@link Any} inside this DynAny.
284       *
285       * @param an_any the value being inserted.
286       * @throws InvalidValue if the value type does not match the
287       * typecode of the enclosed {@link Any}.
288       */
289      void insert_any(Any an_any)
290               throws InvalidValue;
291    
292      /**
293       * Insert the boolean value into the enclosed
294       * {@link Any} inside this DynAny
295       * @param a_x the value being inserted.
296       * @throws InvalidValue if the value type does not match the
297       * typecode of the enclosed {@link Any}.
298       */
299      void insert_boolean(boolean a_x)
300                   throws InvalidValue;
301    
302      /**
303       * Insert the char value into the enclosed
304       * {@link Any} inside this DynAny
305       * @param a_x the value being inserted.
306       * @throws InvalidValue if the value type does not match the
307       * typecode of the enclosed {@link Any}.
308       */
309      void insert_char(char a_x)
310                throws InvalidValue;
311    
312      /**
313       * Insert the double value into the enclosed
314       * {@link Any} inside this DynAny
315       * @param a_x the value being inserted.
316       * @throws InvalidValue if the value type does not match the
317       * typecode of the enclosed {@link Any}.
318       */
319      void insert_double(double a_x)
320                  throws InvalidValue;
321    
322      /**
323       * Insert the float value into the enclosed
324       * {@link Any} inside this DynAny
325       * @param a_x the value being inserted.
326       * @throws InvalidValue if the value type does not match the
327       * typecode of the enclosed {@link Any}.
328       */
329      void insert_float(float a_x)
330                 throws InvalidValue;
331    
332      /**
333       * Insert the int (CORBA long) value into the enclosed
334       * {@link Any} inside this DynAny
335       * @param a_x the value being inserted.
336       * @throws InvalidValue if the value type does not match the
337       * typecode of the enclosed {@link Any}.
338       */
339      void insert_long(int a_x)
340                throws InvalidValue;
341    
342      /**
343       * Insert the long (CORBA long long) value into the enclosed
344       * {@link Any} inside this DynAny
345       * @param a_x the value being inserted.
346       * @throws InvalidValue if the value type does not match the
347       * typecode of the enclosed {@link Any}.
348       */
349      void insert_longlong(long a_x)
350                    throws InvalidValue;
351    
352      /**
353       * Insert the byte (CORBA octet) value into the enclosed
354       * {@link Any} inside this DynAny
355       * @param a_x the value being inserted.
356       * @throws InvalidValue if the value type does not match the
357       * typecode of the enclosed {@link Any}.
358       */
359      void insert_octet(byte a_x)
360                 throws InvalidValue;
361    
362      /**
363       * Insert the object reference into the enclosed
364       * {@link Any} inside this DynAny
365       * @param a_x the value being inserted.
366       * @throws InvalidValue if the value type does not match the
367       * typecode of the enclosed {@link Any}.
368       */
369      void insert_reference(Object a_x)
370                     throws InvalidValue;
371    
372      /**
373       * Insert the <code>short</code> value into the enclosed
374       * {@link Any} inside this DynAny
375       * @param a_x the value being inserted.
376       * @throws InvalidValue if the value type does not match the
377       * typecode of the enclosed {@link Any}.
378       */
379      void insert_short(short a_x)
380                 throws InvalidValue;
381    
382      /**
383       * Insert the string value into the enclosed
384       * {@link Any} inside this DynAny
385       * @param a_x the value being inserted.
386       * @throws InvalidValue if the value type does not match the
387       * typecode of the enclosed {@link Any}.
388       */
389      void insert_string(String a_x)
390                  throws InvalidValue;
391    
392      /**
393       * Insert the {@link TypeCode} value into the enclosed
394       * {@link Any} inside this DynAny
395       * @param a_x the value being inserted.
396       * @throws InvalidValue if the value type does not match the
397       * typecode of the enclosed {@link Any}.
398       */
399      void insert_typecode(TypeCode a_x)
400                    throws InvalidValue;
401    
402      /**
403       * Insert the int (CORBA unsinged long) value into the enclosed
404       * {@link Any} inside this DynAny
405       * @param a_x the value being inserted.
406       * @throws InvalidValue if the value type does not match the
407       * typecode of the enclosed {@link Any}.
408       */
409      void insert_ulong(int a_x)
410                 throws InvalidValue;
411    
412      /**
413       * Insert the long (CORBA unsigned long long) value into the enclosed
414       * {@link Any} inside this DynAny
415       * @param a_x the value being inserted.
416       * @throws InvalidValue if the value type does not match the
417       * typecode of the enclosed {@link Any}.
418       */
419      void insert_ulonglong(long a_x)
420                     throws InvalidValue;
421    
422      /**
423       * Insert the short (CORBA unsigned short) value into the enclosed
424       * {@link Any} inside this DynAny
425       * @param a_x the value being inserted.
426       * @throws InvalidValue if the value type does not match the
427       * typecode of the enclosed {@link Any}.
428       */
429      void insert_ushort(short a_x)
430                  throws InvalidValue;
431    
432      /**
433       * Insert the value into the enclosed
434       * {@link Any} inside this DynAny
435       * @param a_x the value being inserted.
436       * @throws InvalidValue if the value type does not match the
437       * typecode of the enclosed {@link Any}.
438       */
439      void insert_val(Serializable a_x)
440               throws InvalidValue;
441    
442      /**
443       * Insert the wide char (usually UTF-16) value into the enclosed
444       * {@link Any} inside this DynAny
445       * @param a_x the value being inserted.
446       * @throws InvalidValue if the value type does not match the
447       * typecode of the enclosed {@link Any}.
448       */
449      void insert_wchar(char a_x)
450                 throws InvalidValue;
451    
452      /**
453       * Insert the wide string (usually UTF-16) into the enclosed
454       * {@link Any} inside this DynAny
455       * @param a_x the value being inserted.
456       * @throws InvalidValue if the value type does not match the
457       * typecode of the enclosed {@link Any}.
458       */
459      void insert_wstring(String a_x)
460                   throws InvalidValue;
461    
462      /**
463       * Advances the internal pointer, described in the {@link #current_component},
464       * one position forward.
465       *
466       * @return true if the pointer now points to the new component,
467       * false if there are no more components of this DynAny holds
468       * a basic type that is not divided into components.
469       */
470      boolean next();
471    
472      /**
473       * Moves the internal pointer, described in the {@link #current_component},
474       * to the first component.
475       */
476      void rewind();
477    
478      /**
479       * Moves the internal pointer, described in the {@link #current_component},
480       * to the given position.
481       *
482       * @param p the number of the internal component on that the internal
483       * pointer must be focused.
484       *
485       * @return true on success or false if there is no component with the
486       * given number. If the DynAny holds the basic type, this method returs
487       * false p values other than 0.
488       */
489      boolean seek(int p);
490    
491      /**
492       * Returns the enclosed {@link Any}.
493       *
494       * @return the enclosed {@link Any}.
495       */
496      Any to_any()
497          throws Invalid;
498    
499      /**
500       * Returns the typecode of the object, inserted into this
501       * DynAny.
502       *
503       * @return the typecode of the inserted {@link Any} or null typecode
504       * if no {@link Any has been yet inserted}.
505       */
506      TypeCode type();
507    }