KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > corba > NVListImpl


1 /*
2  * @(#)NVListImpl.java 1.30 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 /*
8  * Licensed Materials - Property of IBM
9  * RMI-IIOP v1.0
10  * Copyright IBM Corp. 1998 1999 All Rights Reserved
11  *
12  * US Government Users Restricted Rights - Use, duplication or
13  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14  */

15
16 package com.sun.corba.se.impl.corba;
17
18 import java.util.Vector JavaDoc;
19
20 import org.omg.CORBA.Any JavaDoc;
21 import org.omg.CORBA.Bounds JavaDoc;
22 import org.omg.CORBA.NVList JavaDoc;
23 import org.omg.CORBA.NamedValue JavaDoc;
24
25 import com.sun.corba.se.spi.orb.ORB ;
26
27 public class NVListImpl extends NVList JavaDoc
28 {
29     private final int INITIAL_CAPACITY = 4;
30     private final int CAPACITY_INCREMENT = 2;
31
32     private Vector JavaDoc _namedValues;
33     private ORB orb;
34
35     public NVListImpl(ORB orb)
36     {
37         // Note: This orb could be an instanceof ORBSingleton or ORB
38
this.orb = orb;
39         _namedValues = new Vector JavaDoc(INITIAL_CAPACITY, CAPACITY_INCREMENT);
40     }
41
42     public NVListImpl(ORB orb, int size)
43     {
44         this.orb = orb;
45
46     // Note: the size arg is only a hint of the size of the NVList.
47
_namedValues = new Vector JavaDoc(size);
48     }
49
50
51     public int count()
52     {
53         return _namedValues.size();
54     }
55
56     public NamedValue JavaDoc add(int flags)
57     {
58         NamedValue JavaDoc tmpVal = new NamedValueImpl(orb, "", new AnyImpl(orb), flags);
59         _namedValues.addElement(tmpVal);
60         return tmpVal;
61     }
62
63     public NamedValue JavaDoc add_item(String JavaDoc itemName, int flags)
64     {
65         NamedValue JavaDoc tmpVal = new NamedValueImpl(orb, itemName, new AnyImpl(orb),
66                            flags);
67         _namedValues.addElement(tmpVal);
68         return tmpVal;
69     }
70
71     public NamedValue JavaDoc add_value(String JavaDoc itemName, Any JavaDoc val, int flags)
72     {
73         NamedValue JavaDoc tmpVal = new NamedValueImpl(orb, itemName, val, flags);
74         _namedValues.addElement(tmpVal);
75         return tmpVal;
76     }
77
78     public NamedValue JavaDoc item(int index)
79         throws Bounds JavaDoc
80     {
81         try {
82             return (NamedValue JavaDoc) _namedValues.elementAt(index);
83         } catch (ArrayIndexOutOfBoundsException JavaDoc e) {
84             throw new Bounds JavaDoc();
85         }
86     }
87
88     public void remove(int index)
89         throws Bounds JavaDoc
90     {
91         try {
92             _namedValues.removeElementAt(index);
93         } catch (ArrayIndexOutOfBoundsException JavaDoc e) {
94             throw new Bounds JavaDoc();
95         }
96     }
97 }
98
Popular Tags