KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > impl > MappingHelperImpl


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: MappingHelperImpl.java,v 1.5 2005/06/08 06:21:43 nickb Exp $
16  */

17 package org.eclipse.emf.mapping.impl;
18
19
20 import java.util.Collection JavaDoc;
21
22 import org.eclipse.emf.common.notify.Notification;
23 import org.eclipse.emf.common.notify.NotificationChain;
24 import org.eclipse.emf.common.util.EList;
25 import org.eclipse.emf.ecore.EClass;
26 import org.eclipse.emf.ecore.EObject;
27 import org.eclipse.emf.ecore.EStructuralFeature;
28 import org.eclipse.emf.ecore.InternalEObject;
29 import org.eclipse.emf.ecore.impl.ENotificationImpl;
30 import org.eclipse.emf.ecore.impl.EObjectImpl;
31 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
32 import org.eclipse.emf.ecore.util.EcoreUtil;
33 import org.eclipse.emf.ecore.util.InternalEList;
34 import org.eclipse.emf.mapping.Mapping;
35 import org.eclipse.emf.mapping.MappingHelper;
36 import org.eclipse.emf.mapping.MappingPackage;
37
38
39 /**
40  * <!-- begin-user-doc -->
41  * An implementation of the model object '<em><b>Helper</b></em>'.
42  * <!-- end-user-doc -->
43  * <p>
44  * The following features are implemented:
45  * <ul>
46  * <li>{@link org.eclipse.emf.mapping.impl.MappingHelperImpl#getMapper <em>Mapper</em>}</li>
47  * <li>{@link org.eclipse.emf.mapping.impl.MappingHelperImpl#getHelpedObject <em>Helped Object</em>}</li>
48  * <li>{@link org.eclipse.emf.mapping.impl.MappingHelperImpl#getNestedIn <em>Nested In</em>}</li>
49  * <li>{@link org.eclipse.emf.mapping.impl.MappingHelperImpl#getNested <em>Nested</em>}</li>
50  * </ul>
51  * </p>
52  *
53  * @generated
54  */

55 public class MappingHelperImpl extends EObjectImpl implements MappingHelper
56 {
57   /**
58    * The cached value of the '{@link #getHelpedObject() <em>Helped Object</em>}' reference.
59    * <!-- begin-user-doc -->
60    * <!-- end-user-doc -->
61    * @see #getHelpedObject()
62    * @generated
63    * @ordered
64    */

65   protected EObject helpedObject = null;
66
67   /**
68    * The cached value of the '{@link #getNested() <em>Nested</em>}' containment reference list.
69    * <!-- begin-user-doc -->
70    * <!-- end-user-doc -->
71    * @see #getNested()
72    * @generated
73    * @ordered
74    */

75   protected EList nested = null;
76
77   /**
78    * <!-- begin-user-doc -->
79    * <!-- end-user-doc -->
80    * @generated
81    */

82   protected MappingHelperImpl()
83   {
84     super();
85   }
86
87   /**
88    * <!-- begin-user-doc -->
89    * <!-- end-user-doc -->
90    * @generated
91    */

92   protected EClass eStaticClass()
93   {
94     return MappingPackage.eINSTANCE.getMappingHelper();
95   }
96
97   /**
98    * <!-- begin-user-doc -->
99    * <!-- end-user-doc -->
100    * @generated
101    */

102   public Mapping getMapper()
103   {
104     if (eContainerFeatureID != MappingPackage.MAPPING_HELPER__MAPPER) return null;
105     return (Mapping)eContainer;
106   }
107
108   /**
109    * <!-- begin-user-doc -->
110    * <!-- end-user-doc -->
111    * @generated
112    */

113   public void setMapper(Mapping newMapper)
114   {
115     if (newMapper != eContainer || (eContainerFeatureID != MappingPackage.MAPPING_HELPER__MAPPER && newMapper != null))
116     {
117       if (EcoreUtil.isAncestor(this, newMapper))
118         throw new IllegalArgumentException JavaDoc("Recursive containment not allowed for " + toString());
119       NotificationChain msgs = null;
120       if (eContainer != null)
121         msgs = eBasicRemoveFromContainer(msgs);
122       if (newMapper != null)
123         msgs = ((InternalEObject)newMapper).eInverseAdd(this, MappingPackage.MAPPING__HELPER, Mapping.class, msgs);
124       msgs = eBasicSetContainer((InternalEObject)newMapper, MappingPackage.MAPPING_HELPER__MAPPER, msgs);
125       if (msgs != null) msgs.dispatch();
126     }
127     else if (eNotificationRequired())
128       eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.MAPPING_HELPER__MAPPER, newMapper, newMapper));
129   }
130
131   /**
132    * <!-- begin-user-doc -->
133    * <!-- end-user-doc -->
134    * @generated
135    */

