KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2xml > impl > XMLMapImpl


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 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: XMLMapImpl.java,v 1.2 2005/06/21 16:17:03 khussey Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2xml.impl;
18
19 import java.util.Collection JavaDoc;
20
21 import java.util.List JavaDoc;
22
23 import org.eclipse.emf.common.notify.Notification;
24 import org.eclipse.emf.common.notify.NotificationChain;
25
26 import org.eclipse.emf.common.util.EMap;
27
28 import org.eclipse.emf.ecore.EClass;
29 import org.eclipse.emf.ecore.EClassifier;
30 import org.eclipse.emf.ecore.ENamedElement;
31 import org.eclipse.emf.ecore.EPackage;
32 import org.eclipse.emf.ecore.EStructuralFeature;
33 import org.eclipse.emf.ecore.InternalEObject;
34
35 import org.eclipse.emf.ecore.impl.ENotificationImpl;
36 import org.eclipse.emf.ecore.impl.EObjectImpl;
37
38 import org.eclipse.emf.ecore.util.EcoreEMap;
39 import org.eclipse.emf.ecore.util.InternalEList;
40 import org.eclipse.emf.ecore.xmi.XMLResource;
41 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
42 import org.eclipse.emf.mapping.ecore2xml.XMLInfo;
43 import org.eclipse.emf.mapping.ecore2xml.XMLMap;
44
45 /**
46  * <!-- begin-user-doc -->
47  * An implementation of the model object '<em><b>XML Map</b></em>'.
48  * <!-- end-user-doc -->
49  * <p>
50  * The following features are implemented:
51  * <ul>
52  * <li>{@link org.eclipse.emf.mapping.ecore2xml.impl.XMLMapImpl#getIDAttributeName <em>ID Attribute Name</em>}</li>
53  * <li>{@link org.eclipse.emf.mapping.ecore2xml.impl.XMLMapImpl#getEcoreToXMLInfo <em>Ecore To XML Info</em>}</li>
54  * <li>{@link org.eclipse.emf.mapping.ecore2xml.impl.XMLMapImpl#getNoNamespacePackage <em>No Namespace Package</em>}</li>
55  * </ul>
56  * </p>
57  *
58  * @generated
59  */

60 public class XMLMapImpl extends EObjectImpl implements XMLMap
61 {
62   
63   /**
64    * The default value of the '{@link #getIDAttributeName() <em>ID Attribute Name</em>}' attribute.
65    * <!-- begin-user-doc -->
66    * <!-- end-user-doc -->
67    * @see #getIDAttributeName()
68    * @generated
69    * @ordered
70    */

71   protected static final String JavaDoc IDATTRIBUTE_NAME_EDEFAULT = null;
72   
73   /**
74    * The cached value of the '{@link #getEcoreToXMLInfo() <em>Ecore To XML Info</em>}' map.
75    * <!-- begin-user-doc -->
76    * <!-- end-user-doc -->
77    * @see #getEcoreToXMLInfo()
78    * @generated
79    * @ordered
80    */

81   protected EMap ecoreToXMLInfo = null;
82   
83   /**
84    * <!-- begin-user-doc -->
85    * <!-- end-user-doc -->
86    * @generated
87    */

88   protected XMLMapImpl()
89   {
90     super();
91   }
92
93   /**
94    * <!-- begin-user-doc -->
95    * <!-- end-user-doc -->
96    * @generated
97    */

98   protected EClass eStaticClass()
99   {
100     return Ecore2XMLPackage.eINSTANCE.getXMLMap();
101   }
102
103   /**
104    * <!-- begin-user-doc -->
105    * <!-- end-user-doc -->
106    * @generated NOT
107    */

108   public String JavaDoc getIDAttributeName()
109   {
110     return delegateXMLMap.getIDAttributeName();
111   }
112   
113   /**
114    * <!-- begin-user-doc -->
115    * <!-- end-user-doc -->
116    * @generated NOT
117    */

118   public void setIDAttributeName(String JavaDoc newIDAttributeName)
119   {
120     String JavaDoc oldIDAttributeName = delegateXMLMap.getIDAttributeName();
121     delegateXMLMap.setIDAttributeName(newIDAttributeName);
122     if (eNotificationRequired())
123       eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME, oldIDAttributeName, newIDAttributeName));
124   }
125   
126   /**
127    * <!-- begin-user-doc -->
128    * <!-- end-user-doc -->
129    * @generated
130    */

