KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2ecore > impl > Ecore2EcoreMappingRootImpl


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2004-2005 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: Ecore2EcoreMappingRootImpl.java,v 1.5 2005/06/08 06:21:24 nickb Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2ecore.impl;
18
19
20 import java.util.Collection JavaDoc;
21 import java.util.Iterator JavaDoc;
22
23 import org.eclipse.emf.common.notify.NotificationChain;
24
25 import org.eclipse.emf.ecore.EClass;
26 import org.eclipse.emf.ecore.EPackage;
27 import org.eclipse.emf.ecore.EStructuralFeature;
28 import org.eclipse.emf.ecore.InternalEObject;
29
30 import org.eclipse.emf.ecore.util.InternalEList;
31
32 import org.eclipse.emf.mapping.Mapping;
33 import org.eclipse.emf.mapping.MappingHelper;
34 import org.eclipse.emf.mapping.MappingPackage;
35
36 import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreMappingRoot;
37 import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcorePackage;
38
39 import org.eclipse.emf.mapping.impl.MappingRootImpl;
40
41
42 /**
43  * <!-- begin-user-doc -->
44  * An implementation of the model object '<em><b>Mapping Root</b></em>'.
45  * <!-- end-user-doc -->
46  * <p>
47  * </p>
48  *
49  * @generated
50  */

51 public class Ecore2EcoreMappingRootImpl extends MappingRootImpl implements Ecore2EcoreMappingRoot
52 {
53   /**
54    * <!-- begin-user-doc -->
55    * <!-- end-user-doc -->
56    * @generated
57    */

58   protected Ecore2EcoreMappingRootImpl()
59   {
60     super();
61   }
62
63   /**
64    * <!-- begin-user-doc -->
65    * <!-- end-user-doc -->
66    * @generated
67    */

68   protected EClass eStaticClass()
69   {
70     return Ecore2EcorePackage.eINSTANCE.getEcore2EcoreMappingRoot();
71   }
72
73   /**
74    * <!-- begin-user-doc -->
75    * <!-- end-user-doc -->
76    * @generated
77    */

78   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
79   {
80     if (featureID >= 0)
81     {
82       switch (eDerivedStructuralFeatureID(featureID, baseClass))
83       {
84         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER:
85           if (helper != null)
86             msgs = ((InternalEObject)helper).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER, null, msgs);
87           return basicSetHelper((MappingHelper)otherEnd, msgs);
88         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED:
89           return ((InternalEList)getNested()).basicAdd(otherEnd, msgs);
90         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
91           if (eContainer != null)
92             msgs = eBasicRemoveFromContainer(msgs);
93           return eBasicSetContainer(otherEnd, Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN, msgs);
94         default:
95           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
96       }
97     }
98     if (eContainer != null)
99       msgs = eBasicRemoveFromContainer(msgs);
100     return eBasicSetContainer(otherEnd, featureID, msgs);
101   }
102
103   /**
104    * <!-- begin-user-doc -->
105    * <!-- end-user-doc -->
106    * @generated
107    */

108   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
109   {
110     if (featureID >= 0)
111     {
112       switch (eDerivedStructuralFeatureID(featureID, baseClass))
113       {
114         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER:
115           return basicSetHelper(null, msgs);
116         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED:
117           return ((InternalEList)getNested()).basicRemove(otherEnd, msgs);
118         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
119           return eBasicSetContainer(null, Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN, msgs);
120         default:
121           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
122       }
123     }
124     return eBasicSetContainer(null, featureID, msgs);
125   }
126
127   /**
128    * <!-- begin-user-doc -->
129    * <!-- end-user-doc -->
130    * @generated
131    */

132   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
133   {
134     if (eContainerFeatureID >= 0)
135     {
136       switch (eContainerFeatureID)
137       {
138         case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
139           return eContainer.eInverseRemove(this, MappingPackage.MAPPING__NESTED, Mapping.class, msgs);
140         default:
141           return eDynamicBasicRemoveFromContainer(msgs);
142       }
143     }
144     return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
145   }
146
147   /**
148    * <!-- begin-user-doc -->
149    * <!-- end-user-doc -->
150    * @generated
151    */

152   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
153   {
154     switch (eDerivedStructuralFeatureID(eFeature))
155     {
156       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER:
157         return getHelper();
158       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED:
159         return getNested();
160       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
161         return getNestedIn();
162       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__INPUTS:
163         return getInputs();
164       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUTS:
165         return getOutputs();
166       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TYPE_MAPPING:
167         if (resolve) return getTypeMapping();
168         return basicGetTypeMapping();
169       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUT_READ_ONLY:
170         return isOutputReadOnly() ? Boolean.TRUE : Boolean.FALSE;
171       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TOP_TO_BOTTOM:
172         return isTopToBottom() ? Boolean.TRUE : Boolean.FALSE;
173       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__COMMAND_STACK:
174         return getCommandStack();
175     }
176     return eDynamicGet(eFeature, resolve);
177   }
178
179   /**
180    * <!-- begin-user-doc -->
181    * <!-- end-user-doc -->
182    * @generated
183    */

