LongHolder.java revision 704:3ef63dbde965
176589Sjoerg/*
276589Sjoerg * Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
376589Sjoerg * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
476589Sjoerg *
576589Sjoerg * This code is free software; you can redistribute it and/or modify it
676589Sjoerg * under the terms of the GNU General Public License version 2 only, as
776589Sjoerg * published by the Free Software Foundation.  Oracle designates this
876589Sjoerg * particular file as subject to the "Classpath" exception as provided
976589Sjoerg * by Oracle in the LICENSE file that accompanied this code.
1076589Sjoerg *
1176589Sjoerg * This code is distributed in the hope that it will be useful, but WITHOUT
1276589Sjoerg * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1376589Sjoerg * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1476589Sjoerg * version 2 for more details (a copy is included in the LICENSE file that
1576589Sjoerg * accompanied this code).
1676589Sjoerg *
1776589Sjoerg * You should have received a copy of the GNU General Public License version
1876589Sjoerg * 2 along with this work; if not, write to the Free Software Foundation,
1976589Sjoerg * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2076589Sjoerg *
2176589Sjoerg * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2276589Sjoerg * or visit www.oracle.com if you need additional information or have any
2376589Sjoerg * questions.
2476589Sjoerg */
2576589Sjoerg
2676589Sjoergpackage org.omg.CORBA;
2776589Sjoerg
2876589Sjoergimport org.omg.CORBA.portable.Streamable;
2976589Sjoergimport org.omg.CORBA.portable.InputStream;
30206622Suqsimport org.omg.CORBA.portable.OutputStream;
3176685Sjoerg
3276589Sjoerg/**
3376589Sjoerg * The Holder for {@code Long}. For more information on
3476589Sjoerg * Holder files, see <a href="doc-files/generatedfiles.html#holder">
3576589Sjoerg * "Generated Files: Holder Files"</a>.<P>
3676589Sjoerg * A Holder class for a {@code long}
3776685Sjoerg * that is used to store "out" and "inout" parameters in IDL methods.
3876589Sjoerg * If an IDL method signature has an IDL {@code long long} as an "out"
3976589Sjoerg * or "inout" parameter, the programmer must pass an instance of
4076589Sjoerg * {@code LongHolder} as the corresponding
4178857Sjoerg * parameter in the method invocation; for "inout" parameters, the programmer
4278857Sjoerg * must also fill the "in" value to be sent to the server.
4378857Sjoerg * Before the method invocation returns, the ORB will fill in the
4478857Sjoerg * value corresponding to the "out" value returned from the server.
4576589Sjoerg * <P>
4676685Sjoerg * If {@code myLongHolder} is an instance of {@code LongHolder},
4776685Sjoerg * the value stored in its {@code value} field can be accessed with
48131500Sru * {@code myLongHolder.value}.
49131500Sru *
5076589Sjoerg * @since       JDK1.2
5176589Sjoerg */
5276589Sjoergpublic final class LongHolder implements Streamable {
5395127Scharnier
5476685Sjoerg    /**
5595127Scharnier     * The {@code long} value held by this {@code LongHolder}
5676589Sjoerg     * object.
57131500Sru     */
58131500Sru    public long value;
5976589Sjoerg
6076589Sjoerg    /**
6176589Sjoerg     * Constructs a new {@code LongHolder} object with its
6276589Sjoerg     * {@code value} field initialized to {@code 0}.
6376589Sjoerg     */
6476589Sjoerg    public LongHolder() {
6576589Sjoerg    }
6676589Sjoerg
6776589Sjoerg    /**
6876589Sjoerg     * Constructs a new {@code LongHolder} object with its
6976685Sjoerg     * {@code value} field initialized to the given
7076685Sjoerg     * {@code long}.
7176685Sjoerg     * @param initial the {@code long} with which to initialize
7276685Sjoerg     *                the {@code value} field of the newly-created
7376685Sjoerg     *                {@code LongHolder} object
7476589Sjoerg     */
75131500Sru    public LongHolder(long initial) {
76131500Sru        value = initial;
7776589Sjoerg    }
7876589Sjoerg
7976589Sjoerg    /**
80131500Sru     * Reads from {@code input} and initalizes the value in the Holder
81131500Sru     * with the unmarshalled data.
8276589Sjoerg     *
8376589Sjoerg     * @param input the InputStream containing CDR formatted data from the wire
84131500Sru     */
85131500Sru    public void _read(InputStream input) {
8676589Sjoerg        value = input.read_longlong();
8776589Sjoerg    }
8876589Sjoerg
89131500Sru    /**
90131500Sru     * Marshals to {@code output} the value in the Holder.
9176589Sjoerg     *
9276685Sjoerg     * @param output the OutputStream which will contain the CDR formatted data
9376589Sjoerg     */
9476589Sjoerg    public void _write(OutputStream output) {
9576589Sjoerg        output.write_longlong(value);
9676589Sjoerg    }
9776685Sjoerg
9876685Sjoerg    /**
9976685Sjoerg     * Returns the {@code TypeCode} object
10076685Sjoerg     * corresponding to the value held in the Holder.
10176589Sjoerg     *
10276589Sjoerg     * @return    the TypeCode of the value held in the holder
103141846Sru     */
10476589Sjoerg    public org.omg.CORBA.TypeCode _type() {
10576589Sjoerg        return ORB.init().get_primitive_tc(TCKind.tk_longlong);
10676589Sjoerg    }
10776589Sjoerg
10876589Sjoerg}
10976589Sjoerg