KickJava   Java API By Example, From Geeks To Geeks.

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


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: ENamedElementToXMLInfoMapEntryImpl.java,v 1.2 2005/06/21 16:17:03 khussey Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2xml.impl;
18
19 import org.eclipse.emf.common.notify.Notification;
20 import org.eclipse.emf.common.notify.NotificationChain;
21
22 import org.eclipse.emf.common.util.BasicEMap;
23 import org.eclipse.emf.common.util.EMap;
24
25 import org.eclipse.emf.ecore.EClass;
26 import org.eclipse.emf.ecore.ENamedElement;
27 import org.eclipse.emf.ecore.EObject;
28 import org.eclipse.emf.ecore.EStructuralFeature;
29 import org.eclipse.emf.ecore.InternalEObject;
30
31 import org.eclipse.emf.ecore.impl.ENotificationImpl;
32 import org.eclipse.emf.ecore.impl.EObjectImpl;
33 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
34 import org.eclipse.emf.mapping.ecore2xml.XMLInfo;
35
36 /**
37  * <!-- begin-user-doc -->
38  * An implementation of the model object '<em><b>ENamed Element To XML Info Map Entry</b></em>'.
39  * <!-- end-user-doc -->
40  * <p>
41  * The following features are implemented:
42  * <ul>
43  * <li>{@link org.eclipse.emf.mapping.ecore2xml.impl.ENamedElementToXMLInfoMapEntryImpl#getTypedKey <em>Key</em>}</li>
44  * <li>{@link org.eclipse.emf.mapping.ecore2xml.impl.ENamedElementToXMLInfoMapEntryImpl#getTypedValue <em>Value</em>}</li>
45  * </ul>
46  * </p>
47  *
48  * @generated
49  */

50 public class ENamedElementToXMLInfoMapEntryImpl extends EObjectImpl implements BasicEMap.Entry
51 {
52   
53   /**
54    * The cached value of the '{@link #getTypedKey() <em>Key</em>}' reference.
55    * <!-- begin-user-doc -->
56    * <!-- end-user-doc -->
57    * @see #getTypedKey()
58    * @generated
59    * @ordered
60    */

61   protected ENamedElement key = null;
62   
63   /**
64    * The cached value of the '{@link #getTypedValue() <em>Value</em>}' containment reference.
65    * <!-- begin-user-doc -->
66    * <!-- end-user-doc -->
67    * @see #getTypedValue()
68    * @generated
69    * @ordered
70    */

71   protected XMLInfo value = null;
72   
73   /**
74    * <!-- begin-user-doc -->
75    * <!-- end-user-doc -->
76    * @generated
77    */

78   protected ENamedElementToXMLInfoMapEntryImpl()
79   {
80     super();
81   }
82
83   /**
84    * <!-- begin-user-doc -->
85    * <!-- end-user-doc -->
86    * @generated
87    */

88   protected EClass eStaticClass()
89   {
90     return Ecore2XMLPackage.eINSTANCE.getENamedElementToXMLInfoMapEntry();
91   }
92
93   /**
94    * <!-- begin-user-doc -->
95    * <!-- end-user-doc -->
96    * @generated
97    */

98   public ENamedElement getTypedKey()
99   {
100     if (key != null && key.eIsProxy())
101     {
102       ENamedElement oldKey = key;
103       key = (ENamedElement)eResolveProxy((InternalEObject)key);
104       if (key != oldKey)
105       {
106         if (eNotificationRequired())
107           eNotify(new ENotificationImpl(this, Notification.RESOLVE, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY, oldKey, key));
108       }
109     }
110     return key;
111   }
112
113   /**
114    * <!-- begin-user-doc -->
115    * <!-- end-user-doc -->
116    * @generated
117    */

118   public ENamedElement basicGetTypedKey()
119   {
120     return key;
121   }
122
123   /**
124    * <!-- begin-user-doc -->
125    * <!-- end-user-doc -->
126    * @generated
127    */

128   public void setTypedKey(ENamedElement newKey)
129   {
130     ENamedElement oldKey = key;
131     key = newKey;
132     if (eNotificationRequired())
133       eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY, oldKey, key));
134   }
135
136   /**
137    * <!-- begin-user-doc -->
138    * <!-- end-user-doc -->
139    * @generated
140    */

141   public XMLInfo getTypedValue()
142   {
143     return value;
144   }
145
146   /**
147    * <!-- begin-user-doc -->
148    * <!-- end-user-doc -->
149    * @generated
150    */

151   public NotificationChain basicSetTypedValue(XMLInfo newValue, NotificationChain msgs)
152   {
153     XMLInfo oldValue = value;
154     value = newValue;
155     if (eNotificationRequired())
156     {
157       ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, oldValue, newValue);
158       if (msgs == null) msgs = notification; else msgs.add(notification);
159     }
160     return msgs;
161   }
162
163   /**
164    * <!-- begin-user-doc -->
165    * <!-- end-user-doc -->
166    * @generated
167    */