184   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
185   {
186     switch (eDerivedStructuralFeatureID(eFeature))
187     {
188       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER:
189         setHelper((MappingHelper)newValue);
190         return;
191       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED:
192         getNested().clear();
193         getNested().addAll((Collection JavaDoc)newValue);
194         return;
195       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
196         setNestedIn((Mapping)newValue);
197         return;
198       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__INPUTS:
199         getInputs().clear();
200         getInputs().addAll((Collection JavaDoc)newValue);
201         return;
202       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUTS:
203         getOutputs().clear();
204         getOutputs().addAll((Collection JavaDoc)newValue);
205         return;
206       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TYPE_MAPPING:
207         setTypeMapping((Mapping)newValue);
208         return;
209       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUT_READ_ONLY:
210         setOutputReadOnly(((Boolean JavaDoc)newValue).booleanValue());
211         return;
212       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TOP_TO_BOTTOM:
213         setTopToBottom(((Boolean JavaDoc)newValue).booleanValue());
214         return;
215       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__COMMAND_STACK:
216         setCommandStack((String JavaDoc)newValue);
217         return;
218     }
219     eDynamicSet(eFeature, newValue);
220   }
221
222   /**
223    * <!-- begin-user-doc -->
224    * <!-- end-user-doc -->
225    * @generated
226    */

227   public void eUnset(EStructuralFeature eFeature)
228   {
229     switch (eDerivedStructuralFeatureID(eFeature))
230     {
231       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER:
232         setHelper((MappingHelper)null);
233         return;
234       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED:
235         getNested().clear();
236         return;
237       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
238         setNestedIn((Mapping)null);
239         return;
240       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__INPUTS:
241         getInputs().clear();
242         return;
243       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUTS:
244         getOutputs().clear();
245         return;
246       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TYPE_MAPPING:
247         setTypeMapping((Mapping)null);
248         return;
249       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUT_READ_ONLY:
250         setOutputReadOnly(OUTPUT_READ_ONLY_EDEFAULT);
251         return;
252       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TOP_TO_BOTTOM:
253         setTopToBottom(TOP_TO_BOTTOM_EDEFAULT);
254         return;
255       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__COMMAND_STACK:
256         setCommandStack(COMMAND_STACK_EDEFAULT);
257         return;
258     }
259     eDynamicUnset(eFeature);
260   }
261
262   /**
263    * <!-- begin-user-doc -->
264    * <!-- end-user-doc -->
265    * @generated
266    */

267   public boolean eIsSet(EStructuralFeature eFeature)
268   {
269     switch (eDerivedStructuralFeatureID(eFeature))
270     {
271       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__HELPER:
272         return helper != null;
273       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED:
274         return nested != null && !nested.isEmpty();
275       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__NESTED_IN:
276         return getNestedIn() != null;
277       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__INPUTS:
278         return inputs != null && !inputs.isEmpty();
279       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUTS:
280         return outputs != null && !outputs.isEmpty();
281       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TYPE_MAPPING:
282         return typeMapping != null;
283       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__OUTPUT_READ_ONLY:
284         return outputReadOnly != OUTPUT_READ_ONLY_EDEFAULT;
285       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__TOP_TO_BOTTOM:
286         return topToBottom != TOP_TO_BOTTOM_EDEFAULT;
287       case Ecore2EcorePackage.ECORE2_ECORE_MAPPING_ROOT__COMMAND_STACK:
288         return COMMAND_STACK_EDEFAULT == null ? commandStack != null : !COMMAND_STACK_EDEFAULT.equals(commandStack);
289     }
290     return eDynamicIsSet(eFeature);
291   }
292
293   /* (non-Javadoc)
294    * @see org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreMapping#getInputEPackage()
295    */

296   public EPackage getInputEPackage()
297   {
298     return getInputs().isEmpty() ? null : (EPackage)getInputs().get(0);
299   }
300
301   /* (non-Javadoc)
302    * @see org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreMapping#getOutputEPackage()
303    */

304   public EPackage getOutputEPackage()
305   {
306     return getOutputs().isEmpty() ? null : (EPackage)getOutputs().get(0);
307   }
308   
309   /* (non-Javadoc)
310    * @see org.eclipse.emf.mapping.MappingRoot#canCreateMapping(java.util.Collection, java.util.Collection, org.eclipse.emf.mapping.Mapping)
311    */

312   public boolean canCreateMapping(Collection JavaDoc inputs, Collection JavaDoc outputs, Mapping mapping)
313   {
314     if (mapping == this)
315     {
316       for (Iterator JavaDoc i = inputs.iterator(); i.hasNext();)
317       {
318         if (!(i.next() instanceof EPackage))
319         {
320           return false;
321         }
322       }
323       for (Iterator JavaDoc i = outputs.iterator(); i.hasNext();)
324       {
325         if (!(i.next() instanceof EPackage))
326         {
327           return false;
328         }
329       }
330       return true;
331     }
332     else
333     {
334       return super.canCreateMapping(inputs, outputs, mapping);
335     }
336   }
337 } //Ecore2EcoreMappingRootImpl
338
Popular Tags