1 /*
   2  * Copyright (c) 1996, 2015, 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  * <LI><code>org.omg.CORBA.ORB.create_operation_list</code>
  67  * <PRE>
  68  *    org.omg.CORBA.NVList nv = orb.create_operation_list(myOperationDef);
  69  * </PRE>
  70  * The variable <code>nv</code> represents a newly-created
  71  * <code>NVList</code> object that contains descriptions of the
  72  * arguments to the method described in the given
  73  * <code>OperationDef</code> object.
  74  * </OL>
  75  * <P>
  76  * The methods in the class <code>NVList</code> all deal with
  77  * the <code>NamedValue</code> objects in the list.
  78  * There are three methods for adding a <code>NamedValue</code> object,
  79  * a method for getting the count of <code>NamedValue</code> objects in
  80  * the list, a method for retrieving a <code>NamedValue</code> object
  81  * at a given index, and a method for removing a <code>NamedValue</code> object
  82  * at a given index.
  83  *
  84  * @see org.omg.CORBA.Request
  85  * @see org.omg.CORBA.ServerRequest
  86  * @see org.omg.CORBA.NamedValue
  87  * @see org.omg.CORBA.Context
  88  *
  89  * @since       JDK1.2
  90  */
  91 
  92 public abstract class NVList {
  93 
  94     /**
  95      * Returns the number of <code>NamedValue</code> objects that have
  96      * been added to this <code>NVList</code> object.
  97      *
  98      * @return                  an <code>int</code> indicating the number of
  99      * <code>NamedValue</code> objects in this <code>NVList</code>.
 100      */
 101 
 102     public abstract int count();
 103 
 104     /**
 105      * Creates a new <code>NamedValue</code> object initialized with the given flag
 106      * and adds it to the end of this <code>NVList</code> object.
 107      * The flag can be any one of the argument passing modes:
 108      * <code>ARG_IN.value</code>, <code>ARG_OUT.value</code>, or
 109      * <code>ARG_INOUT.value</code>.
 110      *
 111      * @param flags             one of the argument mode flags
 112      * @return                  the newly-created <code>NamedValue</code> object
 113      */
 114 
 115     public abstract NamedValue add(int flags);
 116 
 117     /**
 118      * Creates a new <code>NamedValue</code> object initialized with the
 119      * given name and flag,
 120      * and adds it to the end of this <code>NVList</code> object.
 121      * The flag can be any one of the argument passing modes:
 122      * <code>ARG_IN.value</code>, <code>ARG_OUT.value</code>, or
 123      * <code>ARG_INOUT.value</code>.
 124      *
 125      * @param item_name the name for the new <code>NamedValue</code> object
 126      * @param flags             one of the argument mode flags
 127      * @return                  the newly-created <code>NamedValue</code> object
 128      */
 129 
 130     public abstract NamedValue add_item(String item_name, int flags);
 131 
 132     /**
 133      * Creates a new <code>NamedValue</code> object initialized with the
 134      * given name, value, and flag,
 135      * and adds it to the end of this <code>NVList</code> object.
 136      *
 137      * @param item_name the name for the new <code>NamedValue</code> object
 138      * @param val         an <code>Any</code> object containing the  value
 139      *                    for the new <code>NamedValue</code> object
 140      * @param flags       one of the following argument passing modes:
 141      *                    <code>ARG_IN.value</code>, <code>ARG_OUT.value</code>, or
 142      *                    <code>ARG_INOUT.value</code>
 143      * @return            the newly created <code>NamedValue</code> object
 144      */
 145 
 146     public abstract NamedValue add_value(String item_name, Any val, int flags);
 147 
 148     /**
 149      * Retrieves the <code>NamedValue</code> object at the given index.
 150      *
 151      * @param index             the index of the desired <code>NamedValue</code> object,
 152      *                    which must be between zero and the length of the list
 153      *                    minus one, inclusive.  The first item is at index zero.
 154      * @return                  the <code>NamedValue</code> object at the given index
 155      * @exception org.omg.CORBA.Bounds  if the index is greater than
 156      *                          or equal to number of <code>NamedValue</code> objects
 157      */
 158 
 159     public abstract NamedValue item(int index) throws org.omg.CORBA.Bounds;
 160 
 161     /**
 162      * Removes the <code>NamedValue</code> object at the given index.
 163      * Note that the indices of all <code>NamedValue</code> objects following
 164      * the one removed are shifted down by one.
 165      *
 166      * @param index             the index of the <code>NamedValue</code> object to be
 167      *                    removed, which must be between zero and the length
 168      *                    of the list minus one, inclusive.
 169      *                    The first item is at index zero.
 170      * @exception org.omg.CORBA.Bounds  if the index is greater than
 171      *                          or equal to number of <code>NamedValue</code> objects in
 172      *                the list
 173      */
 174 
 175     public abstract void remove(int index) throws org.omg.CORBA.Bounds;
 176 
 177 }