168   public void setTypedValue(XMLInfo newValue)
169   {
170     if (newValue != value)
171     {
172       NotificationChain msgs = null;
173       if (value != null)
174         msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, null, msgs);
175       if (newValue != null)
176         msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, null, msgs);
177       msgs = basicSetTypedValue(newValue, msgs);
178       if (msgs != null) msgs.dispatch();
179     }
180     else if (eNotificationRequired())
181       eNotify(new ENotificationImpl(this, Notification.SET, Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE, newValue, newValue));
182   }
183
184   /**
185    * <!-- begin-user-doc -->
186    * <!-- end-user-doc -->
187    * @generated
188    */

189   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
190   {
191     if (featureID >= 0)
192     {
193       switch (eDerivedStructuralFeatureID(featureID, baseClass))
194       {
195         case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE:
196           return basicSetTypedValue(null, msgs);
197         default:
198           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
199       }
200     }
201     return eBasicSetContainer(null, featureID, msgs);
202   }
203
204   /**
205    * <!-- begin-user-doc -->
206    * <!-- end-user-doc -->
207    * @generated
208    */

209   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
210   {
211     switch (eDerivedStructuralFeatureID(eFeature))
212     {
213       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY:
214         if (resolve) return getTypedKey();
215         return basicGetTypedKey();
216       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE:
217         return getTypedValue();
218     }
219     return eDynamicGet(eFeature, resolve);
220   }
221
222   /**
223    * <!-- begin-user-doc -->
224    * <!-- end-user-doc -->
225    * @generated
226    */

227   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
228   {
229     switch (eDerivedStructuralFeatureID(eFeature))
230     {
231       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY:
232         setTypedKey((ENamedElement)newValue);
233         return;
234       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE:
235         setTypedValue((XMLInfo)newValue);
236         return;
237     }
238     eDynamicSet(eFeature, newValue);
239   }
240
241   /**
242    * <!-- begin-user-doc -->
243    * <!-- end-user-doc -->
244    * @generated
245    */

246   public void eUnset(EStructuralFeature eFeature)
247   {
248     switch (eDerivedStructuralFeatureID(eFeature))
249     {
250       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY:
251         setTypedKey((ENamedElement)null);
252         return;
253       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE:
254         setTypedValue((XMLInfo)null);
255         return;
256     }
257     eDynamicUnset(eFeature);
258   }
259
260   /**
261    * <!-- begin-user-doc -->
262    * <!-- end-user-doc -->
263    * @generated
264    */

265   public boolean eIsSet(EStructuralFeature eFeature)
266   {
267     switch (eDerivedStructuralFeatureID(eFeature))
268     {
269       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__KEY:
270         return key != null;
271       case Ecore2XMLPackage.ENAMED_ELEMENT_TO_XML_INFO_MAP_ENTRY__VALUE:
272         return value != null;
273     }
274     return eDynamicIsSet(eFeature);
275   }
276
277   /**
278    * <!-- begin-user-doc -->
279    * <!-- end-user-doc -->
280    * @generated
281    */

282   protected int hash = -1;
283   
284   /**
285    * <!-- begin-user-doc -->
286    * <!-- end-user-doc -->
287    * @generated
288    */

289   public int getHash()
290   {
291     if (hash == -1)
292     {
293       Object JavaDoc theKey = getKey();
294       hash = (theKey == null ? 0 : theKey.hashCode());
295     }
296     return hash;
297   }
298
299   /**
300    * <!-- begin-user-doc -->
301    * <!-- end-user-doc -->
302    * @generated
303    */

304   public void setHash(int hash)
305   {
306     this.hash = hash;
307   }
308
309   /**
310    * <!-- begin-user-doc -->
311    * <!-- end-user-doc -->
312    * @generated
313    */

314   public Object JavaDoc getKey()
315   {
316     return getTypedKey();
317   }
318
319   /**
320    * <!-- begin-user-doc -->
321    * <!-- end-user-doc -->
322    * @generated
323    */

324   public void setKey(Object JavaDoc key)
325   {
326     setTypedKey((ENamedElement)key);
327   }
328
329   /**
330    * <!-- begin-user-doc -->
331    * <!-- end-user-doc -->
332    * @generated
333    */

334   public Object JavaDoc getValue()
335   {
336     return getTypedValue();
337   }
338
339   /**
340    * <!-- begin-user-doc -->
341    * <!-- end-user-doc -->
342    * @generated
343    */

344   public Object JavaDoc setValue(Object JavaDoc value)
345   {
346     Object JavaDoc oldValue = getValue();
347     setTypedValue((XMLInfo)value);
348     return oldValue;
349   }
350
351   /**
352    * <!-- begin-user-doc -->
353    * <!-- end-user-doc -->
354    * @generated
355    */

356   public EMap getEMap()
357   {
358     EObject container = eContainer();
359     return container == null ? null : (EMap)container.eGet(eContainmentFeature());
360   }
361
362 } //ENamedElementToXMLInfoMapEntryImpl
363
Popular Tags