KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > notify > Notification


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: Notification.java,v 1.2 2005/06/08 06:19:08 nickb Exp $
16  */

17 package org.eclipse.emf.common.notify;
18
19
20 /**
21  * A description of a feature change that has occurred for some notifier.
22  * @see Adapter#notifyChanged
23  * @see Notifier
24  */

25 public interface Notification
26 {
27   /**
28    * Returns the object affected by the change.
29    * @return the object affected by the change.
30    */

31   Object JavaDoc getNotifier();
32
33   /**
34    * An {@link Notification#getEventType event type} indicating that
35    * the notifier has been created.
36    * @see Notification#getEventType
37    * @deprecated
38    */

39   int CREATE = 0;
40
41   /**
42    * An {@link Notification#getEventType event type} indicating that
43    * a feature of the notifier has been set.
44    * This applies for simple features.
45    * @see Notification#getEventType
46    */

47   int SET = 1;
48
49   /**
50    * An {@link Notification#getEventType event type} indicating that
51    * a feature of the notifier has been unset.
52    * This applies for unsettable features.
53    * @see Notification#getEventType
54    */

55   int UNSET = 2;
56
57   /**
58    * An {@link Notification#getEventType event type} indicating that
59    * a value has been inserted into a list-based feature of the notifier.
60    * @see Notification#getEventType
61    */

62   int ADD = 3;
63
64   /**
65    * An {@link Notification#getEventType event type} indicating that
66    * a value has been removed from a list-based feature of the notifier.
67    * @see Notification#getEventType
68    */

69   int REMOVE = 4;
70
71   /**
72    * An {@link Notification#getEventType event type} indicating that
73    * a several values have been added into a list-based feature of the notifier.
74    * @see Notification#getEventType
75    */

76   int ADD_MANY = 5;
77
78   /**
79    * An {@link Notification#getEventType event type} indicating that
80    * a several values have been removed from a list-based feature of the notifier.
81    * @see Notification#getEventType
82    */

83   int REMOVE_MANY = 6;
84
85   /**
86    * An {@link Notification#getEventType event type} indicating that
87    * a value has been moved within a list-based feature of the notifier.
88    * @see Notification#getEventType
89    */

90   int MOVE = 7;
91
92   /**
93    * An {@link Notification#getEventType event type} indicating that
94    * an adapter is being removed from the notifier.
95    * @see Notification#getEventType
96    */

97   int REMOVING_ADAPTER = 8;
98
99   /**
100    * An {@link Notification#getEventType event type} indicating that
101    * a feature of the notifier has been resolved from a proxy.
102    * @see Notification#getEventType
103    */

104   int RESOLVE = 9;
105
106   /**
107    * The number of built-in {@link Notification#getEventType event types}.
108    * User defined event types should start from this value.
109    * Clients are expected to ignore types they don't recognize.
110    * @see Notification#getEventType
111    */

112   int EVENT_TYPE_COUNT = 10;
113
114   /**
115    * Returns the type of change that has occurred.
116    * The valid types of events are defined by the constants in this class.
117    * @return the type of change that has occurred.
118    * @see Notifier
119    */

120   int getEventType();
121
122   /**
123    * An {@link Notification#getFeatureID ID} indicating that
124    * no feature ID information is applicable.
125    * @see Notification#getFeatureID
126    */

127   int NO_FEATURE_ID = -1;
128
129   /**
130    * Returns the numeric ID of the feature relative to the given class, or {@link #NO_FEATURE_ID} when not applicable.
131    * @param expectedClass the class to which the ID is relative.
132    * @return the numeric ID of the feature.
133    * @see #NO_FEATURE_ID
134    */

135   int getFeatureID(Class JavaDoc expectedClass);
136
137   /**
138    * Returns the object representing the feature of the notifier that has changed.
139    * @return the feature that has changed.
140    */

141   Object JavaDoc getFeature();
142
143   /**
144    * Returns the value of the notifier's feature before the change occurred.
145    * For a list-based feature, this represents a value, or a list of values, removed from the list.
146    * For a move, this represents the old position of the moved value.
147    * @return the old value of the notifier's feature.
148    */

149   Object JavaDoc getOldValue();
150
151   /**
152    * Returns the value of the notifier's feature after the change occurred.
153    * For a list-based feature, this represents a value, or a list of values, added to the list.
154    * @return the new value of the notifier's feature.
155    */

156   Object JavaDoc getNewValue();
157
158   /**
159    * Returns whether the notifier's feature was considered set before the change occurred.
160    * @return whether the notifier's feature was considered set before the change occurred.
161    */

162   boolean wasSet();
163
164   /**
165    * Returns true if this notification represents an event that did not change the state of the notifying object.
166    * For the events {@link #ADD}, {@link #ADD_MANY}, {@link #REMOVE}, {@link #REMOVE_MANY}, {@link #MOVE},
167    * it always returns false.
168    * For the events {@link #RESOLVE} and {@link #REMOVING_ADAPTER} it always returns true.
169    * For the events {@link #SET} and {@link #UNSET} it returns true if the old and the new value are equal;
170    * In addition, for certain types of features there may be a distiction between
171    * being set to a default value and not being set at all, which implies that it has the default value.
172    * In this situation, even in the case that the old and new values are equal,
173    * isTouch may never the less return false in order to indicate that, although the value has not changed,
174    * the feature has gone from simply having a default value to being set to that same default value,
175    * or has gone from being set to the default value back to being unset.
176    * @return whether or not this is a state changing modification.
177    */

178   boolean isTouch();
179
180   /**
181    * Returns true if the notification's feature has been set to its default value.
182    * @return whether or not this is a feature reset event.
183    */

184   boolean isReset();
185
186   /**
187    * An {@link Notification#getPosition index} indicating that
188    * no position information is applicable.
189    * @see Notification#getPosition
190    */

191   int NO_INDEX = -1;
192
193   /**
194    * Returns the position within a list-based feature at which the change occurred.
195    * It returns {@link #NO_INDEX} when not applicable.
196    * @return the positition at which the change occurred.
197    */

198   int getPosition();
199
200   /**
201    * Returns whether the notification can be and has been merged with this one.
202    * @return whether the notification can be and has been merged with this one.
203    */

204   boolean merge(Notification notification);
205
206   /**
207    * Returns the old value of the notifier's feature, if it is of type <code>boolean</code>.
208    * @return the old value of the notifier's feature.
209    * @exception IllegalStateException if the feature isn't <code>boolean</code>.
210    */

211   boolean getOldBooleanValue();
212
213   /**
214    * Returns the new value of the notifier's feature, if it is of type <code>boolean</code>.
215    * @return the new value of the notifier's feature.
216    * @exception IllegalStateException if the feature isn't <code>boolean</code>.
217    */

218   boolean getNewBooleanValue();
219
220   /**
221    * Returns the old value of the notifier's feature, if it is of type <code>byte</code>.
222    * @return the old value of the notifier's feature.
223    * @exception IllegalStateException if the feature isn't <code>byte</code>.
224    */

225   byte getOldByteValue();
226
227   /**
228    * Returns the new value of the notifier's feature, if it is of type <code>byte</code>.
229    * @return the new value of the notifier's feature.
230    * @exception IllegalStateException if the feature isn't <code>byte</code>.
231    */

232   byte getNewByteValue();
233
234   /**
235    * Returns the old value of the notifier's feature, if it is of type <code>char</code>.
236    * @return the old value of the notifier's feature.
237    * @exception IllegalStateException if the feature isn't <code>char</code>.
238    */

239   char getOldCharValue();
240
241   /**
242    * Returns the new value of the notifier's feature, if it is of type <code>char</code>.
243    * @return the new value of the notifier's feature.
244    * @exception IllegalStateException if the feature isn't <code>char</code>.
245    */

246   char getNewCharValue();
247
248   /**
249    * Returns the old value of the notifier's feature, if it is of type <code>double</code>.
250    * @return the old value of the notifier's feature.
251    * @exception IllegalStateException if the feature isn't <code>double</code>.
252    */

253   double getOldDoubleValue();
254
255   /**
256    * Returns the new value of the notifier's feature, if it is of type <code>double</code>.
257    * @return the new value of the notifier's feature.
258    * @exception IllegalStateException if the feature isn't <code>double</code>.
259    */

260   double getNewDoubleValue();
261
262   /**
263    * Returns the old value of the notifier's feature, if it is of type <code>float</code>.
264    * @return the old value of the notifier's feature.
265    * @exception IllegalStateException if the feature isn't <code>float</code>.
266    */

267   float getOldFloatValue();
268
269   /**
270    * Returns the new value of the notifier's feature, if it is of type <code>float</code>.
271    * @return the new value of the notifier's feature.
272    * @exception IllegalStateException if the feature isn't <code>float</code>.
273    */

274   float getNewFloatValue();
275
276   /**
277    * Returns the old value of the notifier's feature, if it is of type <code>int</code>.
278    * @return the old value of the notifier's feature.
279    * @exception IllegalStateException if the feature isn't <code>int</code>.
280    */

281   int getOldIntValue();
282
283   /**
284    * Returns the new value of the notifier's feature, if it is of type <code>int</code>.
285    * @return the new value of the notifier's feature.
286    * @exception IllegalStateException if the feature isn't <code>int</code>.
287    */

288   int getNewIntValue();
289
290   /**
291    * Returns the old value of the notifier's feature, if it is of type <code>long</code>.
292    * @return the old value of the notifier's feature.
293    * @exception IllegalStateException if the feature isn't <code>long</code>.
294    */

295   long getOldLongValue();
296
297   /**
298    * Returns the new value of the notifier's feature, if it is of type <code>long</code>.
299    * @return the new value of the notifier's feature.
300    * @exception IllegalStateException if the feature isn't <code>long</code>.
301    */

302   long getNewLongValue();
303
304   /**
305    * Returns the old value of the notifier's feature, if it is of type <code>short</code>.
306    * @return the old value of the notifier's feature.
307    * @exception IllegalStateException if the feature isn't <code>short</code>.
308    */

309   short getOldShortValue();
310
311   /**
312    * Returns the new value of the notifier's feature, if it is of type <code>short</code>.
313    * @return the new value of the notifier's feature.
314    * @exception IllegalStateException if the feature isn't <code>short</code>.
315    */

316   short getNewShortValue();
317
318   /**
319    * Returns the old value of the notifier's feature as a String.
320    * @return the old value of the notifier's feature.
321    */

322   String JavaDoc getOldStringValue();
323
324   /**
325    * Returns the new value of the notifier's feature as a String.
326    * @return the new value of the notifier's feature.
327    */

328   String JavaDoc getNewStringValue();
329 }
330
Popular Tags