KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)CharHolder.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
9 package org.omg.CORBA;
10
11 import org.omg.CORBA.portable.Streamable JavaDoc;
12 import org.omg.CORBA.portable.InputStream JavaDoc;
13 import org.omg.CORBA.portable.OutputStream JavaDoc;
14
15 /**
16  * The Holder for <tt>Char</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 <code>char</code>
20  * that is used to store "out" and "inout" parameters in IDL methods.
21  * If an IDL method signature has an IDL <code>char</code> as an "out"
22  * or "inout" parameter, the programmer must pass an instance of
23  * <code>CharHolder</code> as the corresponding
24  * parameter in the method invocation; for "inout" parameters, the programmer
25  * must also fill the "in" value to be sent to the server.
26  * Before the method invocation returns, the ORB will fill in the
27  * value corresponding to the "out" value returned from the server.
28  * <P>
29  * If <code>myCharHolder</code> is an instance of <code>CharHolder</code>,
30  * the value stored in its <code>value</code> field can be accessed with
31  * <code>myCharHolder.value</code>.
32  *
33  * @version 1.14, 09/09/97
34  * @since JDK1.2
35  */

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

42     public char value;
43     
44     /**
45      * Constructs a new <code>CharHolder</code> object with its
46      * <code>value</code> field initialized to <code>0</code>.
47      */

48     public CharHolder() {
49     }
50     
51     /**
52      * Constructs a new <code>CharHolder</code> object for the given
53      * <code>char</code>.
54      * @param initial the <code>char</code> with which to initialize
55      * the <code>value</code> field of the new
56      * <code>CharHolder</code> object
57      */

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

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

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

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