KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > preferences > MockupPreferenceStore


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.jdt.internal.ui.preferences;
13
14 import org.eclipse.core.runtime.ListenerList;
15
16 import org.eclipse.jface.preference.IPreferenceStore;
17 import org.eclipse.jface.util.IPropertyChangeListener;
18 import org.eclipse.jface.util.PropertyChangeEvent;
19
20 /**
21  * Mockup preference store, for registering listeners and firing events,
22  * without being an actual store.
23  * <p>
24  * All methods except firing, adding and removing listeners throw
25  * an {@link java.lang.UnsupportedOperationException}.
26  * </p>
27  *
28  * @since 3.0
29  */

30 public class MockupPreferenceStore implements IPreferenceStore {
31
32     /** Listeners on this store */
33     private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
34
35     /**
36      * {@inheritDoc}
37      */

38     public void addPropertyChangeListener(IPropertyChangeListener listener) {
39         fListeners.add(listener);
40     }
41
42     /**
43      * {@inheritDoc}
44      */

45     public void removePropertyChangeListener(IPropertyChangeListener listener) {
46         fListeners.remove(listener);
47     }
48
49     /**
50      * {@inheritDoc}
51      */

52     public boolean contains(String JavaDoc name) {
53         throw new UnsupportedOperationException JavaDoc();
54     }
55
56     /**
57      * {@inheritDoc}
58      */

59     public void firePropertyChangeEvent(String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue) {
60         firePropertyChangeEvent(this, name, oldValue, newValue);
61     }
62
63     /**
64      * Fires a property change event with the given source, property name, old and new value. Used
65      * when the event source should be different from this mockup preference store.
66      * @param source The event source
67      * @param name The property name
68      * @param oldValue The property's old value
69      * @param newValue The property's new value
70      */

71     public void firePropertyChangeEvent(Object JavaDoc source, String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue) {
72         PropertyChangeEvent event= new PropertyChangeEvent(source, name, oldValue, newValue);
73         Object JavaDoc[] listeners= fListeners.getListeners();
74         for (int i= 0; i < listeners.length; i++)
75             ((IPropertyChangeListener) listeners[i]).propertyChange(event);
76     }
77
78     /**
79      * {@inheritDoc}
80      */

81     public boolean getBoolean(String JavaDoc name) {
82         throw new UnsupportedOperationException JavaDoc();
83     }
84
85     /**
86      * {@inheritDoc}
87      */

88     public boolean getDefaultBoolean(String JavaDoc name) {
89         throw new UnsupportedOperationException JavaDoc();
90     }
91
92     /**
93      * {@inheritDoc}
94      */

95     public double getDefaultDouble(String JavaDoc name) {
96         throw new UnsupportedOperationException JavaDoc();
97     }
98
99     /**
100      * {@inheritDoc}
101      */

102     public float getDefaultFloat(String JavaDoc name) {
103         throw new UnsupportedOperationException JavaDoc();
104     }
105
106     /**
107      * {@inheritDoc}
108      */

109     public int getDefaultInt(String JavaDoc name) {
110         throw new UnsupportedOperationException JavaDoc();
111     }
112
113     /**
114      * {@inheritDoc}
115      */

116     public long getDefaultLong(String JavaDoc name) {
117         throw new UnsupportedOperationException JavaDoc();
118     }
119
120     /**
121      * {@inheritDoc}
122      */

123     public String JavaDoc getDefaultString(String JavaDoc name) {
124         throw new UnsupportedOperationException JavaDoc();
125     }
126
127     /**
128      * {@inheritDoc}
129      */

130     public double getDouble(String JavaDoc name) {
131         throw new UnsupportedOperationException JavaDoc();
132     }
133
134     /**
135      * {@inheritDoc}
136      */

137     public float getFloat(String JavaDoc name) {
138         throw new UnsupportedOperationException JavaDoc();
139     }
140
141     /**
142      * {@inheritDoc}
143      */

144     public int getInt(String JavaDoc name) {
145         throw new UnsupportedOperationException JavaDoc();
146     }
147
148     /**
149      * {@inheritDoc}
150      */

151     public long getLong(String JavaDoc name) {
152         throw new UnsupportedOperationException JavaDoc();
153     }
154
155     /**
156      * {@inheritDoc}
157      */

158     public String JavaDoc getString(String JavaDoc name) {
159         throw new UnsupportedOperationException JavaDoc();
160     }
161
162     /**
163      * {@inheritDoc}
164      */

165     public boolean isDefault(String JavaDoc name) {
166         throw new UnsupportedOperationException JavaDoc();
167     }
168
169     /**
170      * {@inheritDoc}
171      */

172     public boolean needsSaving() {
173         throw new UnsupportedOperationException JavaDoc();
174     }
175
176     /**
177      * {@inheritDoc}
178      */

179     public void putValue(String JavaDoc name, String JavaDoc value) {
180         throw new UnsupportedOperationException JavaDoc();
181     }
182
183     /**
184      * {@inheritDoc}
185      */

186     public void setDefault(String JavaDoc name, double value) {
187         throw new UnsupportedOperationException JavaDoc();
188     }
189
190     /**
191      * {@inheritDoc}
192      */

193     public void setDefault(String JavaDoc name, float value) {
194         throw new UnsupportedOperationException JavaDoc();
195     }
196
197     /**
198      * {@inheritDoc}
199      */

200     public void setDefault(String JavaDoc name, int value) {
201         throw new UnsupportedOperationException JavaDoc();
202     }
203
204     /**
205      * {@inheritDoc}
206      */

207     public void setDefault(String JavaDoc name, long value) {
208         throw new UnsupportedOperationException JavaDoc();
209     }
210
211     /**
212      * {@inheritDoc}
213      */

214     public void setDefault(String JavaDoc name, String JavaDoc defaultObject) {
215         throw new UnsupportedOperationException JavaDoc();
216     }
217
218     /**
219      * {@inheritDoc}
220      */

221     public void setDefault(String JavaDoc name, boolean value) {
222         throw new UnsupportedOperationException JavaDoc();
223     }
224
225     /**
226      * {@inheritDoc}
227      */

228     public void setToDefault(String JavaDoc name) {
229         throw new UnsupportedOperationException JavaDoc();
230     }
231
232     /**
233      * {@inheritDoc}
234      */

235     public void setValue(String JavaDoc name, double value) {
236         throw new UnsupportedOperationException JavaDoc();
237     }
238
239     /**
240      * {@inheritDoc}
241      */

242     public void setValue(String JavaDoc name, float value) {
243         throw new UnsupportedOperationException JavaDoc();
244     }
245
246     /**
247      * {@inheritDoc}
248      */

249     public void setValue(String JavaDoc name, int value) {
250         throw new UnsupportedOperationException JavaDoc();
251     }
252
253     /**
254      * {@inheritDoc}
255      */

256     public void setValue(String JavaDoc name, long value) {
257         throw new UnsupportedOperationException JavaDoc();
258     }
259
260     /**
261      * {@inheritDoc}
262      */

263     public void setValue(String JavaDoc name, String JavaDoc value) {
264         throw new UnsupportedOperationException JavaDoc();
265     }
266
267     /**
268      * {@inheritDoc}
269      */

270     public void setValue(String JavaDoc name, boolean value) {
271         throw new UnsupportedOperationException JavaDoc();
272     }
273
274 }
275
Popular Tags