1 /*
   2  * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.corba.se.impl.dynamicany;
  27 
  28 import org.omg.CORBA.Any;
  29 import org.omg.CORBA.TypeCode;
  30 import org.omg.CORBA.portable.OutputStream;
  31 import org.omg.DynamicAny.*;
  32 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
  33 import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
  34 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
  35 import com.sun.corba.se.impl.corba.TypeCodeImpl;        // needed for recursive type codes
  36 
  37 import com.sun.corba.se.spi.orb.ORB ;
  38 import com.sun.corba.se.spi.logging.CORBALogDomains ;
  39 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  40 
  41 abstract class DynAnyConstructedImpl extends DynAnyImpl
  42 {
  43     protected static final byte REPRESENTATION_NONE = 0;
  44     protected static final byte REPRESENTATION_TYPECODE = 1;
  45     protected static final byte REPRESENTATION_ANY = 2;
  46     protected static final byte REPRESENTATION_COMPONENTS = 4;
  47 
  48     protected static final byte RECURSIVE_UNDEF = -1;
  49     protected static final byte RECURSIVE_NO = 0;
  50     protected static final byte RECURSIVE_YES = 1;
  51 
  52     protected static final DynAny[] emptyComponents = new DynAny[0];
  53     //
  54     // Instance variables
  55     //
  56 
  57     // Constructed DynAnys maintain an ordered collection of component DynAnys.
  58     DynAny[] components = emptyComponents;
  59     byte representations = REPRESENTATION_NONE;
  60     byte isRecursive = RECURSIVE_UNDEF;
  61 
  62     //
  63     // Constructors
  64     //
  65 
  66     private DynAnyConstructedImpl() {
  67         this(null, (Any)null, false);
  68     }
  69 
  70     protected DynAnyConstructedImpl(ORB orb, Any any, boolean copyValue) {
  71         super(orb, any, copyValue);
  72         //System.out.println(this + " constructed with any " + any);
  73         if (this.any != null) {
  74             representations = REPRESENTATION_ANY;
  75         }
  76         // set the current position to 0 if any has components, otherwise to -1.
  77         index = 0;
  78     }
  79 
  80     protected DynAnyConstructedImpl(ORB orb, TypeCode typeCode) {
  81         // assertion: typeCode has been checked to be valid for this particular subclass.
  82         // note: We don't copy TypeCodes since they are considered immutable.
  83         super(orb, typeCode);
  84         if (typeCode != null) {
  85             representations = REPRESENTATION_TYPECODE;
  86         }
  87         // set the current position to 0 if any has components, otherwise to -1.
  88         index = NO_INDEX;
  89 
  90         // _REVISIT_ Would need REPRESENTATION_TYPECODE for lazy initialization
  91         //if ( ! isRecursive()) {
  92         //    initializeComponentsFromTypeCode();
  93         //}
  94     }
  95 
  96     protected boolean isRecursive() {
  97         if (isRecursive == RECURSIVE_UNDEF) {
  98             TypeCode typeCode = any.type();
  99             if (typeCode instanceof TypeCodeImpl) {
 100                 if (((TypeCodeImpl)typeCode).is_recursive())
 101                     isRecursive = RECURSIVE_YES;
 102                 else
 103                     isRecursive = RECURSIVE_NO;
 104             } else {
 105                 // No way to find out unless the TypeCode spec changes.
 106                 isRecursive = RECURSIVE_NO;
 107             }
 108         }
 109         return (isRecursive == RECURSIVE_YES);
 110     }
 111 
 112     //
 113     // DynAny traversal methods
 114     //
 115 
 116     public org.omg.DynamicAny.DynAny current_component()
 117         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
 118     {
 119         if (status == STATUS_DESTROYED) {
 120             throw wrapper.dynAnyDestroyed() ;
 121         }
 122         if (index == NO_INDEX) {
 123             return null;
 124         }
 125         return (checkInitComponents() ? components[index] : null);
 126     }
 127 
 128     public int component_count() {
 129         if (status == STATUS_DESTROYED) {
 130             throw wrapper.dynAnyDestroyed() ;
 131         }
 132         return (checkInitComponents() ? components.length : 0);
 133     }
 134 
 135     public boolean next() {
 136         if (status == STATUS_DESTROYED) {
 137             throw wrapper.dynAnyDestroyed() ;
 138         }
 139         if (checkInitComponents() == false) {
 140             return false;
 141         }
 142         index++;
 143         if (index >= 0 && index < components.length) {
 144             return true;
 145         } else {
 146             index = NO_INDEX;
 147             return false;
 148         }
 149     }
 150 
 151     public boolean seek(int newIndex) {
 152         if (status == STATUS_DESTROYED) {
 153             throw wrapper.dynAnyDestroyed() ;
 154         }
 155         if (newIndex < 0) {
 156             this.index = NO_INDEX;
 157             return false;
 158         }
 159         if (checkInitComponents() == false) {
 160             return false;
 161         }
 162         if (newIndex < components.length) {
 163             index = newIndex;
 164             return true;
 165         }
 166         return false;
 167     }
 168 
 169     public void rewind() {
 170         if (status == STATUS_DESTROYED) {
 171             throw wrapper.dynAnyDestroyed() ;
 172         }
 173         this.seek(0);
 174     }
 175 
 176     //
 177     // Utility methods
 178     //
 179 
 180     protected void clearData() {
 181         super.clearData();
 182         // _REVISIT_ What about status?
 183         components = emptyComponents;
 184         index = NO_INDEX;
 185         representations = REPRESENTATION_NONE;
 186     }
 187 
 188     protected void writeAny(OutputStream out) {
 189         // If all we got is TypeCode representation (no value)
 190         // then we don't want to force creating a default value
 191         //System.out.println(this + " checkInitAny before writeAny");
 192         checkInitAny();
 193         super.writeAny(out);
 194     }
 195 
 196     // Makes sure that the components representation is initialized
 197     protected boolean checkInitComponents() {
 198         if ((representations & REPRESENTATION_COMPONENTS) == 0) {
 199             if ((representations & REPRESENTATION_ANY) != 0) {
 200                 if (initializeComponentsFromAny()) {
 201                     representations |= REPRESENTATION_COMPONENTS;
 202                 } else {
 203                     return false;
 204                 }
 205             } else if ((representations & REPRESENTATION_TYPECODE) != 0) {
 206                 if (initializeComponentsFromTypeCode()) {
 207                     representations |= REPRESENTATION_COMPONENTS;
 208                 } else {
 209                     return false;
 210                 }
 211             }
 212         }
 213         return true;
 214     }
 215 
 216     // Makes sure that the Any representation is initialized
 217     protected void checkInitAny() {
 218         if ((representations & REPRESENTATION_ANY) == 0) {
 219             //System.out.println(this + " checkInitAny: reps does not have REPRESENTATION_ANY");
 220             if ((representations & REPRESENTATION_COMPONENTS) != 0) {
 221                 //System.out.println(this + " checkInitAny: reps has REPRESENTATION_COMPONENTS");
 222                 if (initializeAnyFromComponents()) {
 223                     representations |= REPRESENTATION_ANY;
 224                 }
 225             } else if ((representations & REPRESENTATION_TYPECODE) != 0) {
 226                 //System.out.println(this + " checkInitAny: reps has REPRESENTATION_TYPECODE");
 227                 if (representations == REPRESENTATION_TYPECODE && isRecursive())
 228                     return;
 229                 if (initializeComponentsFromTypeCode()) {
 230                     representations |= REPRESENTATION_COMPONENTS;
 231                 }
 232                 if (initializeAnyFromComponents()) {
 233                     representations |= REPRESENTATION_ANY;
 234                 }
 235             }
 236         } else {
 237             //System.out.println(this + " checkInitAny: reps != REPRESENTATION_ANY");
 238         }
 239         return;
 240     }
 241 
 242     protected abstract boolean initializeComponentsFromAny();
 243     protected abstract boolean initializeComponentsFromTypeCode();
 244 
 245     // Collapses the whole DynAny hierarchys values into one single streamed Any
 246     protected boolean initializeAnyFromComponents() {
 247         //System.out.println(this + " initializeAnyFromComponents");
 248         OutputStream out = any.create_output_stream();
 249         for (int i=0; i<components.length; i++) {
 250             if (components[i] instanceof DynAnyImpl) {
 251                 ((DynAnyImpl)components[i]).writeAny(out);
 252             } else {
 253                 // Not our implementation. Nothing we can do to prevent copying.
 254                 components[i].to_any().write_value(out);
 255             }
 256         }
 257         any.read_value(out.create_input_stream(), any.type());
 258         return true;
 259     }
 260 
 261     //
 262     // DynAny interface methods
 263     //
 264 
 265     public void assign (org.omg.DynamicAny.DynAny dyn_any)
 266         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
 267     {
 268         if (status == STATUS_DESTROYED) {
 269             throw wrapper.dynAnyDestroyed() ;
 270         }
 271         clearData();
 272         super.assign(dyn_any);
 273         representations = REPRESENTATION_ANY;
 274         index = 0;
 275     }
 276 
 277     public void from_any (org.omg.CORBA.Any value)
 278         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 279                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 280     {
 281         if (status == STATUS_DESTROYED) {
 282             throw wrapper.dynAnyDestroyed() ;
 283         }
 284         clearData();
 285         super.from_any(value);
 286         representations = REPRESENTATION_ANY;
 287         index = 0;
 288     }
 289 
 290     // Spec: Returns a copy of the internal Any
 291     public org.omg.CORBA.Any to_any() {
 292         //System.out.println(this + " to_any ");
 293         if (status == STATUS_DESTROYED) {
 294             throw wrapper.dynAnyDestroyed() ;
 295         }
 296         checkInitAny();
 297         // Anys value may still be uninitialized if DynAny was initialized by TypeCode only
 298         return DynAnyUtil.copy(any, orb);
 299     }
 300 
 301     public boolean equal (org.omg.DynamicAny.DynAny dyn_any) {
 302         if (status == STATUS_DESTROYED) {
 303             throw wrapper.dynAnyDestroyed() ;
 304         }
 305         if (dyn_any == this) {
 306             return true;
 307         }
 308         if ( ! any.type().equal(dyn_any.type())) {
 309             return false;
 310         }
 311         // This changes the current position of dyn_any.
 312         // Make sure that our position isn't changed.
 313         if (checkInitComponents() == false) {
 314             return false;
 315         }
 316         DynAny currentComponent = null;
 317         try {
 318             // Remember the current position to restore it later
 319             currentComponent = dyn_any.current_component();
 320             for (int i=0; i<components.length; i++) {
 321                 if (dyn_any.seek(i) == false)
 322                     return false;
 323                 //System.out.println(this + " comparing component " + i + "=" + components[i] +
 324                 //                   " of type " + components[i].type().kind().value());
 325                 if ( ! components[i].equal(dyn_any.current_component())) {
 326                     //System.out.println("Not equal component " + i);
 327                     return false;
 328                 }
 329             }
 330         } catch (TypeMismatch tm) {
 331             // impossible, we checked the type codes already
 332         } finally {
 333             // Restore the current position of the other DynAny
 334             DynAnyUtil.set_current_component(dyn_any, currentComponent);
 335         }
 336         return true;
 337     }
 338 
 339     public void destroy() {
 340         if (status == STATUS_DESTROYED) {
 341             throw wrapper.dynAnyDestroyed() ;
 342         }
 343         if (status == STATUS_DESTROYABLE) {
 344             status = STATUS_DESTROYED;
 345             for (int i=0; i<components.length; i++) {
 346                 if (components[i] instanceof DynAnyImpl) {
 347                     ((DynAnyImpl)components[i]).setStatus(STATUS_DESTROYABLE);
 348                 }
 349                 components[i].destroy();
 350             }
 351         }
 352     }
 353 
 354     public org.omg.DynamicAny.DynAny copy() {
 355         if (status == STATUS_DESTROYED) {
 356             throw wrapper.dynAnyDestroyed() ;
 357         }
 358         checkInitAny();
 359         try {
 360             return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
 361         } catch (InconsistentTypeCode ictc) {
 362             return null; // impossible
 363         }
 364     }
 365 
 366     // getter / setter methods
 367 
 368     public void insert_boolean(boolean value)
 369         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 370                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 371     {
 372         if (status == STATUS_DESTROYED) {
 373             throw wrapper.dynAnyDestroyed() ;
 374         }
 375         if (index == NO_INDEX)
 376             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 377         DynAny currentComponent = current_component();
 378         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 379             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 380         currentComponent.insert_boolean(value);
 381     }
 382 
 383     public void insert_octet(byte value)
 384         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 385                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 386     {
 387         if (status == STATUS_DESTROYED) {
 388             throw wrapper.dynAnyDestroyed() ;
 389         }
 390         if (index == NO_INDEX)
 391             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 392         DynAny currentComponent = current_component();
 393         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 394             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 395         currentComponent.insert_octet(value);
 396     }
 397 
 398     public void insert_char(char value)
 399         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 400                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 401     {
 402         if (status == STATUS_DESTROYED) {
 403             throw wrapper.dynAnyDestroyed() ;
 404         }
 405         if (index == NO_INDEX)
 406             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 407         DynAny currentComponent = current_component();
 408         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 409             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 410         currentComponent.insert_char(value);
 411     }
 412 
 413     public void insert_short(short value)
 414         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 415                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 416     {
 417         if (status == STATUS_DESTROYED) {
 418             throw wrapper.dynAnyDestroyed() ;
 419         }
 420         if (index == NO_INDEX)
 421             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 422         DynAny currentComponent = current_component();
 423         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 424             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 425         currentComponent.insert_short(value);
 426     }
 427 
 428     public void insert_ushort(short value)
 429         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 430                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 431     {
 432         if (status == STATUS_DESTROYED) {
 433             throw wrapper.dynAnyDestroyed() ;
 434         }
 435         if (index == NO_INDEX)
 436             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 437         DynAny currentComponent = current_component();
 438         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 439             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 440         currentComponent.insert_ushort(value);
 441     }
 442 
 443     public void insert_long(int value)
 444         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 445                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 446     {
 447         if (status == STATUS_DESTROYED) {
 448             throw wrapper.dynAnyDestroyed() ;
 449         }
 450         if (index == NO_INDEX)
 451             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 452         DynAny currentComponent = current_component();
 453         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 454             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 455         currentComponent.insert_long(value);
 456     }
 457 
 458     public void insert_ulong(int value)
 459         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 460                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 461     {
 462         if (status == STATUS_DESTROYED) {
 463             throw wrapper.dynAnyDestroyed() ;
 464         }
 465         if (index == NO_INDEX)
 466             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 467         DynAny currentComponent = current_component();
 468         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 469             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 470         currentComponent.insert_ulong(value);
 471     }
 472 
 473     public void insert_float(float value)
 474         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 475                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 476     {
 477         if (status == STATUS_DESTROYED) {
 478             throw wrapper.dynAnyDestroyed() ;
 479         }
 480         if (index == NO_INDEX)
 481             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 482         DynAny currentComponent = current_component();
 483         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 484             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 485         currentComponent.insert_float(value);
 486     }
 487 
 488     public void insert_double(double value)
 489         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 490                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 491     {
 492         if (status == STATUS_DESTROYED) {
 493             throw wrapper.dynAnyDestroyed() ;
 494         }
 495         if (index == NO_INDEX)
 496             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 497         DynAny currentComponent = current_component();
 498         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 499             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 500         currentComponent.insert_double(value);
 501     }
 502 
 503     public void insert_string(String value)
 504         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 505                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 506     {
 507         if (status == STATUS_DESTROYED) {
 508             throw wrapper.dynAnyDestroyed() ;
 509         }
 510         if (index == NO_INDEX)
 511             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 512         DynAny currentComponent = current_component();
 513         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 514             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 515         currentComponent.insert_string(value);
 516     }
 517 
 518     public void insert_reference(org.omg.CORBA.Object value)
 519         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 520                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 521     {
 522         if (status == STATUS_DESTROYED) {
 523             throw wrapper.dynAnyDestroyed() ;
 524         }
 525         if (index == NO_INDEX)
 526             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 527         DynAny currentComponent = current_component();
 528         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 529             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 530         currentComponent.insert_reference(value);
 531     }
 532 
 533     public void insert_typecode(org.omg.CORBA.TypeCode value)
 534         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 535                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 536     {
 537         if (status == STATUS_DESTROYED) {
 538             throw wrapper.dynAnyDestroyed() ;
 539         }
 540         if (index == NO_INDEX)
 541             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 542         DynAny currentComponent = current_component();
 543         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 544             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 545         currentComponent.insert_typecode(value);
 546     }
 547 
 548     public void insert_longlong(long value)
 549         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 550                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 551     {
 552         if (status == STATUS_DESTROYED) {
 553             throw wrapper.dynAnyDestroyed() ;
 554         }
 555         if (index == NO_INDEX)
 556             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 557         DynAny currentComponent = current_component();
 558         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 559             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 560         currentComponent.insert_longlong(value);
 561     }
 562 
 563     public void insert_ulonglong(long value)
 564         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 565                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 566     {
 567         if (status == STATUS_DESTROYED) {
 568             throw wrapper.dynAnyDestroyed() ;
 569         }
 570         if (index == NO_INDEX)
 571             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 572         DynAny currentComponent = current_component();
 573         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 574             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 575         currentComponent.insert_ulonglong(value);
 576     }
 577 
 578     public void insert_wchar(char value)
 579         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 580                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 581     {
 582         if (status == STATUS_DESTROYED) {
 583             throw wrapper.dynAnyDestroyed() ;
 584         }
 585         if (index == NO_INDEX)
 586             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 587         DynAny currentComponent = current_component();
 588         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 589             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 590         currentComponent.insert_wchar(value);
 591     }
 592 
 593     public void insert_wstring(String value)
 594         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 595                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 596     {
 597         if (status == STATUS_DESTROYED) {
 598             throw wrapper.dynAnyDestroyed() ;
 599         }
 600         if (index == NO_INDEX)
 601             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 602         DynAny currentComponent = current_component();
 603         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 604             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 605         currentComponent.insert_wstring(value);
 606     }
 607 
 608     public void insert_any(org.omg.CORBA.Any value)
 609         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 610                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 611     {
 612         if (status == STATUS_DESTROYED) {
 613             throw wrapper.dynAnyDestroyed() ;
 614         }
 615         if (index == NO_INDEX)
 616             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 617         DynAny currentComponent = current_component();
 618         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 619             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 620         currentComponent.insert_any(value);
 621     }
 622 
 623     public void insert_dyn_any (org.omg.DynamicAny.DynAny value)
 624         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 625                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 626     {
 627         if (status == STATUS_DESTROYED) {
 628             throw wrapper.dynAnyDestroyed() ;
 629         }
 630         if (index == NO_INDEX)
 631             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 632         DynAny currentComponent = current_component();
 633         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 634             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 635         currentComponent.insert_dyn_any(value);
 636     }
 637 
 638     public void insert_val(java.io.Serializable value)
 639         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 640                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 641     {
 642         if (status == STATUS_DESTROYED) {
 643             throw wrapper.dynAnyDestroyed() ;
 644         }
 645         if (index == NO_INDEX)
 646             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 647         DynAny currentComponent = current_component();
 648         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 649             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 650         currentComponent.insert_val(value);
 651     }
 652 
 653     public java.io.Serializable get_val()
 654         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 655                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 656     {
 657         if (status == STATUS_DESTROYED) {
 658             throw wrapper.dynAnyDestroyed() ;
 659         }
 660         if (index == NO_INDEX)
 661             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 662         DynAny currentComponent = current_component();
 663         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 664             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 665         return currentComponent.get_val();
 666     }
 667 
 668     public boolean get_boolean()
 669         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 670                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 671     {
 672         if (status == STATUS_DESTROYED) {
 673             throw wrapper.dynAnyDestroyed() ;
 674         }
 675         if (index == NO_INDEX)
 676             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 677         DynAny currentComponent = current_component();
 678         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 679             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 680         return currentComponent.get_boolean();
 681     }
 682 
 683     public byte get_octet()
 684         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 685                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 686     {
 687         if (status == STATUS_DESTROYED) {
 688             throw wrapper.dynAnyDestroyed() ;
 689         }
 690         if (index == NO_INDEX)
 691             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 692         DynAny currentComponent = current_component();
 693         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 694             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 695         return currentComponent.get_octet();
 696     }
 697 
 698     public char get_char()
 699         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 700                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 701     {
 702         if (status == STATUS_DESTROYED) {
 703             throw wrapper.dynAnyDestroyed() ;
 704         }
 705         if (index == NO_INDEX)
 706             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 707         DynAny currentComponent = current_component();
 708         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 709             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 710         return currentComponent.get_char();
 711     }
 712 
 713     public short get_short()
 714         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 715                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 716     {
 717         if (status == STATUS_DESTROYED) {
 718             throw wrapper.dynAnyDestroyed() ;
 719         }
 720         if (index == NO_INDEX)
 721             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 722         DynAny currentComponent = current_component();
 723         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 724             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 725         return currentComponent.get_short();
 726     }
 727 
 728     public short get_ushort()
 729         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 730                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 731     {
 732         if (status == STATUS_DESTROYED) {
 733             throw wrapper.dynAnyDestroyed() ;
 734         }
 735         if (index == NO_INDEX)
 736             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 737         DynAny currentComponent = current_component();
 738         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 739             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 740         return currentComponent.get_ushort();
 741     }
 742 
 743     public int get_long()
 744         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 745                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 746     {
 747         if (status == STATUS_DESTROYED) {
 748             throw wrapper.dynAnyDestroyed() ;
 749         }
 750         if (index == NO_INDEX)
 751             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 752         DynAny currentComponent = current_component();
 753         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 754             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 755         return currentComponent.get_long();
 756     }
 757 
 758     public int get_ulong()
 759         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 760                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 761     {
 762         if (status == STATUS_DESTROYED) {
 763             throw wrapper.dynAnyDestroyed() ;
 764         }
 765         if (index == NO_INDEX)
 766             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 767         DynAny currentComponent = current_component();
 768         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 769             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 770         return currentComponent.get_ulong();
 771     }
 772 
 773     public float get_float()
 774         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 775                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 776     {
 777         if (status == STATUS_DESTROYED) {
 778             throw wrapper.dynAnyDestroyed() ;
 779         }
 780         if (index == NO_INDEX)
 781             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 782         DynAny currentComponent = current_component();
 783         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 784             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 785         return currentComponent.get_float();
 786     }
 787 
 788     public double get_double()
 789         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 790                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 791     {
 792         if (status == STATUS_DESTROYED) {
 793             throw wrapper.dynAnyDestroyed() ;
 794         }
 795         if (index == NO_INDEX)
 796             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 797         DynAny currentComponent = current_component();
 798         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 799             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 800         return currentComponent.get_double();
 801     }
 802 
 803     public String get_string()
 804         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 805                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 806     {
 807         if (status == STATUS_DESTROYED) {
 808             throw wrapper.dynAnyDestroyed() ;
 809         }
 810         if (index == NO_INDEX)
 811             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 812         DynAny currentComponent = current_component();
 813         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 814             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 815         return currentComponent.get_string();
 816     }
 817 
 818     public org.omg.CORBA.Object get_reference()
 819         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 820                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 821     {
 822         if (status == STATUS_DESTROYED) {
 823             throw wrapper.dynAnyDestroyed() ;
 824         }
 825         if (index == NO_INDEX)
 826             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 827         DynAny currentComponent = current_component();
 828         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 829             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 830         return currentComponent.get_reference();
 831     }
 832 
 833     public org.omg.CORBA.TypeCode get_typecode()
 834         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 835                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 836     {
 837         if (status == STATUS_DESTROYED) {
 838             throw wrapper.dynAnyDestroyed() ;
 839         }
 840         if (index == NO_INDEX)
 841             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 842         DynAny currentComponent = current_component();
 843         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 844             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 845         return currentComponent.get_typecode();
 846     }
 847 
 848     public long get_longlong()
 849         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 850                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 851     {
 852         if (status == STATUS_DESTROYED) {
 853             throw wrapper.dynAnyDestroyed() ;
 854         }
 855         if (index == NO_INDEX)
 856             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 857         DynAny currentComponent = current_component();
 858         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 859             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 860         return currentComponent.get_longlong();
 861     }
 862 
 863     public long get_ulonglong()
 864         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 865                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 866     {
 867         if (status == STATUS_DESTROYED) {
 868             throw wrapper.dynAnyDestroyed() ;
 869         }
 870         if (index == NO_INDEX)
 871             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 872         DynAny currentComponent = current_component();
 873         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 874             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 875         return currentComponent.get_ulonglong();
 876     }
 877 
 878     public char get_wchar()
 879         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 880                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 881     {
 882         if (status == STATUS_DESTROYED) {
 883             throw wrapper.dynAnyDestroyed() ;
 884         }
 885         if (index == NO_INDEX)
 886             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 887         DynAny currentComponent = current_component();
 888         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 889             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 890         return currentComponent.get_wchar();
 891     }
 892 
 893     public String get_wstring()
 894         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 895                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 896     {
 897         if (status == STATUS_DESTROYED) {
 898             throw wrapper.dynAnyDestroyed() ;
 899         }
 900         if (index == NO_INDEX)
 901             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 902         DynAny currentComponent = current_component();
 903         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 904             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 905         return currentComponent.get_wstring();
 906     }
 907 
 908     public org.omg.CORBA.Any get_any()
 909         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 910                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 911     {
 912         if (status == STATUS_DESTROYED) {
 913             throw wrapper.dynAnyDestroyed() ;
 914         }
 915         if (index == NO_INDEX)
 916             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 917         DynAny currentComponent = current_component();
 918         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 919             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 920         return currentComponent.get_any();
 921     }
 922 
 923     public org.omg.DynamicAny.DynAny get_dyn_any()
 924         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
 925                org.omg.DynamicAny.DynAnyPackage.InvalidValue
 926     {
 927         if (status == STATUS_DESTROYED) {
 928             throw wrapper.dynAnyDestroyed() ;
 929         }
 930         if (index == NO_INDEX)
 931             throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
 932         DynAny currentComponent = current_component();
 933         if (DynAnyUtil.isConstructedDynAny(currentComponent))
 934             throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
 935         return currentComponent.get_dyn_any();
 936     }
 937 }