duke@1: /* ohair@158: * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@158: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@158: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@158: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@158: * or visit www.oracle.com if you need additional information or have any ohair@158: * questions. duke@1: */ duke@1: duke@1: package org.omg.CORBA; duke@1: duke@1: /** duke@1: * An object used in the DII and DSI to describe duke@1: * arguments and return values. NamedValue objects duke@1: * are also used in the Context duke@1: * object routines to pass lists of property names and values. duke@1: *

duke@1: * A NamedValue object contains: duke@1: *

duke@1: *

duke@1: * The class NamedValue has three methods, which duke@1: * access its fields. The following code fragment demonstrates duke@1: * creating a NamedValue object and then accessing duke@1: * its fields: duke@1: *

duke@1:  *    ORB orb = ORB.init(args, null);
duke@1:  *    String s = "argument_1";
duke@1:  *    org.omg.CORBA.Any myAny = orb.create_any();
duke@1:  *    myAny.insert_long(12345);
duke@1:  *    int in = org.omg.CORBA.ARG_IN.value;
duke@1: 
duke@1:  *    org.omg.CORBA.NamedValue nv = orb.create_named_value(
duke@1:  *        s, myAny, in);
duke@1:  *    System.out.println("This nv name is " + nv.name());
duke@1:  *    try {
duke@1:  *        System.out.println("This nv value is " + nv.value().extract_long());
duke@1:  *        System.out.println("This nv flag is " + nv.flags());
duke@1:  *    } catch (org.omg.CORBA.BAD_OPERATION b) {
duke@1:  *      System.out.println("extract failed");
duke@1:  *    }
duke@1:  * 
duke@1: * duke@1: *

duke@1: * If this code fragment were put into a main method, duke@1: * the output would be something like the following: duke@1: *

duke@1:  *    This nv name is argument_1
duke@1:  *    This nv value is 12345
duke@1:  *    This nv flag is 1
duke@1:  * 
duke@1: *

duke@1: * Note that the method value returns an Any duke@1: * object. In order to access the long contained in the duke@1: * Any object, duke@1: * we used the method extract_long. duke@1: * duke@1: * @see Any duke@1: * @see ARG_IN duke@1: * @see ARG_INOUT duke@1: * @see ARG_OUT duke@1: * duke@1: * @since JDK1.2 duke@1: */ duke@1: duke@1: public abstract class NamedValue { duke@1: duke@1: /** duke@1: * Retrieves the name for this NamedValue object. duke@1: * duke@1: * @return a String object representing duke@1: * the name of this NamedValue object duke@1: */ duke@1: duke@1: public abstract String name(); duke@1: duke@1: /** duke@1: * Retrieves the value for this NamedValue object. duke@1: * duke@1: * @return an Any object containing duke@1: * the value of this NamedValue object duke@1: */ duke@1: duke@1: public abstract Any value(); duke@1: duke@1: /** duke@1: * Retrieves the argument mode flag for this NamedValue object. duke@1: * duke@1: * @return an int representing the argument duke@1: * mode for this NamedValue object duke@1: */ duke@1: duke@1: public abstract int flags(); duke@1: duke@1: }