src/share/classes/org/omg/CORBA/AnyHolder.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/AnyHolder.java	Wed Apr 27 01:21:28 2016 +0800
     1.3 @@ -0,0 +1,107 @@
     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 + * The Holder for <tt>Any</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 <code>Any</code> objects
    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>any</code> as an "out"
    1.42 + * or "inout" parameter, the programmer must pass an instance of
    1.43 + * <code>AnyHolder</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>myAnyHolder</code> is an instance of <code>AnyHolder</code>,
    1.50 + * the value stored in its <code>value</code> field can be accessed with
    1.51 + * <code>myAnyHolder.value</code>.
    1.52 + *
    1.53 + * @since       JDK1.2
    1.54 + */
    1.55 +public final class AnyHolder implements  Streamable {
    1.56 +    /**
    1.57 +     * The <code>Any</code> value held by this <code>AnyHolder</code> object.
    1.58 +     */
    1.59 +
    1.60 +    public Any value;
    1.61 +
    1.62 +    /**
    1.63 +     * Constructs a new <code>AnyHolder</code> object with its
    1.64 +     * <code>value</code> field initialized to <code>null</code>.
    1.65 +     */
    1.66 +    public AnyHolder() {
    1.67 +    }
    1.68 +
    1.69 +    /**
    1.70 +     * Constructs a new <code>AnyHolder</code> object for the given
    1.71 +     * <code>Any</code> object.
    1.72 +     * @param initial the <code>Any</code> object with which to initialize
    1.73 +     *                the <code>value</code> field of the new
    1.74 +     *                <code>AnyHolder</code> object
    1.75 +     */
    1.76 +    public AnyHolder(Any initial) {
    1.77 +        value = initial;
    1.78 +    }
    1.79 +
    1.80 +    /**
    1.81 +     * Reads from <code>input</code> and initalizes the value in the Holder
    1.82 +     * with the unmarshalled data.
    1.83 +     *
    1.84 +     * @param input the InputStream containing CDR formatted data from the wire.
    1.85 +     */
    1.86 +    public void _read(InputStream input) {
    1.87 +        value = input.read_any();
    1.88 +    }
    1.89 +
    1.90 +    /**
    1.91 +     * Marshals to <code>output</code> the value in
    1.92 +     * this <code>AnyHolder</code> object.
    1.93 +     *
    1.94 +     * @param output the OutputStream which will contain the CDR formatted data.
    1.95 +     */
    1.96 +    public void _write(OutputStream output) {
    1.97 +        output.write_any(value);
    1.98 +    }
    1.99 +
   1.100 +    /**
   1.101 +     * Returns the <code>TypeCode</code> object corresponding to the value
   1.102 +     * held in this <code>AnyHolder</code> object.
   1.103 +     *
   1.104 +     * @return    the TypeCode of the value held in
   1.105 +     *              this <code>AnyHolder</code> object
   1.106 +     */
   1.107 +    public TypeCode _type() {
   1.108 +        return ORB.init().get_primitive_tc(TCKind.tk_any);
   1.109 +    }
   1.110 +}

mercurial