131   public EMap getEcoreToXMLInfo()
132   {
133     if (ecoreToXMLInfo == null)
134     {
135       ecoreToXMLInfo = new EcoreEMap(Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry(), ENamedElementToXMLInfoMapEntryImpl.class, this, Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO);
136     }
137     return ecoreToXMLInfo;
138   }
139
140   /**
141    * <!-- begin-user-doc -->
142    * <!-- end-user-doc -->
143    * @generated
144    */

145   public EPackage getNoNamespacePackage()
146   {
147     EPackage noNamespacePackage = basicGetNoNamespacePackage();
148     return noNamespacePackage == null ? null : (EPackage)eResolveProxy((InternalEObject)noNamespacePackage);
149   }
150
151   /**
152    * <!-- begin-user-doc -->
153    * <!-- end-user-doc -->
154    * @generated NOT
155    */

156   public EPackage basicGetNoNamespacePackage()
157   {
158     return delegateXMLMap.getNoNamespacePackage();
159   }
160   
161   /**
162    * <!-- begin-user-doc -->
163    * <!-- end-user-doc -->
164    * @generated NOT
165    */

166   public void setNoNamespacePackage(EPackage newNoNamespacePackage)
167   {
168     EPackage oldNoNamespacePackage = delegateXMLMap.getNoNamespacePackage();
169     delegateXMLMap.setNoNamespacePackage(newNoNamespacePackage);
170     if (eNotificationRequired())
171       eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE, oldNoNamespacePackage, newNoNamespacePackage));
172   }
173   
174   /**
175    * <!-- begin-user-doc -->
176    * <!-- end-user-doc -->
177    * @generated
178    */

179   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
180   {
181     if (featureID >= 0)
182     {
183       switch (eDerivedStructuralFeatureID(featureID, baseClass))
184       {
185         case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO:
186           return ((InternalEList)getEcoreToXMLInfo()).basicRemove(otherEnd, msgs);
187         default:
188           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
189       }
190     }
191     return eBasicSetContainer(null, featureID, msgs);
192   }
193
194   /**
195    * <!-- begin-user-doc -->
196    * <!-- end-user-doc -->
197    * @generated
198    */

199   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
200   {
201     switch (eDerivedStructuralFeatureID(eFeature))
202     {
203       case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME:
204         return getIDAttributeName();
205       case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO:
206         return getEcoreToXMLInfo();
207       case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE:
208         if (resolve) return getNoNamespacePackage();
209         return basicGetNoNamespacePackage();
210     }
211     return eDynamicGet(eFeature, resolve);
212   }
213
214   /**
215    * <!-- begin-user-doc -->
216    * <!-- end-user-doc -->
217    * @generated
218    */

219   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
220   {
221     switch (eDerivedStructuralFeatureID(eFeature))
222     {
223       case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME:
224         setIDAttributeName((String JavaDoc)newValue);
225         return;
226       case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO:
227         getEcoreToXMLInfo().clear();
228         getEcoreToXMLInfo().addAll((Collection JavaDoc)newValue);
229         return;
230       case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE:
231         setNoNamespacePackage((EPackage)newValue);
232         return;
233     }
234     eDynamicSet(eFeature, newValue);
235   }
236
237   /**
238    * <!-- begin-user-doc -->
239    * <!-- end-user-doc -->
240    * @generated
241    */

