KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > DynamicAny > _DynAnyFactoryStub


1 package org.omg.DynamicAny;
2
3
4 /**
5 * org/omg/DynamicAny/_DynAnyFactoryStub.java .
6 * Generated by the IDL-to-Java compiler (portable), version "3.2"
7 * from ../../../../src/share/classes/org/omg/DynamicAny/DynamicAny.idl
8 * Saturday, February 9, 2008 9:40:12 AM GMT
9 */

10
11
12 /**
13     * DynAny objects can be created by invoking operations on the DynAnyFactory object.
14     * Generally there are only two ways to create a DynAny object:
15     * <UL>
16     * <LI>invoking an operation on an existing DynAny object
17     * <LI>invoking an operation on a DynAnyFactory object
18     * </UL>
19     * A constructed DynAny object supports operations that enable the creation of new DynAny
20     * objects encapsulating access to the value of some constituent.
21     * DynAny objects also support the copy operation for creating new DynAny objects.
22     * A reference to the DynAnyFactory object is obtained by calling ORB.resolve_initial_references()
23     * with the identifier parameter set to the string constant "DynAnyFactory".
24     * <P>Dynamic interpretation of an any usually involves creating a DynAny object using create_dyn_any()
25     * as the first step. Depending on the type of the any, the resulting DynAny object reference can be narrowed
26     * to a DynFixed, DynStruct, DynSequence, DynArray, DynUnion, DynEnum, or DynValue object reference.
27     * <P>Dynamic creation of an any involves creating a DynAny object using create_dyn_any_from_type_code(),
28     * passing the TypeCode associated with the value to be created. The returned reference is narrowed to one of
29     * the complex types, such as DynStruct, if appropriate. Then, the value can be initialized by means of
30     * invoking operations on the resulting object. Finally, the to_any operation can be invoked
31     * to create an any value from the constructed DynAny.
32     */

33 public class _DynAnyFactoryStub extends org.omg.CORBA.portable.ObjectImpl JavaDoc implements org.omg.DynamicAny.DynAnyFactory JavaDoc
34 {
35   final public static java.lang.Class JavaDoc _opsClass = DynAnyFactoryOperations JavaDoc.class;
36
37
38
39   /**
40         * Creates a new DynAny object from an any value.
41         * A copy of the TypeCode associated with the any value is assigned to the resulting DynAny object.
42         * The value associated with the DynAny object is a copy of the value in the original any.
43         * The current position of the created DynAny is set to zero if the passed value has components,
44         * to -1 otherwise
45         *
46         * @exception InconsistentTypeCode if value has a TypeCode with a TCKind of tk_Principal,
47         * tk_native, or tk_abstract_interface
48         */

49   public org.omg.DynamicAny.DynAny JavaDoc create_dyn_any (org.omg.CORBA.Any JavaDoc value) throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode JavaDoc
50   {
51       org.omg.CORBA.portable.ServantObject JavaDoc $so = _servant_preinvoke ("create_dyn_any", _opsClass);
52       DynAnyFactoryOperations JavaDoc $self = (DynAnyFactoryOperations JavaDoc) $so.servant;
53
54       try {
55          return $self.create_dyn_any (value);
56       } finally {
57           _servant_postinvoke ($so);
58       }
59   } // create_dyn_any
60

61
62   /**
63         * Creates a DynAny from a TypeCode. Depending on the TypeCode, the created object may be of type DynAny,
64         * or one of its derived types, such as DynStruct. The returned reference can be narrowed to the derived type.
65         * In all cases, a DynAny constructed from a TypeCode has an initial default value.
66         * The default values of basic types are:
67         * <UL>
68         * <LI>false for boolean
69         * <LI>zero for numeric types
70         * <LI>zero for types octet, char, and wchar
71         * <LI>the empty string for string and wstring
72         * <LI>null for object references
73         * <LI>a type code with a TCKind value of tk_null for type codes
74         * <LI>for any values, an any containing a type code with a TCKind value of tk_null type and no value
75         * </UL>
76         * For complex types, creation of the corresponding DynAny assigns a default value as follows:
77         * <UL>
78         * <LI>For DynSequence it sets the current position to -1 and creates an empty sequence.
79         * <LI>For DynEnum it sets the current position to -1 and sets the value of the enumerator
80         * to the first enumerator value indicated by the TypeCode.
81         * <LI>For DynFixed it sets the current position to -1 and sets the value zero.
82         * <LI>For DynStruct it sets the current position to -1 for empty exceptions
83         * and to zero for all other TypeCodes. The members (if any) are (recursively) initialized
84         * to their default values.
85         * <LI>For DynArray sets the current position to zero and (recursively) initializes elements
86         * to their default value.
87         * <LI>For DynUnion sets the current position to zero. The discriminator value is set
88         * to a value consistent with the first named member of the union. That member is activated and (recursively)
89         * initialized to its default value.
90         * <LI>For DynValue and DynValueBox it initializes to a null value.
91         * </UL>
92         */

93   public org.omg.DynamicAny.DynAny JavaDoc create_dyn_any_from_type_code (org.omg.CORBA.TypeCode JavaDoc type) throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode JavaDoc
94   {
95       org.omg.CORBA.portable.ServantObject JavaDoc $so = _servant_preinvoke ("create_dyn_any_from_type_code", _opsClass);
96       DynAnyFactoryOperations JavaDoc $self = (DynAnyFactoryOperations JavaDoc) $so.servant;
97
98       try {
99          return $self.create_dyn_any_from_type_code (type);
100       } finally {
101           _servant_postinvoke ($so);
102       }
103   } // create_dyn_any_from_type_code
104

105   // Type-specific CORBA::Object operations
106
private static String JavaDoc[] __ids = {
107     "IDL:omg.org/DynamicAny/DynAnyFactory:1.0"};
108
109   public String JavaDoc[] _ids ()
110   {
111     return (String JavaDoc[])__ids.clone ();
112   }
113
114   private void readObject (java.io.ObjectInputStream JavaDoc s) throws java.io.IOException JavaDoc
115   {
116      String JavaDoc str = s.readUTF ();
117      String JavaDoc[] args = null;
118      java.util.Properties JavaDoc props = null;
119      org.omg.CORBA.Object JavaDoc obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str);
120      org.omg.CORBA.portable.Delegate JavaDoc delegate = ((org.omg.CORBA.portable.ObjectImpl JavaDoc) obj)._get_delegate ();
121      _set_delegate (delegate);
122   }
123
124   private void writeObject (java.io.ObjectOutputStream JavaDoc s) throws java.io.IOException JavaDoc
125   {
126      String JavaDoc[] args = null;
127      java.util.Properties JavaDoc props = null;
128      String JavaDoc str = org.omg.CORBA.ORB.init (args, props).object_to_string (this);
129      s.writeUTF (str);
130   }
131 } // class _DynAnyFactoryStub
132
Popular Tags