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:
026: package org.omg.CORBA;
027:
028: import org.omg.CORBA.portable.Streamable;
029: import org.omg.CORBA.portable.InputStream;
030: import org.omg.CORBA.portable.OutputStream;
031:
032: /**
033: * The Holder for <tt>Short</tt>. For more information on
034: * Holder files, see <a href="doc-files/generatedfiles.html#holder">
035: * "Generated Files: Holder Files"</a>.<P
036: * A Holder class for a <code>short</code>
037: * that is used to store "out" and "inout" parameters in IDL operations.
038: * If an IDL operation signature has an IDL <code>short</code> as an "out"
039: * or "inout" parameter, the programmer must pass an instance of
040: * <code>ShortHolder</code> as the corresponding
041: * parameter in the method invocation; for "inout" parameters, the programmer
042: * must also fill the "in" value to be sent to the server.
043: * Before the method invocation returns, the ORB will fill in the
044: * value corresponding to the "out" value returned from the server.
045: * <P>
046: * If <code>myShortHolder</code> is an instance of <code>ShortHolder</code>,
047: * the value stored in its <code>value</code> field can be accessed with
048: * <code>myShortHolder.value</code>.
049: *
050: * @version 1.14, 09/09/97
051: * @since JDK1.2
052: */
053: public final class ShortHolder implements Streamable {
054:
055: /**
056: * The <code>short</code> value held by this <code>ShortHolder</code>
057: * object.
058: */
059: public short value;
060:
061: /**
062: * Constructs a new <code>ShortHolder</code> object with its
063: * <code>value</code> field initialized to <code>0</code>.
064: */
065: public ShortHolder() {
066: }
067:
068: /**
069: * Constructs a new <code>ShortHolder</code> object with its
070: * <code>value</code> field initialized to the given
071: * <code>short</code>.
072: * @param initial the <code>short</code> with which to initialize
073: * the <code>value</code> field of the newly-created
074: * <code>ShortHolder</code> object
075: */
076: public ShortHolder(short initial) {
077: value = initial;
078: }
079:
080: /**
081: * Reads from <code>input</code> and initalizes the value in
082: * this <code>ShortHolder</code> object
083: * with the unmarshalled data.
084: *
085: * @param input the InputStream containing CDR formatted data from the wire.
086: */
087: public void _read(InputStream input) {
088: value = input.read_short();
089: }
090:
091: /**
092: * Marshals to <code>output</code> the value in
093: * this <code>ShortHolder</code> object.
094: *
095: * @param output the OutputStream which will contain the CDR formatted data.
096: */
097: public void _write(OutputStream output) {
098: output.write_short(value);
099: }
100:
101: /**
102: * Returns the TypeCode corresponding to the value held in
103: * this <code>ShortHolder</code> object.
104: *
105: * @return the TypeCode of the value held in
106: * this <code>ShortHolder</code> object
107: */
108: public org.omg.CORBA.TypeCode _type() {
109: return ORB.init().get_primitive_tc(TCKind.tk_short);
110: }
111: }
|