KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > management > ObjectNotificationFilterSupport


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.core.management;
15
16 import java.util.Set JavaDoc;
17 import java.util.HashSet JavaDoc;
18 import java.util.Collection JavaDoc;
19
20 /**
21  *
22  * Date: Jul 31, 2005
23  * @author Rakesh Kalra
24  */

25 public class ObjectNotificationFilterSupport implements ObjectNotificationFilter{
26
27     private Set JavaDoc notificationTypes = new HashSet JavaDoc();
28
29     public void enableType(String JavaDoc type){
30         assert type != null;
31         notificationTypes.add(type);
32     }
33
34     /**
35      * This method is called before a notification is sent to see whether
36      * the listener wants the notification.
37      *
38      * @param notification the notification to be sent.
39      * @return true if the listener wants the notification, false otherwise
40      */

41     public boolean isNotificationEnabled(ObjectNotification notification) {
42         return notificationTypes.contains(notification.getType());
43     }
44
45     /**
46      *
47      * @return a list of notification types that are enabled.
48      */

49     public Collection JavaDoc getEnabledTypes() {
50         return notificationTypes;
51     }
52 }
53
Popular Tags