001: /*
002: * Copyright 1995-2001 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package org.omg.CORBA;
027:
028: import org.omg.CORBA.portable.Streamable;
029: import org.omg.CORBA.portable.InputStream;
030: import org.omg.CORBA.portable.OutputStream;
031:
032: /**
033: * The Holder for <tt>Long</tt>. For more information on
034: * Holder files, see <a href="doc-files/generatedfiles.html#holder">
035: * "Generated Files: Holder Files"</a>.<P>
036: * A Holder class for a <code>long</code>
037: * that is used to store "out" and "inout" parameters in IDL methods.
038: * If an IDL method signature has an IDL <code>long long</code> as an "out"
039: * or "inout" parameter, the programmer must pass an instance of
040: * <code>LongHolder</code> as the corresponding
041: * parameter in the method invocation; for "inout" parameters, the programmer
042: * must also fill the "in" value to be sent to the server.
043: * Before the method invocation returns, the ORB will fill in the
044: * value corresponding to the "out" value returned from the server.
045: * <P>
046: * If <code>myLongHolder</code> is an instance of <code>LongHolder</code>,
047: * the value stored in its <code>value</code> field can be accessed with
048: * <code>myLongHolder.value</code>.
049: *
050: * @version 1.14, 09/09/97
051: * @since JDK1.2
052: */
053: public final class LongHolder implements Streamable {
054:
055: /**
056: * The <code>long</code> value held by this <code>LongHolder</code>
057: * object.
058: */
059: public long value;
060:
061: /**
062: * Constructs a new <code>LongHolder</code> object with its
063: * <code>value</code> field initialized to <code>0</code>.
064: */
065: public LongHolder() {
066: }
067:
068: /**
069: * Constructs a new <code>LongHolder</code> object with its
070: * <code>value</code> field initialized to the given
071: * <code>long</code>.
072: * @param initial the <code>long</code> with which to initialize
073: * the <code>value</code> field of the newly-created
074: * <code>LongHolder</code> object
075: */
076: public LongHolder(long initial) {
077: value = initial;
078: }
079:
080: /**
081: * Reads from <code>input</code> and initalizes the value in the Holder
082: * with the unmarshalled data.
083: *
084: * @param input the InputStream containing CDR formatted data from the wire
085: */
086: public void _read(InputStream input) {
087: value = input.read_longlong();
088: }
089:
090: /**
091: * Marshals to <code>output</code> the value in the Holder.
092: *
093: * @param output the OutputStream which will contain the CDR formatted data
094: */
095: public void _write(OutputStream output) {
096: output.write_longlong(value);
097: }
098:
099: /**
100: * Returns the <code>TypeCode</code> object
101: * corresponding to the value held in the Holder.
102: *
103: * @return the TypeCode of the value held in the holder
104: */
105: public org.omg.CORBA.TypeCode _type() {
106: return ORB.init().get_primitive_tc(TCKind.tk_longlong);
107: }
108:
109: }
|