KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Containers > MetaInformation > ReceptaclePortInstanceListImpl


1 /*====================================================================
2
3 created on 14 ao?t 2003
4 OpenCCM: The Open CORBA Component Model Platform
5 Copyright (C) 2001-2002 USTL - LIFL - GOAL
6 Contact: openccm-team@objectweb.org
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 USA
22
23 Initial developer(s): Hameau Fabien.
24 Contributor(s): ______________________________________.
25
26 */

27 package org.objectweb.openccm.Containers.MetaInformation;
28
29 import org.objectweb.ccm.util.Table;
30 import org.omg.CORBA.LocalObject JavaDoc;
31 import org.omg.Components.InvalidName;
32
33 /**
34  * @author hameau
35  *
36  * To change the template for this generated type comment go to
37  * Window>Preferences>Java>Code Generation>Code and Comments
38  */

39 public class ReceptaclePortInstanceListImpl
40 extends LocalObject JavaDoc
41 implements ReceptaclePortInstanceList
42 {
43   
44   private Table _receptacles;
45
46   public ReceptaclePortInstanceListImpl()
47   {
48      _receptacles = new Table();
49   }
50
51   /* (non-Javadoc)
52    * @see org.objectweb.openccm.Containers.MetaInformation.ReceptaclePortInstanceListOperations#get_receptacle_port_instance(java.lang.String)
53    */

54   public ReceptaclePortInstance
55   get_receptacle_port_instance(String JavaDoc name)
56   throws InvalidName
57   {
58     ReceptaclePortInstance result = (ReceptaclePortInstance) _receptacles.get(name);
59     if(result == null)
60       throw new InvalidName();
61     return result;
62   }
63
64   /* (non-Javadoc)
65    * @see org.objectweb.openccm.Containers.MetaInformation.ReceptaclePortInstanceListOperations#get_named_receptacle_port_instanceS(java.lang.String[])
66    */

67   public ReceptaclePortInstance[]
68   get_named_receptacle_port_instanceS(String JavaDoc[] names)
69   throws InvalidName
70   {
71     ReceptaclePortInstance[] result = new ReceptaclePortInstance[names.length];
72
73  // Iterate on all the connections.
74

75  int i = 0;
76  for(i=0;i<names.length;i++)
77  {
78    result[i] = (ReceptaclePortInstance)_receptacles.get(names[i]);
79      
80    if(result[i] == null)
81    {
82      throw new InvalidName();
83    }
84   }
85    
86  return result;
87   }
88
89   /* (non-Javadoc)
90    * @see org.objectweb.openccm.Containers.MetaInformation.ReceptaclePortInstanceListOperations#get_all_receptacle_port_instanceS()
91    */

92   public ReceptaclePortInstance[]
93   get_all_receptacle_port_instanceS()
94   {
95     ReceptaclePortInstance[] result = new ReceptaclePortInstance[_receptacles.size()];
96   
97     // Iterate on all the connections.
98
int idx = 0;
99     for(java.util.Enumeration JavaDoc elements = _receptacles.elements(); elements.hasMoreElements(); )
100     {
101       ReceptaclePortInstance info = (ReceptaclePortInstance)elements.nextElement();
102         result[idx++] = info;
103     }
104     return result;
105   }
106
107   /* (non-Javadoc)
108    * @see org.objectweb.openccm.Containers.MetaInformation.ReceptaclePortInstanceListOperations#add_receptacle_port_instance(org.objectweb.openccm.Containers.MetaInformation.ReceptaclePortInstance)
109    */

110   public void
111   add_receptacle_port_instance(ReceptaclePortInstance rpi)
112   {
113     String JavaDoc key = rpi.type_reference().name() ;//+ rpi.toString().substring(rpi.toString().lastIndexOf("@"));
114
_receptacles.put(key,rpi);
115   }
116
117   /* (non-Javadoc)
118    * @see org.objectweb.openccm.Containers.MetaInformation.ReceptaclePortInstanceListOperations#remove_receptacle_port_instance(java.lang.String)
119    */

120   public void
121   remove_receptacle_port_instance(String JavaDoc name)
122   throws InvalidName
123   {
124     Object JavaDoc result = _receptacles.remove(name);
125     
126     if (result == null) throw new InvalidName();
127   }
128 }
129
Popular Tags