KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > impl > ENotificationImpl


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: ENotificationImpl.java,v 1.2 2005/06/08 06:20:10 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.impl;
18
19
20 import org.eclipse.emf.common.notify.impl.NotificationImpl;
21 import org.eclipse.emf.ecore.EClass;
22 import org.eclipse.emf.ecore.EStructuralFeature;
23 import org.eclipse.emf.ecore.InternalEObject;
24
25
26 /**
27  * An implementation an Ecore-specific notification.
28  */

29 public class ENotificationImpl extends NotificationImpl
30 {
31   protected InternalEObject notifier;
32   protected int featureID = NO_FEATURE_ID;
33   protected EStructuralFeature feature = null;
34
35   public ENotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object JavaDoc oldValue, Object JavaDoc newValue, boolean isSetChange)
36   {
37     this(notifier, eventType, feature, oldValue, newValue, isSetChange ? IS_SET_CHANGE_INDEX : NO_INDEX);
38   }
39
40   public ENotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object JavaDoc oldValue, Object JavaDoc newValue)
41   {
42     this(notifier, eventType, feature, oldValue, newValue, NO_INDEX);
43   }
44
45   public ENotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object JavaDoc oldValue, Object JavaDoc newValue, int position)
46   {
47     super(eventType, oldValue, newValue, position);
48     this.notifier = notifier;
49     this.feature = feature;
50   }
51
52   public ENotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object JavaDoc oldValue, Object JavaDoc newValue, int position, boolean wasSet)
53   {
54     super(eventType, oldValue, newValue, position, wasSet);
55     this.notifier = notifier;
56     this.feature = feature;
57   }
58
59   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, Object JavaDoc oldValue, Object JavaDoc newValue, boolean isSetChange)
60   {
61     this(notifier, eventType, featureID, oldValue, newValue, isSetChange ? IS_SET_CHANGE_INDEX : NO_INDEX);
62   }
63
64   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, Object JavaDoc oldValue, Object JavaDoc newValue, int position, boolean wasSet)
65   {
66     super(eventType, oldValue, newValue, position, wasSet);
67     this.notifier = notifier;
68     this.featureID = featureID;
69   }
70
71   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, Object JavaDoc oldValue, Object JavaDoc newValue)
72   {
73     this(notifier, eventType, featureID, oldValue, newValue, NO_INDEX);
74   }
75
76   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, Object JavaDoc oldValue, Object JavaDoc newValue, int position)
77   {
78     super(eventType, oldValue, newValue, position);
79     this.notifier = notifier;
80     this.featureID = featureID;
81   }
82
83   public ENotificationImpl
84     (InternalEObject notifier, int eventType, int featureID, boolean oldBooleanValue, boolean newBooleanValue, boolean isSetChange)
85   {
86     this(notifier, eventType, featureID, oldBooleanValue, newBooleanValue);
87     if (isSetChange)
88     {
89       this.position = IS_SET_CHANGE_INDEX;
90     }
91   }
92
93   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, boolean oldBooleanValue, boolean newBooleanValue)
94   {
95     super(eventType, oldBooleanValue, newBooleanValue);
96     this.notifier = notifier;
97     this.featureID = featureID;
98   }
99
100   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, byte oldByteValue, byte newByteValue, boolean isSetChange)
101   {
102     this(notifier, eventType, featureID, oldByteValue, newByteValue);
103     if (isSetChange)
104     {
105       this.position = IS_SET_CHANGE_INDEX;
106     }
107   }
108
109   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, byte oldByteValue, byte newByteValue)
110   {
111     super(eventType, oldByteValue, newByteValue);
112     this.notifier = notifier;
113     this.featureID = featureID;
114   }
115
116   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, char oldCharValue, char newCharValue, boolean isSetChange)
117   {
118     this(notifier, eventType, featureID, oldCharValue, newCharValue);
119     if (isSetChange)
120     {
121       this.position = IS_SET_CHANGE_INDEX;
122     }
123   }
124
125   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, char oldCharValue, char newCharValue)
126   {
127     super(eventType, oldCharValue, newCharValue);
128     this.notifier = notifier;
129     this.featureID = featureID;
130   }
131
132   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, double oldDoubleValue, double newDoubleValue, boolean isSetChange)
133   {
134     this(notifier, eventType, featureID, oldDoubleValue, newDoubleValue);
135     if (isSetChange)
136     {
137       this.position = IS_SET_CHANGE_INDEX;
138     }
139   }
140
141   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, double oldDoubleValue, double newDoubleValue)
142   {
143     super(eventType, oldDoubleValue, newDoubleValue);
144     this.notifier = notifier;
145     this.featureID = featureID;
146   }
147
148   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, float oldFloatValue, float newFloatValue, boolean isSetChange)
149   {
150     this(notifier, eventType, featureID, oldFloatValue, newFloatValue);
151     if (isSetChange)
152     {
153       this.position = IS_SET_CHANGE_INDEX;
154     }
155   }
156
157   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, float oldFloatValue, float newFloatValue)
158   {
159     super(eventType, oldFloatValue, newFloatValue);
160     this.notifier = notifier;
161     this.featureID = featureID;
162   }
163
164   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, int oldIntValue, int newIntValue, boolean isSetChange)
165   {
166     this(notifier, eventType, featureID, oldIntValue, newIntValue);
167     if (isSetChange)
168     {
169       this.position = IS_SET_CHANGE_INDEX;
170     }
171   }
172
173   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, int oldIntValue, int newIntValue)
174   {
175     super(eventType, oldIntValue, newIntValue);
176     this.notifier = notifier;
177     this.featureID = featureID;
178   }
179
180   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, long oldLongValue, long newLongValue, boolean isSetChange)
181   {
182     this(notifier, eventType, featureID, oldLongValue, newLongValue);
183     if (isSetChange)
184     {
185       this.position = IS_SET_CHANGE_INDEX;
186     }
187   }
188
189   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, long oldLongValue, long newLongValue)
190   {
191     super(eventType, oldLongValue, newLongValue);
192     this.notifier = notifier;
193     this.featureID = featureID;
194   }
195
196   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, short oldShortValue, short newShortValue, boolean isSetChange)
197   {
198     this(notifier, eventType, featureID, oldShortValue, newShortValue);
199     if (isSetChange)
200     {
201       this.position = IS_SET_CHANGE_INDEX;
202     }
203   }
204
205   public ENotificationImpl(InternalEObject notifier, int eventType, int featureID, short oldShortValue, short newShortValue)
206   {
207     super(eventType, oldShortValue, newShortValue);
208     this.notifier = notifier;
209     this.featureID = featureID;
210   }
211
212   public Object JavaDoc getNotifier()
213   {
214     return notifier;
215   }
216
217   public Object JavaDoc getFeature()
218   {
219     if (feature == null && featureID != NO_FEATURE_ID)
220     {
221       EClass eClass = notifier.eClass();
222       feature = eClass.getEStructuralFeature(featureID);
223     }
224     return feature;
225   }
226
227   public int getFeatureID(Class JavaDoc expectedClass)
228   {
229     if (featureID == NO_FEATURE_ID && feature != null)
230     {
231       featureID = notifier.eDerivedStructuralFeatureID(feature.getFeatureID(), feature.getContainerClass());
232     }
233     return notifier.eBaseStructuralFeatureID(featureID, expectedClass);
234   }
235
236   protected Object JavaDoc getFeatureDefaultValue()
237   {
238     Object JavaDoc feature = getFeature();
239     if (feature instanceof EStructuralFeature)
240     {
241       return ((EStructuralFeature)feature).getDefaultValue();
242     }
243     return null;
244   }
245
246   protected boolean isFeatureUnsettable()
247   {
248     Object JavaDoc feature = getFeature();
249     if (feature instanceof EStructuralFeature)
250     {
251       return ((EStructuralFeature)feature).isUnsettable();
252     }
253     return false;
254   }
255 }
256
257
Popular Tags