KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > CORBA > ObjectHolder


1 /*
2  * @(#)ObjectHolder.java 1.30 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
8 package org.omg.CORBA;
9
10 import org.omg.CORBA.portable.Streamable JavaDoc;
11 import org.omg.CORBA.portable.InputStream JavaDoc;
12 import org.omg.CORBA.portable.OutputStream JavaDoc;
13
14
15 /**
16  * The Holder for <tt>Object</tt>. For more information on
17  * Holder files, see <a HREF="doc-files/generatedfiles.html#holder">
18  * "Generated Files: Holder Files"</a>.<P>
19  * A Holder class for a CORBA object reference (a value of type
20  * <code>org.omg.CORBA.Object</code>). It is usually
21  * used to store "out" and "inout" parameters in IDL methods.
22  * If an IDL method signature has a CORBA Object reference as an "out"
23  * or "inout" parameter, the programmer must pass an instance of
24  * <code>ObjectHolder</code> as the corresponding
25  * parameter in the method invocation; for "inout" parameters, the programmer
26  * must also fill the "in" value to be sent to the server.
27  * Before the method invocation returns, the ORB will fill in the
28  * value corresponding to the "out" value returned from the server.
29  * <P>
30  * If <code>myObjectHolder</code> is an instance of <code>ObjectHolder</code>,
31  * the value stored in its <code>value</code> field can be accessed with
32  * <code>myObjectHolder.value</code>.
33  *
34  * @version 1.14, 09/09/97
35  * @since JDK1.2
36  */

37 public final class ObjectHolder implements Streamable JavaDoc {
38     /**
39      * The <code>Object</code> value held by this <code>ObjectHolder</code>
40      * object.
41      */

42     public Object JavaDoc value;
43
44     /**
45      * Constructs a new <code>ObjectHolder</code> object with its
46      * <code>value</code> field initialized to <code>null</code>.
47      */

48     public ObjectHolder() {
49     }
50     
51     /**
52      * Constructs a new <code>ObjectHolder</code> object with its
53      * <code>value</code> field initialized to the given
54      * <code>Object</code>.
55      * @param initial the <code>Object</code> with which to initialize
56      * the <code>value</code> field of the newly-created
57      * <code>ObjectHolder</code> object
58      */

59     public ObjectHolder(Object JavaDoc initial) {
60     value = initial;
61     }
62
63     /**
64      * Reads from <code>input</code> and initalizes the value in
65      * this <code>ObjectHolder</code> object
66      * with the unmarshalled data.
67      *
68      * @param input the InputStream containing CDR formatted data from the wire.
69      */

70     public void _read(InputStream JavaDoc input) {
71     value = input.read_Object();
72     }
73
74     /**
75      * Marshals to <code>output</code> the value in
76      * this <code>ObjectHolder</code> object.
77      *
78      * @param output the OutputStream which will contain the CDR formatted data.
79      */

80     public void _write(OutputStream JavaDoc output) {
81     output.write_Object(value);
82     }
83
84     /**
85      * Returns the TypeCode corresponding to the value held in
86      * this <code>ObjectHolder</code> object
87      *
88      * @return the TypeCode of the value held in
89      * this <code>ObjectHolder</code> object
90      */

91     public org.omg.CORBA.TypeCode JavaDoc _type() {
92     return org.omg.CORBA.ORB.init().get_primitive_tc(TCKind.tk_objref);
93     }
94 }
95
Popular Tags