KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
18 import java.util.ListIterator JavaDoc;
19
20 import org.eclipse.core.databinding.observable.IChangeListener;
21 import org.eclipse.core.databinding.observable.IStaleListener;
22 import org.eclipse.core.databinding.observable.Realm;
23 import org.eclipse.core.databinding.observable.list.IListChangeListener;
24 import org.eclipse.core.databinding.observable.list.IObservableList;
25
26 /**
27  * Singleton empty list
28  */

29 public class EmptyObservableList implements IObservableList {
30
31     private static final List JavaDoc emptyList = Collections.EMPTY_LIST;
32
33     private Realm realm;
34
35     /**
36      * Creates a singleton empty list. This list may be disposed multiple times
37      * without any side-effects.
38      *
39      * @param realm
40      */

41     public EmptyObservableList(Realm realm) {
42         this.realm = realm;
43     }
44
45     public void addListChangeListener(IListChangeListener listener) {
46     }
47
48     public void removeListChangeListener(IListChangeListener listener) {
49     }
50
51     public Object JavaDoc getElementType() {
52         return null;
53     }
54
55     public int size() {
56         return 0;
57     }
58
59     public boolean isEmpty() {
60         return true;
61     }
62
63     public boolean contains(Object JavaDoc o) {
64         return false;
65     }
66
67     public Iterator JavaDoc iterator() {
68         return emptyList.iterator();
69     }
70
71     public Object JavaDoc[] toArray() {
72         return emptyList.toArray();
73     }
74
75     public Object JavaDoc[] toArray(Object JavaDoc[] a) {
76         return emptyList.toArray(a);
77     }
78
79     public boolean add(Object JavaDoc o) {
80         throw new UnsupportedOperationException JavaDoc();
81     }
82
83     public boolean remove(Object JavaDoc o) {
84         throw new UnsupportedOperationException JavaDoc();
85     }
86
87     public boolean containsAll(Collection JavaDoc c) {
88         return c.isEmpty();
89     }
90
91     public boolean addAll(Collection JavaDoc c) {
92         throw new UnsupportedOperationException JavaDoc();
93     }
94
95     public boolean retainAll(Collection JavaDoc c) {
96         throw new UnsupportedOperationException JavaDoc();
97     }
98
99     public boolean removeAll(Collection JavaDoc c) {
100         throw new UnsupportedOperationException JavaDoc();
101     }
102
103     public void clear() {
104         throw new UnsupportedOperationException JavaDoc();
105     }
106
107     public void addChangeListener(IChangeListener listener) {
108     }
109
110     public void removeChangeListener(IChangeListener listener) {
111     }
112
113     public void addStaleListener(IStaleListener listener) {
114     }
115
116     public void removeStaleListener(IStaleListener listener) {
117     }
118
119     public boolean isStale() {
120         return false;
121     }
122
123     public void dispose() {
124     }
125
126     public boolean addAll(int index, Collection JavaDoc c) {
127         throw new UnsupportedOperationException JavaDoc();
128     }
129
130     public Object JavaDoc get(int index) {
131         return emptyList.get(index);
132     }
133
134     public int indexOf(Object JavaDoc o) {
135         return -1;
136     }
137
138     public int lastIndexOf(Object JavaDoc o) {
139         return -1;
140     }
141
142     public ListIterator JavaDoc listIterator() {
143         return emptyList.listIterator();
144     }
145
146     public ListIterator JavaDoc listIterator(int index) {
147         return emptyList.listIterator(index);
148     }
149
150     public Object JavaDoc remove(int index) {
151         throw new UnsupportedOperationException JavaDoc();
152     }
153
154     public Object JavaDoc set(int index, Object JavaDoc element) {
155         throw new UnsupportedOperationException JavaDoc();
156     }
157
158     public List JavaDoc subList(int fromIndex, int toIndex) {
159         return emptyList.subList(fromIndex, toIndex);
160     }
161
162     public void add(int arg0, Object JavaDoc arg1) {
163         throw new UnsupportedOperationException JavaDoc();
164     }
165
166     public Realm getRealm() {
167         return realm;
168     }
169
170 }
171
Popular Tags