136   public EObject getHelpedObject()
137   {
138     if (helpedObject != null && helpedObject.eIsProxy())
139     {
140       EObject oldHelpedObject = helpedObject;
141       helpedObject = (EObject)eResolveProxy((InternalEObject)helpedObject);
142       if (helpedObject != oldHelpedObject)
143       {
144         if (eNotificationRequired())
145           eNotify(new ENotificationImpl(this, Notification.RESOLVE, MappingPackage.MAPPING_HELPER__HELPED_OBJECT, oldHelpedObject, helpedObject));
146       }
147     }
148     return helpedObject;
149   }
150
151   /**
152    * <!-- begin-user-doc -->
153    * <!-- end-user-doc -->
154    * @generated
155    */

156   public EObject basicGetHelpedObject()
157   {
158     return helpedObject;
159   }
160
161   /**
162    * <!-- begin-user-doc -->
163    * <!-- end-user-doc -->
164    * @generated
165    */

166   public void setHelpedObject(EObject newHelpedObject)
167   {
168     EObject oldHelpedObject = helpedObject;
169     helpedObject = newHelpedObject;
170     if (eNotificationRequired())
171       eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.MAPPING_HELPER__HELPED_OBJECT, oldHelpedObject, helpedObject));
172   }
173
174   /**
175    * <!-- begin-user-doc -->
176    * <!-- end-user-doc -->
177    * @generated
178    */

179   public MappingHelper getNestedIn()
180   {
181     if (eContainerFeatureID != MappingPackage.MAPPING_HELPER__NESTED_IN) return null;
182     return (MappingHelper)eContainer;
183   }
184
185   /**
186    * <!-- begin-user-doc -->
187    * <!-- end-user-doc -->
188    * @generated
189    */

190   public void setNestedIn(MappingHelper newNestedIn)
191   {
192     if (newNestedIn != eContainer || (eContainerFeatureID != MappingPackage.MAPPING_HELPER__NESTED_IN && newNestedIn != null))
193     {
194       if (EcoreUtil.isAncestor(this, newNestedIn))
195         throw new IllegalArgumentException JavaDoc("Recursive containment not allowed for " + toString());
196       NotificationChain msgs = null;
197       if (eContainer != null)
198         msgs = eBasicRemoveFromContainer(msgs);
199       if (newNestedIn != null)
200         msgs = ((InternalEObject)newNestedIn).eInverseAdd(this, MappingPackage.MAPPING_HELPER__NESTED, MappingHelper.class, msgs);
201       msgs = eBasicSetContainer((InternalEObject)newNestedIn, MappingPackage.MAPPING_HELPER__NESTED_IN, msgs);
202       if (msgs != null) msgs.dispatch();
203     }
204     else if (eNotificationRequired())
205       eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.MAPPING_HELPER__NESTED_IN, newNestedIn, newNestedIn));
206   }
207
208   /**
209    * <!-- begin-user-doc -->
210    * <!-- end-user-doc -->
211    * @generated
212    */

213   public EList getNested()
214   {
215     if (nested == null)
216     {
217       nested = new EObjectContainmentWithInverseEList(MappingHelper.class, this, MappingPackage.MAPPING_HELPER__NESTED, MappingPackage.MAPPING_HELPER__NESTED_IN);
218     }
219     return nested;
220   }
221
222   /**
223    * <!-- begin-user-doc -->
224    * <!-- end-user-doc -->
225    * @generated
226    */

227   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
228   {
229     if (featureID >= 0)
230     {
231       switch (eDerivedStructuralFeatureID(featureID, baseClass))
232       {
233         case MappingPackage.MAPPING_HELPER__MAPPER:
234           if (eContainer != null)
235             msgs = eBasicRemoveFromContainer(msgs);
236           return eBasicSetContainer(otherEnd, MappingPackage.MAPPING_HELPER__MAPPER, msgs);
237         case MappingPackage.MAPPING_HELPER__NESTED_IN:
238           if (eContainer != null)
239             msgs = eBasicRemoveFromContainer(msgs);
240           return eBasicSetContainer(otherEnd, MappingPackage.MAPPING_HELPER__NESTED_IN, msgs);
241         case MappingPackage.MAPPING_HELPER__NESTED:
242           return ((InternalEList)getNested()).basicAdd(otherEnd, msgs);
243         default:
244           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
245       }
246     }
247     if (eContainer != null)
248       msgs = eBasicRemoveFromContainer(msgs);
249     return eBasicSetContainer(otherEnd, featureID, msgs);
250   }
251
252   /**
253    * <!-- begin-user-doc -->
254    * <!-- end-user-doc -->
255    * @generated
256    */

