src/share/classes/org/omg/CORBA/ObjectHolder.java

changeset 0
7ef37b2cdcad
child 748
6845b95cba6b
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/org/omg/CORBA/ObjectHolder.java	Wed Apr 27 01:21:28 2016 +0800
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 + * Copyright (c) 1996, 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 +/**
    1.37 + * The Holder for <tt>Object</tt>.  For more information on
    1.38 + * Holder files, see <a href="doc-files/generatedfiles.html#holder">
    1.39 + * "Generated Files: Holder Files"</a>.<P>
    1.40 + * A Holder class for a CORBA object reference (a value of type
    1.41 + * <code>org.omg.CORBA.Object</code>).  It is usually
    1.42 + * used to store "out" and "inout" parameters in IDL methods.
    1.43 + * If an IDL method signature has a CORBA Object reference as an "out"
    1.44 + * or "inout" parameter, the programmer must pass an instance of
    1.45 + * <code>ObjectHolder</code> as the corresponding
    1.46 + * parameter in the method invocation; for "inout" parameters, the programmer
    1.47 + * must also fill the "in" value to be sent to the server.
    1.48 + * Before the method invocation returns, the ORB will fill in the
    1.49 + * value corresponding to the "out" value returned from the server.
    1.50 + * <P>
    1.51 + * If <code>myObjectHolder</code> is an instance of <code>ObjectHolder</code>,
    1.52 + * the value stored in its <code>value</code> field can be accessed with
    1.53 + * <code>myObjectHolder.value</code>.
    1.54 + *
    1.55 + * @since       JDK1.2
    1.56 + */
    1.57 +public final class ObjectHolder implements Streamable {
    1.58 +    /**
    1.59 +     * The <code>Object</code> value held by this <code>ObjectHolder</code>
    1.60 +     * object.
    1.61 +     */
    1.62 +    public Object value;
    1.63 +
    1.64 +    /**
    1.65 +     * Constructs a new <code>ObjectHolder</code> object with its
    1.66 +     * <code>value</code> field initialized to <code>null</code>.
    1.67 +     */
    1.68 +    public ObjectHolder() {
    1.69 +    }
    1.70 +
    1.71 +    /**
    1.72 +     * Constructs a new <code>ObjectHolder</code> object with its
    1.73 +     * <code>value</code> field initialized to the given
    1.74 +     * <code>Object</code>.
    1.75 +     * @param initial the <code>Object</code> with which to initialize
    1.76 +     *                the <code>value</code> field of the newly-created
    1.77 +     *                <code>ObjectHolder</code> object
    1.78 +     */
    1.79 +    public ObjectHolder(Object initial) {
    1.80 +        value = initial;
    1.81 +    }
    1.82 +
    1.83 +    /**
    1.84 +     * Reads from <code>input</code> and initalizes the value in
    1.85 +     * this <code>ObjectHolder</code> object
    1.86 +     * with the unmarshalled data.
    1.87 +     *
    1.88 +     * @param input the InputStream containing CDR formatted data from the wire.
    1.89 +     */
    1.90 +    public void _read(InputStream input) {
    1.91 +        value = input.read_Object();
    1.92 +    }
    1.93 +
    1.94 +    /**
    1.95 +     * Marshals to <code>output</code> the value in
    1.96 +     * this <code>ObjectHolder</code> object.
    1.97 +     *
    1.98 +     * @param output the OutputStream which will contain the CDR formatted data.
    1.99 +     */
   1.100 +    public void _write(OutputStream output) {
   1.101 +        output.write_Object(value);
   1.102 +    }
   1.103 +
   1.104 +    /**
   1.105 +     * Returns the TypeCode corresponding to the value held in
   1.106 +     * this <code>ObjectHolder</code> object
   1.107 +     *
   1.108 +     * @return    the TypeCode of the value held in
   1.109 +     *            this <code>ObjectHolder</code> object
   1.110 +     */
   1.111 +    public org.omg.CORBA.TypeCode _type() {
   1.112 +        return org.omg.CORBA.ORB.init().get_primitive_tc(TCKind.tk_objref);
   1.113 +    }
   1.114 +}

mercurial