1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/org/omg/CORBA/ShortHolder.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,110 @@ 1.4 +/* 1.5 + * Copyright 1995-2001 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package org.omg.CORBA; 1.30 + 1.31 +import org.omg.CORBA.portable.Streamable; 1.32 +import org.omg.CORBA.portable.InputStream; 1.33 +import org.omg.CORBA.portable.OutputStream; 1.34 + 1.35 +/** 1.36 + * The Holder for <tt>Short</tt>. For more information on 1.37 + * Holder files, see <a href="doc-files/generatedfiles.html#holder"> 1.38 + * "Generated Files: Holder Files"</a>.<P 1.39 + * A Holder class for a <code>short</code> 1.40 + * that is used to store "out" and "inout" parameters in IDL operations. 1.41 + * If an IDL operation signature has an IDL <code>short</code> as an "out" 1.42 + * or "inout" parameter, the programmer must pass an instance of 1.43 + * <code>ShortHolder</code> as the corresponding 1.44 + * parameter in the method invocation; for "inout" parameters, the programmer 1.45 + * must also fill the "in" value to be sent to the server. 1.46 + * Before the method invocation returns, the ORB will fill in the 1.47 + * value corresponding to the "out" value returned from the server. 1.48 + * <P> 1.49 + * If <code>myShortHolder</code> is an instance of <code>ShortHolder</code>, 1.50 + * the value stored in its <code>value</code> field can be accessed with 1.51 + * <code>myShortHolder.value</code>. 1.52 + * 1.53 + * @since JDK1.2 1.54 + */ 1.55 +public final class ShortHolder implements Streamable { 1.56 + 1.57 + /** 1.58 + * The <code>short</code> value held by this <code>ShortHolder</code> 1.59 + * object. 1.60 + */ 1.61 + public short value; 1.62 + 1.63 + /** 1.64 + * Constructs a new <code>ShortHolder</code> object with its 1.65 + * <code>value</code> field initialized to <code>0</code>. 1.66 + */ 1.67 + public ShortHolder() { 1.68 + } 1.69 + 1.70 + /** 1.71 + * Constructs a new <code>ShortHolder</code> object with its 1.72 + * <code>value</code> field initialized to the given 1.73 + * <code>short</code>. 1.74 + * @param initial the <code>short</code> with which to initialize 1.75 + * the <code>value</code> field of the newly-created 1.76 + * <code>ShortHolder</code> object 1.77 + */ 1.78 + public ShortHolder(short initial) { 1.79 + value = initial; 1.80 + } 1.81 + 1.82 + /** 1.83 + * Reads from <code>input</code> and initalizes the value in 1.84 + * this <code>ShortHolder</code> object 1.85 + * with the unmarshalled data. 1.86 + * 1.87 + * @param input the InputStream containing CDR formatted data from the wire. 1.88 + */ 1.89 + public void _read(InputStream input) { 1.90 + value = input.read_short(); 1.91 + } 1.92 + 1.93 + /** 1.94 + * Marshals to <code>output</code> the value in 1.95 + * this <code>ShortHolder</code> object. 1.96 + * 1.97 + * @param output the OutputStream which will contain the CDR formatted data. 1.98 + */ 1.99 + public void _write(OutputStream output) { 1.100 + output.write_short(value); 1.101 + } 1.102 + 1.103 + /** 1.104 + * Returns the TypeCode corresponding to the value held in 1.105 + * this <code>ShortHolder</code> object. 1.106 + * 1.107 + * @return the TypeCode of the value held in 1.108 + * this <code>ShortHolder</code> object 1.109 + */ 1.110 + public org.omg.CORBA.TypeCode _type() { 1.111 + return ORB.init().get_primitive_tc(TCKind.tk_short); 1.112 + } 1.113 +}