001: /*
002: * Copyright 1995-2001 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package org.omg.CORBA;
026:
027: import org.omg.CORBA.portable.Streamable;
028: import org.omg.CORBA.portable.InputStream;
029: import org.omg.CORBA.portable.OutputStream;
030:
031: /**
032: * The Holder for <tt>Boolean</tt>. For more information on
033: * Holder files, see <a href="doc-files/generatedfiles.html#holder">
034: * "Generated Files: Holder Files"</a>.<P>
035: * A Holder class for a <code>boolean</code>
036: * that is used to store "out" and "inout" parameters in IDL methods.
037: * If an IDL method signature has an IDL <code>boolean</code> as an "out"
038: * or "inout" parameter, the programmer must pass an instance of
039: * <code>BooleanHolder</code> as the corresponding
040: * parameter in the method invocation; for "inout" parameters, the programmer
041: * must also fill the "in" value to be sent to the server.
042: * Before the method invocation returns, the ORB will fill in the
043: * value corresponding to the "out" value returned from the server.
044: * <P>
045: * If <code>myBooleanHolder</code> is an instance of <code>BooleanHolder</code>,
046: * the value stored in its <code>value</code> field can be accessed with
047: * <code>myBooleanHolder.value</code>.
048: *
049: * @version 1.14, 09/09/97
050: * @since JDK1.2
051: */
052: public final class BooleanHolder implements Streamable {
053:
054: /**
055: * The <code>boolean</code> value held by this <code>BooleanHolder</code>
056: * object.
057: */
058: public boolean value;
059:
060: /**
061: * Constructs a new <code>BooleanHolder</code> object with its
062: * <code>value</code> field initialized to <code>false</code>.
063: */
064: public BooleanHolder() {
065: }
066:
067: /**
068: * Constructs a new <code>BooleanHolder</code> object with its
069: * <code>value</code> field initialized with the given <code>boolean</code>.
070: * @param initial the <code>boolean</code> with which to initialize
071: * the <code>value</code> field of the newly-created
072: * <code>BooleanHolder</code> object
073: */
074: public BooleanHolder(boolean initial) {
075: value = initial;
076: }
077:
078: /**
079: * Reads unmarshalled data from <code>input</code> and assigns it to this
080: * <code>BooleanHolder</code> object's <code>value</code> field.
081: *
082: * @param input the <code>InputStream</code> object containing
083: * CDR formatted data from the wire
084: */
085: public void _read(InputStream input) {
086: value = input.read_boolean();
087: }
088:
089: /**
090: * Marshals the value in this <code>BooleanHolder</code> object's
091: * <code>value</code> field to the output stream <code>output</code>.
092: *
093: * @param output the OutputStream which will contain the CDR formatted data
094: */
095: public void _write(OutputStream output) {
096: output.write_boolean(value);
097: }
098:
099: /**
100: * Retrieves the <code>TypeCode</code> object that corresponds to the
101: * value held in this <code>BooleanHolder</code> object.
102: *
103: * @return the <code>TypeCode</code> for the value held
104: * in this <code>BooleanHolder</code> object
105: */
106: public TypeCode _type() {
107: return ORB.init().get_primitive_tc(TCKind.tk_boolean);
108: }
109: }
|