KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > registry > model > WebServiceGroup


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.registry.model;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.HashSet JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Set JavaDoc;
27 import org.netbeans.modules.websvc.registry.model.WebServiceListModel;
28 import org.netbeans.modules.websvc.registry.util.Util;
29
30 /**
31  *
32  * @author Winston Prakash
33  */

34 public class WebServiceGroup {
35
36     Set JavaDoc listeners = new HashSet JavaDoc();
37     String JavaDoc groupId = null;
38     String JavaDoc groupName = null;
39
40     Set JavaDoc webserviceIds = new HashSet JavaDoc();
41
42     public WebServiceGroup() {
43         this(WebServiceListModel.getInstance().getUniqueWebServiceGroupId());
44     }
45     
46     public WebServiceGroup(String JavaDoc id) {
47         setId(id);
48     }
49     
50     public void addWebServiceGroupListener(WebServiceGroupListener listener){
51         listeners.add(listener);
52     }
53     
54     public void removeWebServiceGroupListener(WebServiceGroupListener listener){
55         listeners.remove(listener);
56     }
57     
58     public void setId(String JavaDoc id){
59         groupId = id;
60     }
61     
62     public String JavaDoc getId(){
63         return groupId;
64     }
65     
66     public String JavaDoc getName() {
67         return groupName;
68     }
69     
70     public void setName(String JavaDoc name) {
71         groupName = name;
72     }
73     
74     public void add(String JavaDoc webServiceId) {
75         //System.out.println("WebServiceGroup add called - " + webServiceId);
76
if (!webserviceIds.contains(webServiceId)) {
77             WebServiceData wsData = WebServiceListModel.getInstance().getWebService(webServiceId);
78             wsData.setGroupId(getId());
79             webserviceIds.add(webServiceId);
80             Iterator JavaDoc iter = listeners.iterator();
81             while(iter.hasNext()) {
82                 WebServiceGroupEvent evt = new WebServiceGroupEvent(webServiceId);
83                 ((WebServiceGroupListener)iter.next()).webServiceAdded(evt);
84             }
85         }
86     }
87     
88     public void remove(String JavaDoc webServiceId){
89         //System.out.println("WebServiceGroup remove called - " + webServiceId);
90
if (webserviceIds.contains(webServiceId)) {
91             webserviceIds.remove(webServiceId);
92             Iterator JavaDoc iter = listeners.iterator();
93             while(iter.hasNext()) {
94                 WebServiceGroupEvent evt = new WebServiceGroupEvent(webServiceId);
95                 ((WebServiceGroupListener)iter.next()).webServiceRemoved(evt);
96             }
97         }
98     }
99     
100     public void setWebServiceIds(Set JavaDoc ids){
101         webserviceIds = ids;
102         Iterator JavaDoc iter = webserviceIds.iterator();
103         while(iter.hasNext()) {
104             WebServiceData wsData = WebServiceListModel.getInstance().getWebService((String JavaDoc)iter.next());
105             wsData.setGroupId(getId());
106         }
107     }
108     
109     public Set JavaDoc getWebServiceIds(){
110         return webserviceIds;
111     }
112     
113 }
114
Popular Tags