001 /**
002 * <copyright>
003 *
004 * Copyright (c) 2002-2006 IBM Corporation and others.
005 * All rights reserved. This program and the accompanying materials
006 * are made available under the terms of the Eclipse Public License v1.0
007 * which accompanies this distribution, and is available at
008 * http://www.eclipse.org/legal/epl-v10.html
009 *
010 * Contributors:
011 * IBM - Initial API and implementation
012 *
013 * </copyright>
014 *
015 * $Id: NotificationWrapper.java,v 1.4 2006/12/05 20:19:54 emerks Exp $
016 */
017 package org.eclipse.emf.common.notify;
018
019
020 /**
021 * A notification that wraps another notification.
022 * All the {@link Notification} methods are delegated to the wrapped notification.
023 */
024 public class NotificationWrapper implements Notification
025 {
026 /**
027 * The notification that is being wrapped.
028 */
029 protected Notification notification;
030
031 /**
032 * An optional override value for the notification's notifier.
033 */
034 protected Object notifier;
035
036 /**
037 * Create an instance with the specified notification.
038 */
039 public NotificationWrapper(Notification notification)
040 {
041 this.notification = notification;
042 }
043
044 /**
045 * Create an instance with the specified notifier and notification.
046 */
047 public NotificationWrapper(Object notifier, Notification notification)
048 {
049 this.notifier = notifier;
050 this.notification = notification;
051 }
052
053 /**
054 * Returns the local notifier if set; otherwise delegates to the getNotifier method of the notification.
055 * @return the notifier.
056 */
057 public Object getNotifier()
058 {
059 return notifier == null ? notification.getNotifier() : notifier;
060 }
061
062 /**
063 * Delegates to the getEventType method of the notification.
064 * @return the eventType.
065 */
066 public int getEventType()
067 {
068 return notification.getEventType();
069 }
070
071 /**
072 * Delegates to the getFeatureID method of the notification.
073 * @return the featureID.
074 */
075 public int getFeatureID(Class<?> expectedClass)
076 {
077 return notification.getFeatureID(expectedClass);
078 }
079
080 /**
081 * Delegates to the getFeature method of the notification.
082 * @return the feature.
083 */
084 public Object getFeature()
085 {
086 return notification.getFeature();
087 }
088
089 /**
090 * Delegates to the getOldValue method of the notification.
091 * @return the oldValue.
092 */
093 public Object getOldValue()
094 {
095 return notification.getOldValue();
096 }
097
098 /**
099 * Delegates to the getNewValue method of the notification.
100 * @return the newValue.
101 */
102 public Object getNewValue()
103 {
104 return notification.getNewValue();
105 }
106
107 /**
108 * Delegates to the wasSet method of the notification.
109 * @return the wasSet result.
110 */
111 public boolean wasSet()
112 {
113 return notification.wasSet();
114 }
115
116 /**
117 * Delegates to the isTouch method of the notification.
118 * @return the isTouch result.
119 */
120 public boolean isTouch()
121 {
122 return notification.isTouch();
123 }
124
125 /**
126 * Delegates to the isReset method of the notification.
127 * @return the isReset result.
128 */
129 public boolean isReset()
130 {
131 return notification.isReset();
132 }
133
134 /**
135 * Delegates to the getPosition method of the notification.
136 * @return the position.
137 */
138 public int getPosition()
139 {
140 return notification.getPosition();
141 }
142
143 /**
144 * Delegates to the merge method of the notification.
145 * @return the merge result.
146 */
147 public boolean merge(Notification notification)
148 {
149 return false;
150 }
151
152 /**
153 * Delegates to the getOldBooleanValue method of the notification.
154 * @return the oldBooleanValue.
155 */
156 public boolean getOldBooleanValue()
157 {
158 return notification.getOldBooleanValue();
159 }
160
161 /**
162 * Delegates to the getNewBooleanValue method of the notification.
163 * @return the newBooleanValue.
164 */
165 public boolean getNewBooleanValue()
166 {
167 return notification.getNewBooleanValue();
168 }
169
170 /**
171 * Delegates to the getOldByteValue method of the notification.
172 * @return the oldByteValue.
173 */
174 public byte getOldByteValue()
175 {
176 return notification.getOldByteValue();
177 }
178
179 /**
180 * Delegates to the getNewByteValue method of the notification.
181 * @return the newByteValue.
182 */
183 public byte getNewByteValue()
184 {
185 return notification.getNewByteValue();
186 }
187
188 /**
189 * Delegates to the getOldCharValue method of the notification.
190 * @return the oldCharValue.
191 */
192 public char getOldCharValue()
193 {
194 return notification.getOldCharValue();
195 }
196
197 /**
198 * Delegates to the getNewCharValue method of the notification.
199 * @return the newCharValue.
200 */
201 public char getNewCharValue()
202 {
203 return notification.getNewCharValue();
204 }
205
206 /**
207 * Delegates to the getOldDoubleValue method of the notification.
208 * @return the oldDoubleValue.
209 */
210 public double getOldDoubleValue()
211 {
212 return notification.getOldDoubleValue();
213 }
214
215 /**
216 * Delegates to the getNewDoubleValue method of the notification.
217 * @return the newDoubleValue.
218 */
219 public double getNewDoubleValue()
220 {
221 return notification.getNewDoubleValue();
222 }
223
224 /**
225 * Delegates to the getOldFloatValue method of the notification.
226 * @return the oldFloatValue.
227 */
228 public float getOldFloatValue()
229 {
230 return notification.getOldFloatValue();
231 }
232
233 /**
234 * Delegates to the getNewFloatValue method of the notification.
235 * @return the newFloatValue.
236 */
237 public float getNewFloatValue()
238 {
239 return notification.getNewFloatValue();
240 }
241
242 /**
243 * Delegates to the getOldIntValue method of the notification.
244 * @return the oldIntValue.
245 */
246 public int getOldIntValue()
247 {
248 return notification.getOldIntValue();
249 }
250
251 /**
252 * Delegates to the getNewIntValue method of the notification.
253 * @return the newIntValue.
254 */
255 public int getNewIntValue()
256 {
257 return notification.getNewIntValue();
258 }
259
260 /**
261 * Delegates to the getOldLongValue method of the notification.
262 * @return the oldLongValue.
263 */
264 public long getOldLongValue()
265 {
266 return notification.getOldLongValue();
267 }
268
269 /**
270 * Delegates to the getNewLongValue method of the notification.
271 * @return the newLongValue.
272 */
273 public long getNewLongValue()
274 {
275 return notification.getNewLongValue();
276 }
277
278 /**
279 * Delegates to the getOldShortValue method of the notification.
280 * @return the oldShortValue.
281 */
282 public short getOldShortValue()
283 {
284 return notification.getOldShortValue();
285 }
286
287 /**
288 * Delegates to the getNewShortValue method of the notification.
289 * @return the newShortValue.
290 */
291 public short getNewShortValue()
292 {
293 return notification.getNewShortValue();
294 }
295
296 /**
297 * Delegates to the getOldStringValue method of the notification.
298 * @return the oldStringValue.
299 */
300 public String getOldStringValue()
301 {
302 return notification.getOldStringValue();
303 }
304
305 /**
306 * Delegates to the getNewStringValue method of the notification.
307 * @return the newStringValue.
308 */
309 public String getNewStringValue()
310 {
311 return notification.getNewStringValue();
312 }
313 }