1 /* gnuDynAny.java --
2    Copyright (C) 2005 Free Software Foundation, Inc.
3 
4 This file is part of GNU Classpath.
5 
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.
10 
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.
15 
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.
20 
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.
25 
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. */
37 
38 
39 package gnu.CORBA.DynAn;
40 
41 import gnu.CORBA.CDR.BufferedCdrOutput;
42 import gnu.CORBA.OctetHolder;
43 import gnu.CORBA.Unexpected;
44 import gnu.CORBA.WCharHolder;
45 import gnu.CORBA.WStringHolder;
46 import gnu.CORBA.HolderLocator;
47 import gnu.CORBA.TypeKindNamer;
48 import gnu.CORBA.GeneralHolder;
49 
50 import org.omg.CORBA.Any;
51 import org.omg.CORBA.AnyHolder;
52 import org.omg.CORBA.BooleanHolder;
53 import org.omg.CORBA.CharHolder;
54 import org.omg.CORBA.DoubleHolder;
55 import org.omg.CORBA.FloatHolder;
56 import org.omg.CORBA.IntHolder;
57 import org.omg.CORBA.LongHolder;
58 import org.omg.CORBA.MARSHAL;
59 import org.omg.CORBA.ORB;
60 import org.omg.CORBA.Object;
61 import org.omg.CORBA.ObjectHolder;
62 import org.omg.CORBA.ShortHolder;
63 import org.omg.CORBA.StringHolder;
64 import org.omg.CORBA.TCKind;
65 import org.omg.CORBA.TypeCode;
66 import org.omg.CORBA.TypeCodeHolder;
67 import org.omg.CORBA.TypeCodePackage.BadKind;
68 import org.omg.CORBA.ValueBaseHolder;
69 import org.omg.CORBA.portable.InputStream;
70 import org.omg.CORBA.portable.OutputStream;
71 import org.omg.CORBA.portable.Streamable;
72 import org.omg.DynamicAny.DynAny;
73 import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
74 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
75 
76 import java.io.IOException;
77 import java.io.Serializable;
78 
79 import java.util.Arrays;
80 
81 /**
82  * The primitive dynamic Any holds the value basic final_type that cannot be
83  * traversed.
84  *
85  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
86  */
87 public class gnuDynAny extends AbstractAny implements DynAny, Serializable
88 {
89   /**
90    * Use serialVersionUID for interoperability.
91    */
92   private static final long serialVersionUID = 1;
93 
94   /**
95    * The enclosed Streamable, holding the actual value.
96    */
97   protected Streamable holder;
98 
99   /**
100    * Create DynAny providing the holder.
101    *
102    * @param a_holder
103    */
gnuDynAny(Streamable aHolder, TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, ORB anOrb )104   public gnuDynAny(Streamable aHolder, TypeCode oType, TypeCode aType,
105     gnuDynAnyFactory aFactory, ORB anOrb
106   )
107   {
108     super(oType, aType, aFactory, anOrb);
109     holder = aHolder;
110   }
111 
112   /**
113    * Assign the contents of the given {@link DynAny} to this DynAny.
114    *
115    * @param from the source to assign from.
116    */
assign(DynAny from)117   public void assign(DynAny from) throws TypeMismatch
118   {
119     checkType(official_type, from.type());
120 
121     if (from instanceof gnuDynAny)
122       holder = ((gnuDynAny) from).holder;
123     else
124       holder = from.to_any().extract_Streamable();
125     valueChanged();
126   }
127 
128   /**
129    * Create a copy of this {@link DynAny} via buffer read/write.
130    */
copy()131   public DynAny copy()
132   {
133     if (holder != null)
134       {
135         BufferedCdrOutput buffer = new BufferedCdrOutput();
136         holder._write(buffer);
137 
138         gnuDynAny other;
139         try
140           {
141             other =
142               new gnuDynAny((Streamable) (holder.getClass().newInstance()),
143                 official_type, final_type, factory, orb
144               );
145           }
146         catch (Exception e)
147           {
148             // Holder must have parameterless constructor.
149             throw new Unexpected(e);
150           }
151         other.holder._read(buffer.create_input_stream());
152         return other;
153       }
154     else
155       {
156         return new gnuDynAny(null, official_type, final_type, factory, orb);
157       }
158   }
159 
160   /**
161    * Always returns <code>null</code>.
162    *
163    * @return <code>null</code>, always.
164    */
current_component()165   public DynAny current_component() throws TypeMismatch
166   {
167     throw new TypeMismatch("Not applicable for " +
168       TypeKindNamer.nameIt(final_type)
169     );
170   }
171 
172   /**
173    * Returns without action, leaving all work to the garbage collector.
174    */
destroy()175   public void destroy()
176   {
177   }
178 
179   /**
180    * Takes the passed parameter as the enclosed {@link Any} reference.
181    *
182    * @param an_any the {@link Any} that will be used as an enclosed reference.
183    *
184    * @throws TypeMismatch if the final_type of the passed Any is not the same as
185    * the final_type, currently stored in this Any.
186    */
from_any(Any an_any)187   public void from_any(Any an_any) throws TypeMismatch, InvalidValue
188   {
189     checkType(official_type, an_any.type());
190 
191     Streamable a_holder = an_any.extract_Streamable();
192     if (a_holder == null)
193       {
194         throw new InvalidValue(ISNULL);
195       }
196     else if (a_holder instanceof GeneralHolder)
197       {
198         holder = HolderLocator.createHolder(official_type);
199         if (holder == null)
200           holder = HolderLocator.createHolder(final_type);
201 
202         if (holder == null)
203           holder = ((GeneralHolder) a_holder).Clone();
204         else
205           {
206             InputStream in = an_any.create_input_stream();
207             holder._read(in);
208             try
209               {
210                 in.close();
211               }
212             catch (IOException ex)
213               {
214                 throw new Unexpected(ex);
215               }
216           }
217       }
218     else
219       {
220         try
221           {
222             InputStream in = an_any.create_input_stream();
223             holder = (Streamable) a_holder.getClass().newInstance();
224             holder._read(in);
225             in.close();
226           }
227         catch (Exception ex)
228           {
229             TypeMismatch t = new TypeMismatch();
230             t.initCause(ex);
231             throw t;
232           }
233       }
234     valueChanged();
235   }
236 
237   /**
238    * Return the second (enclosed any) that is stored in the wrapped Any.
239    */
get_any()240   public Any get_any() throws TypeMismatch
241   {
242     try
243       {
244         return ((AnyHolder) holder).value;
245       }
246     catch (ClassCastException cex)
247       {
248         TypeMismatch m = new TypeMismatch();
249         m.initCause(cex);
250         throw m;
251       }
252   }
253 
254   /** {@inheritDoc} */
get_boolean()255   public boolean get_boolean() throws TypeMismatch
256   {
257     try
258       {
259         return ((BooleanHolder) holder).value;
260       }
261     catch (ClassCastException cex)
262       {
263         TypeMismatch m = new TypeMismatch();
264         m.initCause(cex);
265         throw m;
266       }
267   }
268 
269   /** {@inheritDoc} */
get_char()270   public char get_char() throws TypeMismatch
271   {
272     try
273       {
274         return ((CharHolder) holder).value;
275       }
276     catch (ClassCastException cex)
277       {
278         TypeMismatch m = new TypeMismatch();
279         m.initCause(cex);
280         throw m;
281       }
282   }
283 
284   /** {@inheritDoc} */
get_double()285   public double get_double() throws TypeMismatch
286   {
287     try
288       {
289         return ((DoubleHolder) holder).value;
290       }
291     catch (ClassCastException cex)
292       {
293         TypeMismatch m = new TypeMismatch();
294         m.initCause(cex);
295         throw m;
296       }
297   }
298 
299   /** {@inheritDoc} */
get_float()300   public float get_float() throws TypeMismatch
301   {
302     try
303       {
304         return ((FloatHolder) holder).value;
305       }
306     catch (ClassCastException cex)
307       {
308         TypeMismatch m = new TypeMismatch();
309         m.initCause(cex);
310         throw m;
311       }
312   }
313 
314   /** {@inheritDoc} */
get_long()315   public int get_long() throws TypeMismatch
316   {
317     try
318       {
319         return ((IntHolder) holder).value;
320       }
321     catch (ClassCastException cex)
322       {
323         TypeMismatch m = new TypeMismatch();
324         m.initCause(cex);
325         throw m;
326       }
327   }
328 
329   /** {@inheritDoc} */
get_longlong()330   public long get_longlong() throws TypeMismatch
331   {
332     try
333       {
334         return ((LongHolder) holder).value;
335       }
336     catch (ClassCastException cex)
337       {
338         TypeMismatch m = new TypeMismatch();
339         m.initCause(cex);
340         throw m;
341       }
342   }
343 
344   /** {@inheritDoc} */
get_octet()345   public byte get_octet() throws TypeMismatch
346   {
347     try
348       {
349         return ((OctetHolder) holder).value;
350       }
351     catch (ClassCastException cex)
352       {
353         TypeMismatch m = new TypeMismatch();
354         m.initCause(cex);
355         throw m;
356       }
357   }
358 
359   /** {@inheritDoc} */
get_reference()360   public Object get_reference() throws TypeMismatch
361   {
362     try
363       {
364         return ((ObjectHolder) holder).value;
365       }
366     catch (ClassCastException cex)
367       {
368         TypeMismatch m = new TypeMismatch();
369         m.initCause(cex);
370         throw m;
371       }
372   }
373 
374   /** {@inheritDoc} */
get_short()375   public short get_short() throws TypeMismatch
376   {
377     try
378       {
379         return ((ShortHolder) holder).value;
380       }
381     catch (ClassCastException cex)
382       {
383         TypeMismatch m = new TypeMismatch();
384         m.initCause(cex);
385         throw m;
386       }
387   }
388 
389   /** {@inheritDoc} */
get_string()390   public String get_string() throws TypeMismatch
391   {
392     try
393       {
394         return ((StringHolder) holder).value;
395       }
396     catch (ClassCastException cex)
397       {
398         TypeMismatch m = new TypeMismatch();
399         m.initCause(cex);
400         throw m;
401       }
402   }
403 
404   /** {@inheritDoc} */
get_typecode()405   public TypeCode get_typecode() throws TypeMismatch
406   {
407     try
408       {
409         return ((TypeCodeHolder) holder).value;
410       }
411     catch (ClassCastException cex)
412       {
413         TypeMismatch m = new TypeMismatch();
414         m.initCause(cex);
415         throw m;
416       }
417   }
418 
419   /** {@inheritDoc} */
get_ulong()420   public int get_ulong() throws TypeMismatch
421   {
422     check(TCKind.tk_ulong);
423     return get_long();
424   }
425 
426   /** {@inheritDoc} */
get_ulonglong()427   public long get_ulonglong() throws TypeMismatch
428   {
429     check(TCKind.tk_ulonglong);
430     return get_longlong();
431   }
432 
433   /** {@inheritDoc} */
get_ushort()434   public short get_ushort() throws TypeMismatch
435   {
436     check(TCKind.tk_ushort);
437     return get_short();
438   }
439 
440   /** {@inheritDoc} */
get_val()441   public Serializable get_val() throws TypeMismatch
442   {
443     try
444       {
445         return ((ValueBaseHolder) holder).value;
446       }
447     catch (ClassCastException cex)
448       {
449         TypeMismatch m = new TypeMismatch();
450         m.initCause(cex);
451         throw m;
452       }
453   }
454 
455   /** {@inheritDoc} */
get_wchar()456   public char get_wchar() throws TypeMismatch
457   {
458     try
459       {
460         return ((WCharHolder) holder).value;
461       }
462     catch (ClassCastException cex)
463       {
464         TypeMismatch m = new TypeMismatch();
465         m.initCause(cex);
466         throw m;
467       }
468   }
469 
470   /** {@inheritDoc} */
get_wstring()471   public String get_wstring() throws TypeMismatch
472   {
473     try
474       {
475         return ((WStringHolder) holder).value;
476       }
477     catch (ClassCastException cex)
478       {
479         TypeMismatch m = new TypeMismatch();
480         m.initCause(cex);
481         throw m;
482       }
483   }
484 
485   /** {@inheritDoc} */
insert_any(Any a_x)486   public void insert_any(Any a_x) throws TypeMismatch, InvalidValue
487   {
488     try
489       {
490         if (a_x.type().kind().value() == TCKind._tk_null)
491           ((AnyHolder) holder).value = a_x;
492         else
493           {
494             OutputStream buf = a_x.create_output_stream();
495             buf.write_any(a_x);
496             holder._read(buf.create_input_stream());
497             buf.close();
498           }
499         valueChanged();
500       }
501     catch (ClassCastException cex)
502       {
503         TypeMismatch t = new TypeMismatch();
504         t.initCause(cex);
505         throw t;
506       }
507     catch (MARSHAL m)
508       {
509         InvalidValue v = new InvalidValue();
510         v.initCause(m);
511         throw v;
512       }
513     catch (IOException ex)
514       {
515         throw new Unexpected(ex);
516       }
517   }
518 
519   /** {@inheritDoc} */
insert_boolean(boolean a_x)520   public void insert_boolean(boolean a_x) throws InvalidValue, TypeMismatch
521   {
522     try
523       {
524         ((BooleanHolder) holder).value = a_x;
525         valueChanged();
526       }
527     catch (ClassCastException cex)
528       {
529         TypeMismatch t = new TypeMismatch();
530         t.initCause(cex);
531         throw t;
532       }
533   }
534 
535   /** {@inheritDoc} */
insert_char(char a_x)536   public void insert_char(char a_x) throws InvalidValue, TypeMismatch
537   {
538     try
539       {
540         ((CharHolder) holder).value = a_x;
541         valueChanged();
542       }
543     catch (ClassCastException cex)
544       {
545         TypeMismatch t = new TypeMismatch();
546         t.initCause(cex);
547         throw t;
548       }
549   }
550 
551   /** {@inheritDoc} */
insert_double(double a_x)552   public void insert_double(double a_x) throws InvalidValue, TypeMismatch
553   {
554     try
555       {
556         ((DoubleHolder) holder).value = a_x;
557         valueChanged();
558       }
559     catch (ClassCastException cex)
560       {
561         TypeMismatch t = new TypeMismatch();
562         t.initCause(cex);
563         throw t;
564       }
565   }
566 
567   /** {@inheritDoc} */
insert_float(float a_x)568   public void insert_float(float a_x) throws InvalidValue, TypeMismatch
569   {
570     try
571       {
572         ((FloatHolder) holder).value = a_x;
573         valueChanged();
574       }
575     catch (ClassCastException cex)
576       {
577         TypeMismatch t = new TypeMismatch();
578         t.initCause(cex);
579         throw t;
580       }
581   }
582 
583   /** {@inheritDoc} */
insert_long(int a_x)584   public void insert_long(int a_x) throws InvalidValue, TypeMismatch
585   {
586     try
587       {
588         ((IntHolder) holder).value = a_x;
589         valueChanged();
590       }
591     catch (ClassCastException cex)
592       {
593         TypeMismatch t = new TypeMismatch();
594         t.initCause(cex);
595         throw t;
596       }
597   }
598 
599   /** {@inheritDoc} */
insert_longlong(long a_x)600   public void insert_longlong(long a_x) throws InvalidValue, TypeMismatch
601   {
602     try
603       {
604         ((LongHolder) holder).value = a_x;
605         valueChanged();
606       }
607     catch (ClassCastException cex)
608       {
609         TypeMismatch t = new TypeMismatch();
610         t.initCause(cex);
611         throw t;
612       }
613   }
614 
615   /** {@inheritDoc} */
insert_octet(byte a_x)616   public void insert_octet(byte a_x) throws InvalidValue, TypeMismatch
617   {
618     try
619       {
620         ((OctetHolder) holder).value = a_x;
621         valueChanged();
622       }
623     catch (ClassCastException cex)
624       {
625         TypeMismatch t = new TypeMismatch();
626         t.initCause(cex);
627         throw t;
628       }
629   }
630 
631   /** {@inheritDoc} */
insert_reference(Object a_x)632   public void insert_reference(Object a_x) throws InvalidValue, TypeMismatch
633   {
634     try
635       {
636         ((ObjectHolder) holder).value = a_x;
637         valueChanged();
638       }
639     catch (ClassCastException cex)
640       {
641         TypeMismatch t = new TypeMismatch();
642         t.initCause(cex);
643         throw t;
644       }
645   }
646 
647   /** {@inheritDoc} */
insert_short(short a_x)648   public void insert_short(short a_x) throws InvalidValue, TypeMismatch
649   {
650     try
651       {
652         ((ShortHolder) holder).value = a_x;
653         valueChanged();
654       }
655     catch (ClassCastException cex)
656       {
657         TypeMismatch t = new TypeMismatch();
658         t.initCause(cex);
659         throw t;
660       }
661   }
662 
663   /** {@inheritDoc} */
insert_string(String a_x)664   public void insert_string(String a_x) throws InvalidValue, TypeMismatch
665   {
666     try
667       {
668         if (a_x != null &&
669           final_type.length() > 0 &&
670           a_x.length() > final_type.length()
671         )
672           throw new InvalidValue(a_x.length() + " exceeds bound, " +
673             final_type.length()
674           );
675         ((StringHolder) holder).value = a_x;
676         valueChanged();
677       }
678     catch (ClassCastException cex)
679       {
680         TypeMismatch t = new TypeMismatch();
681         t.initCause(cex);
682         throw t;
683       }
684     catch (BadKind e)
685       {
686         TypeMismatch t = new TypeMismatch();
687         t.initCause(e);
688         throw t;
689       }
690   }
691 
692   /** {@inheritDoc} */
insert_typecode(TypeCode a_x)693   public void insert_typecode(TypeCode a_x) throws InvalidValue, TypeMismatch
694   {
695     try
696       {
697         ((TypeCodeHolder) holder).value = a_x;
698         valueChanged();
699       }
700     catch (ClassCastException cex)
701       {
702         TypeMismatch t = new TypeMismatch();
703         t.initCause(cex);
704         throw t;
705       }
706   }
707 
708   /** {@inheritDoc} */
insert_ulong(int a_x)709   public void insert_ulong(int a_x) throws InvalidValue, TypeMismatch
710   {
711     try
712       {
713         ((IntHolder) holder).value = a_x;
714         valueChanged();
715       }
716     catch (ClassCastException cex)
717       {
718         TypeMismatch t = new TypeMismatch();
719         t.initCause(cex);
720         throw t;
721       }
722   }
723 
724   /** {@inheritDoc} */
insert_ulonglong(long a_x)725   public void insert_ulonglong(long a_x) throws InvalidValue, TypeMismatch
726   {
727     try
728       {
729         ((LongHolder) holder).value = a_x;
730         valueChanged();
731       }
732     catch (ClassCastException cex)
733       {
734         TypeMismatch t = new TypeMismatch();
735         t.initCause(cex);
736         throw t;
737       }
738   }
739 
740   /** {@inheritDoc} */
insert_ushort(short a_x)741   public void insert_ushort(short a_x) throws InvalidValue, TypeMismatch
742   {
743     try
744       {
745         ((ShortHolder) holder).value = a_x;
746         valueChanged();
747       }
748     catch (ClassCastException cex)
749       {
750         TypeMismatch t = new TypeMismatch();
751         t.initCause(cex);
752         throw t;
753       }
754   }
755 
756   /** {@inheritDoc} */
insert_val(Serializable a_x)757   public void insert_val(Serializable a_x) throws InvalidValue, TypeMismatch
758   {
759     try
760       {
761         ((ValueBaseHolder) holder).value = a_x;
762         valueChanged();
763       }
764     catch (ClassCastException cex)
765       {
766         TypeMismatch t = new TypeMismatch();
767         t.initCause(cex);
768         throw t;
769       }
770   }
771 
772   /** {@inheritDoc} */
insert_wchar(char a_x)773   public void insert_wchar(char a_x) throws InvalidValue, TypeMismatch
774   {
775     try
776       {
777         ((WCharHolder) holder).value = a_x;
778         valueChanged();
779       }
780     catch (ClassCastException cex)
781       {
782         TypeMismatch t = new TypeMismatch();
783         t.initCause(cex);
784         throw t;
785       }
786   }
787 
788   /** {@inheritDoc} */
insert_wstring(String a_x)789   public void insert_wstring(String a_x) throws InvalidValue, TypeMismatch
790   {
791     try
792       {
793         if (a_x != null &&
794           final_type.length() > 0 &&
795           a_x.length() > type().length()
796         )
797           throw new InvalidValue(a_x.length() + " exceeds bound, " +
798             final_type.length()
799           );
800         ((WStringHolder) holder).value = a_x;
801         valueChanged();
802       }
803     catch (ClassCastException cex)
804       {
805         TypeMismatch t = new TypeMismatch();
806         t.initCause(cex);
807         throw t;
808       }
809     catch (BadKind e)
810       {
811         TypeMismatch t = new TypeMismatch();
812         t.initCause(e);
813         throw t;
814       }
815   }
816 
817   /**
818    * The objects, enclosed inside this class, have only one component (self).
819    *
820    * @return false, always (no other action).
821    */
next()822   public boolean next()
823   {
824     return false;
825   }
826 
827   /**
828    * Returns without action.
829    */
rewind()830   public void rewind()
831   {
832   }
833 
834   /**
835    * This objects, stored in this wrapper, never have multiple internal
836    * components to seek.
837    *
838    * @return false, always (no other action).
839    */
seek(int p)840   public boolean seek(int p)
841   {
842     return false;
843   }
844 
845   /**
846    * Returns the enclosed {@link Any}.
847    *
848    * @return the enclosed {@link Any}.
849    */
to_any()850   public Any to_any()
851   {
852     Any a = createAny();
853     a.insert_Streamable(holder);
854     a.type(official_type);
855     return a;
856   }
857 
858   /** {@inheritDoc} */
type()859   public TypeCode type()
860   {
861     return official_type;
862   }
863 
864   /**
865    * Compute hashcode in a trivial way.
866    */
getHashCodeSimple(int maximum)867   protected int getHashCodeSimple(int maximum)
868   {
869     int h = super.hashCode() / 2;
870     if (h < 0)
871       h = -h;
872     return h % maximum;
873   }
874 
875   /**
876    * Inserts Any, contained in the parameter, into Any, contained in this
877    * DynAny.
878    */
insert_dyn_any(DynAny d)879   public void insert_dyn_any(DynAny d) throws TypeMismatch, InvalidValue
880   {
881     check(d.type().kind());
882 
883     Any a = d.to_any();
884     holder = a.extract_Streamable();
885     valueChanged();
886   }
887 
888   /**
889    * Checks for equality. The DynAnys are equal if the stored Anys are equal.
890    */
equal(DynAny other)891   public boolean equal(DynAny other)
892   {
893     if (other instanceof AbstractAny)
894       {
895         if (other instanceof gnuDynAny)
896           {
897             gnuDynAny x = (gnuDynAny) other;
898 
899             if (!x.holder.getClass().equals(holder.getClass()))
900               return false;
901 
902             BufferedCdrOutput b1 = new BufferedCdrOutput();
903             x.holder._write(b1);
904 
905             BufferedCdrOutput b2 = new BufferedCdrOutput(b1.buffer.size() + 10);
906             holder._write(b2);
907 
908             return Arrays.equals(b1.buffer.toByteArray(),
909               b2.buffer.toByteArray()
910             );
911           }
912         else
913           return false;
914       }
915     if (other == null)
916       return false;
917     else if (other.component_count() != component_count() ||
918       !official_type.equal(other.type())
919     )
920       return false;
921     else
922       return other.to_any().equal(to_any());
923   }
924 
925   /**
926    * This final_type has no components.
927    *
928    * @return 0, always.
929    */
component_count()930   public int component_count()
931   {
932     return 0;
933   }
934 
get_dyn_any()935   public DynAny get_dyn_any() throws TypeMismatch, InvalidValue
936   {
937     return new gnuDynAny(holder, official_type, final_type, factory, orb);
938   }
939 
check(TCKind t)940   private void check(TCKind t) throws TypeMismatch
941   {
942     if (t.value() != final_type.kind().value())
943       throw new TypeMismatch(t.value() + "!=" + final_type.kind().value());
944   }
945 }
946