KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > notification > NotificationListenerMeta


1 /* ************************************************************************** *
2  * Copyright (C) 2004 NightLabs GmbH, Marco Schulze *
3  * All rights reserved. *
4  * http://www.NightLabs.de *
5  * *
6  * This program and the accompanying materials are free software; you can re- *
7  * distribute it and/or modify it under the terms of the GNU General Public *
8  * License as published by the Free Software Foundation; either ver 2 of the *
9  * License, or any later version. *
10  * *
11  * This module is distributed in the hope that it will be useful, but WITHOUT *
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- *
13  * NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more *
14  * details. *
15  * *
16  * You should have received a copy of the GNU General Public License along *
17  * with this module; if not, write to the Free Software Foundation, Inc.: *
18  * 59 Temple Place, Suite 330 *
19  * Boston MA 02111-1307 *
20  * USA *
21  * *
22  * Or get it online: *
23  * http://www.opensource.org/licenses/gpl-license.php *
24  * *
25  * In case, you want to use this module or parts of it in a proprietary pro- *
26  * ject, you can purchase it under the NightLabs Commercial License. Please *
27  * contact NightLabs GmbH under info AT nightlabs DOT com for more infos or *
28  * visit http://www.NightLabs.com *
29  * ************************************************************************** */

30
31 /*
32  * Created on Apr 14, 2005
33  */

34 package com.nightlabs.notification;
35
36 import java.lang.ref.WeakReference JavaDoc;
37
38 /**
39  * @author Marco Schulze - marco at nightlabs dot de
40  */

41 public class NotificationListenerMeta
42 {
43     private String JavaDoc zone;
44     private Class JavaDoc subjectClass;
45     private WeakReference JavaDoc notificationListenerRef;
46     private String JavaDoc notificationMode;
47     private int counter;
48
49 // /**
50
// * key: Class subjectClass
51
// * value: Integer counter
52
// */
53
// private Map subjectCounters = new HashMap();
54
//
55
public NotificationListenerMeta(String JavaDoc zone, Class JavaDoc subjectClass, NotificationListener listener, String JavaDoc notificationMode)
56     {
57         this.zone = zone;
58         this.subjectClass = subjectClass;
59         this.notificationListenerRef = new WeakReference JavaDoc(listener);
60         this.notificationMode = notificationMode;
61     }
62     /**
63      * @return Returns the zone.
64      */

65     public String JavaDoc getZone()
66     {
67         return zone;
68     }
69     /**
70      * @return Returns the subjectClass.
71      */

72     public Class JavaDoc getSubjectClass()
73     {
74         return subjectClass;
75     }
76     /**
77      * @return Returns the notificationMode.
78      */

79     public String JavaDoc getNotificationMode()
80     {
81         return notificationMode;
82     }
83     /**
84      * @return the notificationListener. Might return <tt>null</tt>, if weak reference has been disposed!
85      */

86     public NotificationListener getNotificationListener()
87     {
88         return (NotificationListener) notificationListenerRef.get();
89     }
90     /**
91      * @return Returns the counter.
92      */

93     public int getCounter()
94     {
95         return counter;
96     }
97
98     public int incCounter()
99     {
100         return ++counter;
101     }
102
103     public int decCounter()
104     {
105         return --counter;
106     }
107
108 }
109
Popular Tags