001: /*
002: * Copyright 1999-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>ValueBase</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>java.io.Serializable</code>
037: * that is used to store "out" and "inout" parameters in IDL methods.
038: * If an IDL method signature has an IDL <code>ValueBase</code> as an "out"
039: * or "inout" parameter, the programmer must pass an instance of
040: * <code>ValueBaseHolder</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>myValueBaseHolder</code> is an instance of <code>ValueBaseHolder</code>,
047: * the value stored in its <code>value</code> field can be accessed with
048: * <code>myValueBaseHolder.value</code>.
049: *
050: */
051: public final class ValueBaseHolder implements Streamable {
052:
053: /**
054: * The <code>java.io.Serializable</code> value held by this
055: * <code>ValueBaseHolder</code> object.
056: */
057: public java.io.Serializable value;
058:
059: /**
060: * Constructs a new <code>ValueBaseHolder</code> object with its
061: * <code>value</code> field initialized to <code>0</code>.
062: */
063: public ValueBaseHolder() {
064: }
065:
066: /**
067: * Constructs a new <code>ValueBaseHolder</code> object with its
068: * <code>value</code> field initialized to the given
069: * <code>java.io.Serializable</code>.
070: * @param initial the <code>java.io.Serializable</code> with which to initialize
071: * the <code>value</code> field of the newly-created
072: * <code>ValueBaseHolder</code> object
073: */
074: public ValueBaseHolder(java.io.Serializable initial) {
075: value = initial;
076: }
077:
078: /**
079: * Reads from <code>input</code> and initalizes the value in the Holder
080: * with the unmarshalled data.
081: *
082: * @param input the InputStream containing CDR formatted data from the wire
083: */
084: public void _read(InputStream input) {
085: value = ((org.omg.CORBA_2_3.portable.InputStream) input)
086: .read_value();
087: }
088:
089: /**
090: * Marshals to <code>output</code> the value in the Holder.
091: *
092: * @param output the OutputStream which will contain the CDR formatted data
093: */
094: public void _write(OutputStream output) {
095: ((org.omg.CORBA_2_3.portable.OutputStream) output)
096: .write_value(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_value);
107: }
108:
109: }
|