KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > observable > EmptyObservableSet


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.core.internal.databinding.observable;
13
14 import java.util.Collection JavaDoc;
15 import java.util.Collections JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.Set JavaDoc;
18
19 import org.eclipse.core.databinding.observable.IChangeListener;
20 import org.eclipse.core.databinding.observable.IStaleListener;
21 import org.eclipse.core.databinding.observable.Realm;
22 import org.eclipse.core.databinding.observable.set.IObservableSet;
23 import org.eclipse.core.databinding.observable.set.ISetChangeListener;
24
25 /**
26  * Singleton empty set
27  */

28 public class EmptyObservableSet implements IObservableSet {
29
30     private static final Set JavaDoc emptySet = Collections.EMPTY_SET;
31
32     private Realm realm;
33
34     /**
35      * Creates a singleton empty set. This set may be disposed multiple times
36      * without any side-effects.
37      *
38      * @param realm
39      */

40     public EmptyObservableSet(Realm realm) {
41         this.realm = realm;
42     }
43
44     public void addSetChangeListener(ISetChangeListener listener) {
45     }
46
47     public void removeSetChangeListener(ISetChangeListener listener) {
48     }
49
50     public Object JavaDoc getElementType() {
51         return null;
52     }
53
54     public int size() {
55         return 0;
56     }
57
58     public boolean isEmpty() {
59         return true;
60     }
61
62     public boolean contains(Object JavaDoc o) {
63         return false;
64     }
65
66     public Iterator JavaDoc iterator() {
67         return emptySet.iterator();
68     }
69
70     public Object JavaDoc[] toArray() {
71         return emptySet.toArray();
72     }
73
74     public Object JavaDoc[] toArray(Object JavaDoc[] a) {
75         return emptySet.toArray(a);
76     }
77
78     public boolean add(Object JavaDoc o) {
79         throw new UnsupportedOperationException JavaDoc();
80     }
81
82     public boolean remove(Object JavaDoc o) {
83         throw new UnsupportedOperationException JavaDoc();
84     }
85
86     public boolean containsAll(Collection JavaDoc c) {
87         return c.isEmpty();
88     }
89
90     public boolean addAll(Collection JavaDoc c) {
91         throw new UnsupportedOperationException JavaDoc();
92     }
93
94     public boolean retainAll(Collection JavaDoc c) {
95         throw new UnsupportedOperationException JavaDoc();
96     }
97
98     public boolean removeAll(Collection JavaDoc c) {
99         throw new UnsupportedOperationException JavaDoc();
100     }
101
102     public void clear() {
103         throw new UnsupportedOperationException JavaDoc();
104     }
105
106     public void addChangeListener(IChangeListener listener) {
107     }
108
109     public void removeChangeListener(IChangeListener listener) {
110     }
111
112     public void addStaleListener(IStaleListener listener) {
113     }
114
115     public void removeStaleListener(IStaleListener listener) {
116     }
117
118     public boolean isStale() {
119         return false;
120     }
121
122     public void dispose() {
123     }
124
125     public Realm getRealm() {
126         return realm;
127     }
128
129 }
130
Popular Tags