257   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
258   {
259     if (featureID >= 0)
260     {
261       switch (eDerivedStructuralFeatureID(featureID, baseClass))
262       {
263         case MappingPackage.MAPPING_HELPER__MAPPER:
264           return eBasicSetContainer(null, MappingPackage.MAPPING_HELPER__MAPPER, msgs);
265         case MappingPackage.MAPPING_HELPER__NESTED_IN:
266           return eBasicSetContainer(null, MappingPackage.MAPPING_HELPER__NESTED_IN, msgs);
267         case MappingPackage.MAPPING_HELPER__NESTED:
268           return ((InternalEList)getNested()).basicRemove(otherEnd, msgs);
269         default:
270           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
271       }
272     }
273     return eBasicSetContainer(null, featureID, msgs);
274   }
275
276   /**
277    * <!-- begin-user-doc -->
278    * <!-- end-user-doc -->
279    * @generated
280    */

281   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
282   {
283     if (eContainerFeatureID >= 0)
284     {
285       switch (eContainerFeatureID)
286       {
287         case MappingPackage.MAPPING_HELPER__MAPPER:
288           return eContainer.eInverseRemove(this, MappingPackage.MAPPING__HELPER, Mapping.class, msgs);
289         case MappingPackage.MAPPING_HELPER__NESTED_IN:
290           return eContainer.eInverseRemove(this, MappingPackage.MAPPING_HELPER__NESTED, MappingHelper.class, msgs);
291         default:
292           return eDynamicBasicRemoveFromContainer(msgs);
293       }
294     }
295     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
296   }
297
298   /**
299    * <!-- begin-user-doc -->
300    * <!-- end-user-doc -->
301    * @generated
302    */

303   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
304   {
305     switch (eDerivedStructuralFeatureID(eFeature))
306     {
307       case MappingPackage.MAPPING_HELPER__MAPPER:
308         return getMapper();
309       case MappingPackage.MAPPING_HELPER__HELPED_OBJECT:
310         if (resolve) return getHelpedObject();
311         return basicGetHelpedObject();
312       case MappingPackage.MAPPING_HELPER__NESTED_IN:
313         return getNestedIn();
314       case MappingPackage.MAPPING_HELPER__NESTED:
315         return getNested();
316     }
317     return eDynamicGet(eFeature, resolve);
318   }
319
320   /**
321    * <!-- begin-user-doc -->
322    * <!-- end-user-doc -->
323    * @generated
324    */

325   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
326   {
327     switch (eDerivedStructuralFeatureID(eFeature))
328     {
329       case MappingPackage.MAPPING_HELPER__MAPPER:
330         setMapper((Mapping)newValue);
331         return;
332       case MappingPackage.MAPPING_HELPER__HELPED_OBJECT:
333         setHelpedObject((EObject)newValue);
334         return;
335       case MappingPackage.MAPPING_HELPER__NESTED_IN:
336         setNestedIn((MappingHelper)newValue);
337         return;
338       case MappingPackage.MAPPING_HELPER__NESTED:
339         getNested().clear();
340         getNested().addAll((Collection JavaDoc)newValue);
341         return;
342     }
343     eDynamicSet(eFeature, newValue);
344   }
345
346   /**
347    * <!-- begin-user-doc -->
348    * <!-- end-user-doc -->
349    * @generated
350    */

351   public void eUnset(EStructuralFeature eFeature)
352   {
353     switch (eDerivedStructuralFeatureID(eFeature))
354     {
355       case MappingPackage.MAPPING_HELPER__MAPPER:
356         setMapper((Mapping)null);
357         return;
358       case MappingPackage.MAPPING_HELPER__HELPED_OBJECT:
359         setHelpedObject((EObject)null);
360         return;
361       case MappingPackage.MAPPING_HELPER__NESTED_IN:
362         setNestedIn((MappingHelper)null);
363         return;
364       case MappingPackage.MAPPING_HELPER__NESTED:
365         getNested().clear();
366         return;
367     }
368     eDynamicUnset(eFeature);
369   }
370
371   /**
372    * <!-- begin-user-doc -->
373    * <!-- end-user-doc -->
374    * @generated
375    */

376   public boolean eIsSet(EStructuralFeature eFeature)
377   {
378     switch (eDerivedStructuralFeatureID(eFeature))
379     {
380       case MappingPackage.MAPPING_HELPER__MAPPER:
381         return getMapper() != null;
382       case MappingPackage.MAPPING_HELPER__HELPED_OBJECT:
383         return helpedObject != null;
384       case MappingPackage.MAPPING_HELPER__NESTED_IN:
385         return getNestedIn() != null;
386       case MappingPackage.MAPPING_HELPER__NESTED:
387         return nested != null && !nested.isEmpty();
388     }
389     return eDynamicIsSet(eFeature);
390   }
391
392 } //MappingHelperImpl
393

394
395
Popular Tags