1. package org.omg.DynamicAny;
  2. /**
  3. * org/omg/DynamicAny/_DynAnyFactoryStub.java .
  4. * Generated by the IDL-to-Java compiler (portable), version "3.1"
  5. * from ../../../../src/share/classes/org/omg/DynamicAny/DynamicAny.idl
  6. * Monday, February 23, 2004 7:03:09 AM GMT
  7. */
  8. /**
  9. * DynAny objects can be created by invoking operations on the DynAnyFactory object.
  10. * Generally there are only two ways to create a DynAny object:
  11. * <UL>
  12. * <LI>invoking an operation on an existing DynAny object
  13. * <LI>invoking an operation on a DynAnyFactory object
  14. * </UL>
  15. * A constructed DynAny object supports operations that enable the creation of new DynAny
  16. * objects encapsulating access to the value of some constituent.
  17. * DynAny objects also support the copy operation for creating new DynAny objects.
  18. * A reference to the DynAnyFactory object is obtained by calling ORB.resolve_initial_references()
  19. * with the identifier parameter set to the string constant "DynAnyFactory".
  20. * <P>Dynamic interpretation of an any usually involves creating a DynAny object using create_dyn_any()
  21. * as the first step. Depending on the type of the any, the resulting DynAny object reference can be narrowed
  22. * to a DynFixed, DynStruct, DynSequence, DynArray, DynUnion, DynEnum, or DynValue object reference.
  23. * <P>Dynamic creation of an any involves creating a DynAny object using create_dyn_any_from_type_code(),
  24. * passing the TypeCode associated with the value to be created. The returned reference is narrowed to one of
  25. * the complex types, such as DynStruct, if appropriate. Then, the value can be initialized by means of
  26. * invoking operations on the resulting object. Finally, the to_any operation can be invoked
  27. * to create an any value from the constructed DynAny.
  28. */
  29. public class _DynAnyFactoryStub extends org.omg.CORBA.portable.ObjectImpl implements org.omg.DynamicAny.DynAnyFactory
  30. {
  31. final public static java.lang.Class _opsClass = DynAnyFactoryOperations.class;
  32. /**
  33. * Creates a new DynAny object from an any value.
  34. * A copy of the TypeCode associated with the any value is assigned to the resulting DynAny object.
  35. * The value associated with the DynAny object is a copy of the value in the original any.
  36. * The current position of the created DynAny is set to zero if the passed value has components,
  37. * to -1 otherwise
  38. *
  39. * @exception InconsistentTypeCode if value has a TypeCode with a TCKind of tk_Principal,
  40. * tk_native, or tk_abstract_interface
  41. */
  42. public org.omg.DynamicAny.DynAny create_dyn_any (org.omg.CORBA.Any value) throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
  43. {
  44. org.omg.CORBA.portable.ServantObject $so = _servant_preinvoke ("create_dyn_any", _opsClass);
  45. DynAnyFactoryOperations $self = (DynAnyFactoryOperations) $so.servant;
  46. try {
  47. return $self.create_dyn_any (value);
  48. } finally {
  49. _servant_postinvoke ($so);
  50. }
  51. } // create_dyn_any
  52. /**
  53. * Creates a DynAny from a TypeCode. Depending on the TypeCode, the created object may be of type DynAny,
  54. * or one of its derived types, such as DynStruct. The returned reference can be narrowed to the derived type.
  55. * In all cases, a DynAny constructed from a TypeCode has an initial default value.
  56. * The default values of basic types are:
  57. * <UL>
  58. * <LI>false for boolean
  59. * <LI>zero for numeric types
  60. * <LI>zero for types octet, char, and wchar
  61. * <LI>the empty string for string and wstring
  62. * <LI>null for object references
  63. * <LI>a type code with a TCKind value of tk_null for type codes
  64. * <LI>for any values, an any containing a type code with a TCKind value of tk_null type and no value
  65. * </UL>
  66. * For complex types, creation of the corresponding DynAny assigns a default value as follows:
  67. * <UL>
  68. * <LI>For DynSequence it sets the current position to -1 and creates an empty sequence.
  69. * <LI>For DynEnum it sets the current position to -1 and sets the value of the enumerator
  70. * to the first enumerator value indicated by the TypeCode.
  71. * <LI>For DynFixed it sets the current position to -1 and sets the value zero.
  72. * <LI>For DynStruct it sets the current position to -1 for empty exceptions
  73. * and to zero for all other TypeCodes. The members (if any) are (recursively) initialized
  74. * to their default values.
  75. * <LI>For DynArray sets the current position to zero and (recursively) initializes elements
  76. * to their default value.
  77. * <LI>For DynUnion sets the current position to zero. The discriminator value is set
  78. * to a value consistent with the first named member of the union. That member is activated and (recursively)
  79. * initialized to its default value.
  80. * <LI>For DynValue and DynValueBox it initializes to a null value.
  81. * </UL>
  82. */
  83. public org.omg.DynamicAny.DynAny create_dyn_any_from_type_code (org.omg.CORBA.TypeCode type) throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
  84. {
  85. org.omg.CORBA.portable.ServantObject $so = _servant_preinvoke ("create_dyn_any_from_type_code", _opsClass);
  86. DynAnyFactoryOperations $self = (DynAnyFactoryOperations) $so.servant;
  87. try {
  88. return $self.create_dyn_any_from_type_code (type);
  89. } finally {
  90. _servant_postinvoke ($so);
  91. }
  92. } // create_dyn_any_from_type_code
  93. // Type-specific CORBA::Object operations
  94. private static String[] __ids = {
  95. "IDL:omg.org/DynamicAny/DynAnyFactory:1.0"};
  96. public String[] _ids ()
  97. {
  98. return (String[])__ids.clone ();
  99. }
  100. private void readObject (java.io.ObjectInputStream s) throws java.io.IOException
  101. {
  102. String str = s.readUTF ();
  103. String[] args = null;
  104. java.util.Properties props = null;
  105. org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
  106. org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate ();
  107. _set_delegate (delegate);
  108. }
  109. private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException
  110. {
  111. String[] args = null;
  112. java.util.Properties props = null;
  113. String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
  114. s.writeUTF (str);
  115. }
  116. } // class _DynAnyFactoryStub