1. /*
  2. * @(#)DynStructImpl.java 1.8 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.dynamicany;
  8. import org.omg.CORBA.TypeCode;
  9. import org.omg.CORBA.TCKind;
  10. import org.omg.CORBA.Any;
  11. import org.omg.CORBA.TypeCodePackage.BadKind;
  12. import org.omg.CORBA.TypeCodePackage.Bounds;
  13. import org.omg.DynamicAny.*;
  14. import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
  15. import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
  16. import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
  17. import com.sun.corba.se.spi.orb.ORB ;
  18. import com.sun.corba.se.spi.logging.CORBALogDomains ;
  19. import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  20. public class DynStructImpl extends DynAnyComplexImpl implements DynStruct
  21. {
  22. //
  23. // Constructors
  24. //
  25. private DynStructImpl() {
  26. this(null, (Any)null, false);
  27. }
  28. protected DynStructImpl(ORB orb, Any any, boolean copyValue) {
  29. // We can be sure that typeCode is of kind tk_struct
  30. super(orb, any, copyValue);
  31. // Initialize components lazily, on demand.
  32. // This is an optimization in case the user is only interested in storing Anys.
  33. }
  34. protected DynStructImpl(ORB orb, TypeCode typeCode) {
  35. // We can be sure that typeCode is of kind tk_struct
  36. super(orb, typeCode);
  37. // For DynStruct, the operation sets the current position to -1
  38. // for empty exceptions and to zero for all other TypeCodes.
  39. // The members (if any) are (recursively) initialized to their default values.
  40. index = 0;
  41. }
  42. //
  43. // Methods differing from DynValues
  44. //
  45. public org.omg.DynamicAny.NameValuePair[] get_members () {
  46. if (status == STATUS_DESTROYED) {
  47. throw wrapper.dynAnyDestroyed() ;
  48. }
  49. checkInitComponents();
  50. return nameValuePairs;
  51. }
  52. public org.omg.DynamicAny.NameDynAnyPair[] get_members_as_dyn_any () {
  53. if (status == STATUS_DESTROYED) {
  54. throw wrapper.dynAnyDestroyed() ;
  55. }
  56. checkInitComponents();
  57. return nameDynAnyPairs;
  58. }
  59. }