KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)StringHolder.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  * The Holder for <tt>String</tt>. For more information on
16  * Holder files, see <a HREF="doc-files/generatedfiles.html#holder">
17  * "Generated Files: Holder Files"</a>.<P>
18  * A Holder class for a <code>String</code>
19  * that is used to store "out" and "inout" parameters in IDL operations.
20  * If an IDL operation signature has an IDL <code>string</code> as an "out"
21  * or "inout" parameter, the programmer must pass an instance of
22  * <code>StringHolder</code> as the corresponding
23  * parameter in the method invocation; for "inout" parameters, the programmer
24  * must also fill the "in" value to be sent to the server.
25  * Before the method invocation returns, the ORB will fill in the
26  * value corresponding to the "out" value returned from the server.
27  * <P>
28  * If <code>myStringHolder</code> is an instance of <code>StringHolder</code>,
29  * the value stored in its <code>value</code> field can be accessed with
30  * <code>myStringHolder.value</code>.
31  *
32  * @version 1.14, 09/09/97
33  * @since JDK1.2
34  */

35 public final class StringHolder implements Streamable JavaDoc {
36
37     /**
38      * The <code>String</code> value held by this <code>StringHolder</code>
39      * object.
40      */

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

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

58     public StringHolder(String JavaDoc initial) {
59     value = initial;
60     }
61
62     /**
63      * Reads the unmarshalled data from <code>input</code> and assigns it to
64      * the <code>value</code> field of this <code>StringHolder</code> object.
65      *
66      * @param input the InputStream containing CDR formatted data from the wire.
67      */

68     public void _read(InputStream JavaDoc input) {
69     value = input.read_string();
70     }
71
72     /**
73      * Marshals the value held by this <code>StringHolder</code> object
74      * to the output stream <code>output</code>.
75      *
76      * @param output the OutputStream which will contain the CDR formatted data.
77      */

78     public void _write(OutputStream JavaDoc output) {
79     output.write_string(value);
80     }
81
82     /**
83      * Retrieves the <code>TypeCode</code> object that corresponds to
84      * the value held in this <code>StringHolder</code> object.
85      *
86      * @return the type code of the value held in this <code>StringHolder</code>
87      * object
88      */

89     public org.omg.CORBA.TypeCode JavaDoc _type() {
90     return ORB.init().get_primitive_tc(TCKind.tk_string);
91     }
92 }
93
Popular Tags