242   public void eUnset(EStructuralFeature eFeature)
243   {
244     switch (eDerivedStructuralFeatureID(eFeature))
245     {
246       case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME:
247         setIDAttributeName(IDATTRIBUTE_NAME_EDEFAULT);
248         return;
249       case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO:
250         getEcoreToXMLInfo().clear();
251         return;
252       case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE:
253         setNoNamespacePackage((EPackage)null);
254         return;
255     }
256     eDynamicUnset(eFeature);
257   }
258
259   /**
260    * <!-- begin-user-doc -->
261    * <!-- end-user-doc -->
262    * @generated
263    */

264   public boolean eIsSet(EStructuralFeature eFeature)
265   {
266     switch (eDerivedStructuralFeatureID(eFeature))
267     {
268       case Ecore2XMLPackage.XML_MAP__IDATTRIBUTE_NAME:
269         return IDATTRIBUTE_NAME_EDEFAULT == null ? getIDAttributeName() != null : !IDATTRIBUTE_NAME_EDEFAULT.equals(getIDAttributeName());
270       case Ecore2XMLPackage.XML_MAP__ECORE_TO_XML_INFO:
271         return ecoreToXMLInfo != null && !ecoreToXMLInfo.isEmpty();
272       case Ecore2XMLPackage.XML_MAP__NO_NAMESPACE_PACKAGE:
273         return basicGetNoNamespacePackage() != null;
274     }
275     return eDynamicIsSet(eFeature);
276   }
277
278   protected class DelegateXMLMapImpl extends org.eclipse.emf.ecore.xmi.impl.XMLMapImpl
279   {
280     protected DelegateXMLMapImpl()
281     {
282       super();
283       this.ecoreToXMLInfo = XMLMapImpl.this.getEcoreToXMLInfo().map();
284     }
285   }
286   
287   protected XMLResource.XMLMap delegateXMLMap = new DelegateXMLMapImpl();
288   
289   /* (non-Javadoc)
290    * @see org.eclipse.emf.ecore.xmi.XMLResource.XMLMap#add(org.eclipse.emf.ecore.ENamedElement, org.eclipse.emf.ecore.xmi.XMLResource.XMLInfo)
291    */

292   public void add(ENamedElement element, XMLResource.XMLInfo info)
293   {
294     delegateXMLMap.add(element, XMLInfo.class.isInstance(info) ? info : new XMLInfoImpl(info));
295   }
296   
297   /* (non-Javadoc)
298    * @see org.eclipse.emf.ecore.xmi.XMLResource.XMLMap#getClassifier(java.lang.String, java.lang.String)
299    */

300   public EClassifier getClassifier(String JavaDoc namespaceURI, String JavaDoc name)
301   {
302     return delegateXMLMap.getClassifier(namespaceURI, name);
303   }
304   
305   /* (non-Javadoc)
306    * @see org.eclipse.emf.ecore.xmi.XMLResource.XMLMap#getFeature(org.eclipse.emf.ecore.EClass, java.lang.String, java.lang.String)
307    */

308   public EStructuralFeature getFeature(EClass eClass, String JavaDoc namespaceURI, String JavaDoc name)
309   {
310     return delegateXMLMap.getFeature(eClass, namespaceURI, name);
311   }
312   
313   /* (non-Javadoc)
314    * @see org.eclipse.emf.ecore.xmi.XMLResource.XMLMap#getFeatures(org.eclipse.emf.ecore.EClass)
315    */

316   public List JavaDoc getFeatures(EClass eClass)
317   {
318     return delegateXMLMap.getFeatures(eClass);
319   }
320   
321   /* (non-Javadoc)
322    * @see org.eclipse.emf.ecore.xmi.XMLResource.XMLMap#getInfo(org.eclipse.emf.ecore.ENamedElement)
323    */

324   public XMLResource.XMLInfo getInfo(ENamedElement element)
325   {
326     return delegateXMLMap.getInfo(element);
327   }
328   
329 } //XMLMapImpl
330
Popular Tags