1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/org/omg/CORBA/IntHolder.java Wed Apr 27 01:21:28 2016 +0800 1.3 @@ -0,0 +1,112 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2001, Oracle and/or its affiliates. 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. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * 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>Int</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 an <code>int</code> 1.40 + * that is used to store "out" and "inout" parameters in IDL methods. 1.41 + * If an IDL method signature has an IDL <code>long</code> as an "out" 1.42 + * or "inout" parameter, the programmer must pass an instance of 1.43 + * <code>IntHolder</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>myIntHolder</code> is an instance of <code>IntHolder</code>, 1.50 + * the value stored in its <code>value</code> field can be accessed with 1.51 + * <code>myIntHolder.value</code>. 1.52 + * 1.53 + * @since JDK1.2 1.54 + */ 1.55 +public final class IntHolder implements Streamable { 1.56 + 1.57 + /** 1.58 + * The <code>int</code> value held by this <code>IntHolder</code> 1.59 + * object in its <code>value</code> field. 1.60 + */ 1.61 + public int value; 1.62 + 1.63 + /** 1.64 + * Constructs a new <code>IntHolder</code> object with its 1.65 + * <code>value</code> field initialized to <code>0</code>. 1.66 + */ 1.67 + public IntHolder() { 1.68 + } 1.69 + 1.70 + /** 1.71 + * Constructs a new <code>IntHolder</code> object with its 1.72 + * <code>value</code> field initialized to the given 1.73 + * <code>int</code>. 1.74 + * @param initial the <code>int</code> with which to initialize 1.75 + * the <code>value</code> field of the newly-created 1.76 + * <code>IntHolder</code> object 1.77 + */ 1.78 + public IntHolder(int initial) { 1.79 + value = initial; 1.80 + } 1.81 + 1.82 + /** 1.83 + * Reads unmarshalled data from <code>input</code> and assigns it to 1.84 + * the <code>value</code> field in this <code>IntHolder</code> object. 1.85 + * 1.86 + * @param input the <code>InputStream</code> object containing CDR 1.87 + * formatted data from the wire 1.88 + */ 1.89 + public void _read(InputStream input) { 1.90 + value = input.read_long(); 1.91 + } 1.92 + 1.93 + /** 1.94 + * Marshals the value in this <code>IntHolder</code> object's 1.95 + * <code>value</code> field to the output stream <code>output</code>. 1.96 + * 1.97 + * @param output the <code>OutputStream</code> object that will contain 1.98 + * the CDR formatted data 1.99 + */ 1.100 + public void _write(OutputStream output) { 1.101 + output.write_long(value); 1.102 + } 1.103 + 1.104 + /** 1.105 + * Retrieves the <code>TypeCode</code> object that corresponds 1.106 + * to the value held in this <code>IntHolder</code> object's 1.107 + * <code>value</code> field. 1.108 + * 1.109 + * @return the type code for the value held in this <code>IntHolder</code> 1.110 + * object 1.111 + */ 1.112 + public org.omg.CORBA.TypeCode _type() { 1.113 + return ORB.init().get_primitive_tc(TCKind.tk_long); 1.114 + } 1.115 +}