NamedValue.java revision 608:7e06bf1dcb09
1/* 2 * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package org.omg.CORBA; 27 28/** 29 * An object used in the DII and DSI to describe 30 * arguments and return values. <code>NamedValue</code> objects 31 * are also used in the <code>Context</code> 32 * object routines to pass lists of property names and values. 33 * <P> 34 * A <code>NamedValue</code> object contains: 35 * <UL> 36 * <LI>a name -- If the <code>NamedValue</code> object is used to 37 * describe arguments to a request, the name will be an argument 38 * identifier specified in the OMG IDL interface definition 39 * for the operation being described. 40 * <LI>a value -- an <code>Any</code> object 41 * <LI>an argument mode flag -- one of the following: 42 * <UL> 43 * <LI><code>ARG_IN.value</code> 44 * <LI><code>ARG_OUT.value</code> 45 * <LI><code>ARG_INOUT.value</code> 46 * <LI>zero -- if this <code>NamedValue</code> object represents a property 47 * in a <code>Context</code> object rather than a parameter or 48 * return value 49 * </UL> 50 * </UL> 51 * <P> 52 * The class <code>NamedValue</code> has three methods, which 53 * access its fields. The following code fragment demonstrates 54 * creating a <code>NamedValue</code> object and then accessing 55 * its fields: 56 * <PRE> 57 * ORB orb = ORB.init(args, null); 58 * String s = "argument_1"; 59 * org.omg.CORBA.Any myAny = orb.create_any(); 60 * myAny.insert_long(12345); 61 * int in = org.omg.CORBA.ARG_IN.value; 62 63 * org.omg.CORBA.NamedValue nv = orb.create_named_value( 64 * s, myAny, in); 65 * System.out.println("This nv name is " + nv.name()); 66 * try { 67 * System.out.println("This nv value is " + nv.value().extract_long()); 68 * System.out.println("This nv flag is " + nv.flags()); 69 * } catch (org.omg.CORBA.BAD_OPERATION b) { 70 * System.out.println("extract failed"); 71 * } 72 * </PRE> 73 * 74 * <P> 75 * If this code fragment were put into a <code>main</code> method, 76 * the output would be something like the following: 77 * <PRE> 78 * This nv name is argument_1 79 * This nv value is 12345 80 * This nv flag is 1 81 * </PRE> 82 * <P> 83 * Note that the method <code>value</code> returns an <code>Any</code> 84 * object. In order to access the <code>long</code> contained in the 85 * <code>Any</code> object, 86 * we used the method <code>extract_long</code>. 87 * 88 * @see Any 89 * @see ARG_IN 90 * @see ARG_INOUT 91 * @see ARG_OUT 92 * 93 * @since JDK1.2 94 */ 95 96public abstract class NamedValue { 97 98 /** 99 * Retrieves the name for this <code>NamedValue</code> object. 100 * 101 * @return a <code>String</code> object representing 102 * the name of this <code>NamedValue</code> object 103 */ 104 105 public abstract String name(); 106 107 /** 108 * Retrieves the value for this <code>NamedValue</code> object. 109 * 110 * @return an <code>Any</code> object containing 111 * the value of this <code>NamedValue</code> object 112 */ 113 114 public abstract Any value(); 115 116 /** 117 * Retrieves the argument mode flag for this <code>NamedValue</code> object. 118 * 119 * @return an <code>int</code> representing the argument 120 * mode for this <code>NamedValue</code> object 121 */ 122 123 public abstract int flags(); 124 125} 126