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