Revision 23170 branches/v2_0_0_prep/libraries/libTools/src/org/gvsig/tools/observer/DefaultObservable.java
DefaultObservable.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
1 | 27 |
package org.gvsig.tools.observer; |
2 | 28 |
|
3 | 29 |
import java.lang.ref.Reference; |
... | ... | |
39 | 65 |
} |
40 | 66 |
|
41 | 67 |
public synchronized void addObserver(Reference ref) { |
42 |
if (ref == null || ref.get() == null) |
|
43 |
throw new NullPointerException(); |
|
68 |
if (ref == null || ref.get() == null) { |
|
69 |
throw new NullPointerException(); |
|
70 |
} |
|
44 | 71 |
Observer o = (Observer)ref.get(); |
45 | 72 |
if (!contains(o)) { |
46 | 73 |
obs.addElement(ref); |
... | ... | |
109 | 136 |
public synchronized void deleteObserver(Reference ref) { |
110 | 137 |
Observer o = (Observer)ref.get(); |
111 | 138 |
obs.removeElement(ref); |
112 |
if (o == null) |
|
113 |
return; |
|
139 |
if (o == null) { |
|
140 |
return; |
|
141 |
} |
|
114 | 142 |
deleteObserverReferenced(o); |
115 | 143 |
} |
116 | 144 |
|
... | ... | |
288 | 316 |
* 2) a recently unregistered Observer will be |
289 | 317 |
* wrongly notified when it doesn't care |
290 | 318 |
*/ |
291 |
if (!changed) |
|
292 |
return; |
|
319 |
if (!changed) { |
|
320 |
return; |
|
321 |
} |
|
293 | 322 |
arrLocal = obs.toArray(); |
294 | 323 |
clearChanged(); |
295 | 324 |
} |
Also available in: Unified diff