1 /*
   2  * Copyright (c) 1996, 2000, 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 
  26 package org.omg.CORBA;
  27 
  28 /**
  29  * A modifiable list containing <code>NamedValue</code> objects.
  30  * <P>
  31  * The class <code>NVList</code> is used as follows:
  32  * <UL>
  33  * <LI>to describe arguments for a <code>Request</code> object
  34  * in the Dynamic Invocation Interface and
  35  * the Dynamic Skeleton Interface
  36  * <LI>to describe context values in a <code>Context</code> object
  37  * </UL>
  38  * <P>
  39  * Each <code>NamedValue</code> object consists of the following:
  40  * <UL>
  41  * <LI>a name, which is a <code>String</code> object
  42  * <LI>a value, as an <code>Any</code> object
  43  * <LI>an argument mode flag
  44  * </UL>
  45  * <P>
  46  * An <code>NVList</code> object
  47  * may be created using one of the following
  48  * <code>ORB</code> methods:
  49  * <OL>
  50  * <LI><code>org.omg.CORBA.ORB.create_list</code>
  51  * <PRE>
  52  *    org.omg.CORBA.NVList nv = orb.create_list(3);
  53  * </PRE>
  54  * The variable <code>nv</code> represents a newly-created
  55  * <code>NVList</code> object.  The argument is a memory-management
  56  * hint to the orb and does not imply the actual length of the list.
  57  * If, for example, you want to use an <code>NVList</code> object
  58  * in a request, and the method being invoked takes three parameters,
  59  * you might optimize by supplying 3 to the method
  60  * <code>create_list</code>.  Note that the new <code>NVList</code>
  61  * will not necessarily have a length of 3; it
  62  * could have a length of 2 or 4, for instance.
  63  * Note also that you can add any number of
  64  * <code>NamedValue</code> objects to this list regardless of
  65  * its original length.
  66  * <P>
  67  * <LI><code>org.omg.CORBA.ORB.create_operation_list</code>
  68  * <PRE>
  69  *    org.omg.CORBA.NVList nv = orb.create_operation_list(myOperationDef);
  70  * </PRE>
  71  * The variable <code>nv</code> represents a newly-created
  72  * <code>NVList</code> object that contains descriptions of the
  73  * arguments to the method described in the given
  74  * <code>OperationDef</code> object.
  75  * </OL>
  76  * <P>
  77  * The methods in the class <code>NVList</code> all deal with
  78  * the <code>NamedValue</code> objects in the list.
  79  * There are three methods for adding a <code>NamedValue</code> object,
  80  * a method for getting the count of <code>NamedValue</code> objects in
  81  * the list, a method for retrieving a <code>NamedValue</code> object
  82  * at a given index, and a method for removing a <code>NamedValue</code> object
  83  * at a given index.
  84  *
  85  * @see org.omg.CORBA.Request
  86  * @see org.omg.CORBA.ServerRequest
  87  * @see org.omg.CORBA.NamedValue
  88  * @see org.omg.CORBA.Context
  89  *
  90  * @since       1.2
  91  */
  92 
  93 public abstract class NVList {
  94 
  95     /**
  96      * Returns the number of <code>NamedValue</code> objects that have
  97      * been added to this <code>NVList</code> object.
  98      *
  99      * @return                  an <code>int</code> indicating the number of
 100      * <code>NamedValue</code> objects in this <code>NVList</code>.
 101      */
 102 
 103     public abstract int count();
 104 
 105     /**
 106      * Creates a new <code>NamedValue</code> object initialized with the given flag
 107      * and adds it to the end of this <code>NVList</code> object.
 108      * The flag can be any one of the argument passing modes:
 109      * <code>ARG_IN.value</code>, <code>ARG_OUT.value</code>, or
 110      * <code>ARG_INOUT.value</code>.
 111      *
 112      * @param flags             one of the argument mode flags
 113      * @return                  the newly-created <code>NamedValue</code> object
 114      */
 115 
 116     public abstract NamedValue add(int flags);
 117 
 118     /**
 119      * Creates a new <code>NamedValue</code> object initialized with the
 120      * given name and flag,
 121      * and adds it to the end of this <code>NVList</code> object.
 122      * The flag can be any one of the argument passing modes:
 123      * <code>ARG_IN.value</code>, <code>ARG_OUT.value</code>, or
 124      * <code>ARG_INOUT.value</code>.
 125      *
 126      * @param item_name the name for the new <code>NamedValue</code> object
 127      * @param flags             one of the argument mode flags
 128      * @return                  the newly-created <code>NamedValue</code> object
 129      */
 130 
 131     public abstract NamedValue add_item(String item_name, int flags);
 132 
 133     /**
 134      * Creates a new <code>NamedValue</code> object initialized with the
 135      * given name, value, and flag,
 136      * and adds it to the end of this <code>NVList</code> object.
 137      *
 138      * @param item_name the name for the new <code>NamedValue</code> object
 139      * @param val         an <code>Any</code> object containing the  value
 140      *                    for the new <code>NamedValue</code> object
 141      * @param flags       one of the following argument passing modes:
 142      *                    <code>ARG_IN.value</code>, <code>ARG_OUT.value</code>, or
 143      *                    <code>ARG_INOUT.value</code>
 144      * @return            the newly created <code>NamedValue</code> object
 145      */
 146 
 147     public abstract NamedValue add_value(String item_name, Any val, int flags);
 148 
 149     /**
 150      * Retrieves the <code>NamedValue</code> object at the given index.
 151      *
 152      * @param index             the index of the desired <code>NamedValue</code> object,
 153      *                    which must be between zero and the length of the list
 154      *                    minus one, inclusive.  The first item is at index zero.
 155      * @return                  the <code>NamedValue</code> object at the given index
 156      * @exception org.omg.CORBA.Bounds  if the index is greater than
 157      *                          or equal to number of <code>NamedValue</code> objects
 158      */
 159 
 160     public abstract NamedValue item(int index) throws org.omg.CORBA.Bounds;
 161 
 162     /**
 163      * Removes the <code>NamedValue</code> object at the given index.
 164      * Note that the indices of all <code>NamedValue</code> objects following
 165      * the one removed are shifted down by one.
 166      *
 167      * @param index             the index of the <code>NamedValue</code> object to be
 168      *                    removed, which must be between zero and the length
 169      *                    of the list minus one, inclusive.
 170      *                    The first item is at index zero.
 171      * @exception org.omg.CORBA.Bounds  if the index is greater than
 172      *                          or equal to number of <code>NamedValue</code> objects in
 173      *                the list
 174      */
 175 
 176     public abstract void remove(int index) throws org.omg.CORBA.Bounds;
 177 
 178 }