01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 1997-2004 Gerald Brose.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Library General Public License for more details.
15: *
16: * You should have received a copy of the GNU Library General Public
17: * License along with this library; if not, write to the Free
18: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19: */
20:
21: package org.jacorb.orb;
22:
23: /**
24: * @author Gerald Brose, FU Berlin
25: * @version $Id: NVList.java,v 1.11 2006/07/10 13:34:12 alphonse.bendt Exp $
26: */
27:
28: import java.util.*;
29:
30: public class NVList extends org.omg.CORBA.NVList {
31: private final List list;
32: private final org.omg.CORBA.ORB orb;
33:
34: NVList(org.omg.CORBA.ORB orb, int count) {
35: super ();
36: this .orb = orb;
37: this .list = Collections.synchronizedList(new ArrayList(count));
38: }
39:
40: public int count() {
41: return list.size();
42: }
43:
44: public org.omg.CORBA.NamedValue add(int item_flags) {
45: org.omg.CORBA.NamedValue namedValue = orb.create_named_value(
46: "", null, item_flags);
47: list.add(namedValue);
48: return namedValue;
49: }
50:
51: public org.omg.CORBA.NamedValue add_item(String item_name,
52: int item_flags) {
53: org.omg.CORBA.NamedValue namedValue = orb.create_named_value(
54: item_name, null, item_flags);
55: list.add(namedValue);
56: return namedValue;
57: }
58:
59: public org.omg.CORBA.NamedValue add_value(
60: java.lang.String item_name, org.omg.CORBA.Any value,
61: int item_flags) {
62: org.omg.CORBA.NamedValue namedValue = orb.create_named_value(
63: item_name, value, item_flags);
64: list.add(namedValue);
65: return namedValue;
66: }
67:
68: public org.omg.CORBA.NamedValue item(int index)
69: throws org.omg.CORBA.Bounds {
70: try {
71: return (NamedValue) list.get(index);
72: } catch (ArrayIndexOutOfBoundsException e) {
73: throw new org.omg.CORBA.Bounds(e.toString());
74: }
75: }
76:
77: public void remove(int index) throws org.omg.CORBA.Bounds {
78: try {
79: list.remove(index);
80: } catch (ArrayIndexOutOfBoundsException e) {
81: throw new org.omg.CORBA.Bounds(e.toString());
82: }
83: }
84:
85: public Iterator iterator() {
86: return list.iterator();
87: }
88: }
|