KickJava   Java API By Example, From Geeks To Geeks.

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


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 PublisherPortInstanceListImpl
40 extends LocalObject JavaDoc
41 implements PublisherPortInstanceList
42 {
43   private Table _publishers;
44   
45   public PublisherPortInstanceListImpl()
46   {
47     _publishers = new Table();
48   }
49
50   /* (non-Javadoc)
51    * @see org.objectweb.openccm.Containers.MetaInformation.PublisherPortInstanceListOperations#get_publisher_port_instance(java.lang.String)
52    */

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

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

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

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

109   public void add_publisher_port_instance(PublisherPortInstance cpi)
110   {
111     String JavaDoc key = cpi.type_reference().name() ;//+ cpi.toString().substring(cpi.toString().lastIndexOf("@"));
112
_publishers.put(key,cpi);
113     
114   }
115
116   /* (non-Javadoc)
117    * @see org.objectweb.openccm.Containers.MetaInformation.PublisherPortInstanceListOperations#remove_publisher_port_instance(java.lang.String)
118    */

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