KickJava   Java API By Example, From Geeks To Geeks.

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


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

17 package org.eclipse.emf.ecore.impl;
18
19 import java.util.Collection JavaDoc;
20
21 import org.eclipse.emf.common.notify.Notification;
22 import org.eclipse.emf.common.notify.NotificationChain;
23 import org.eclipse.emf.common.util.EList;
24 import org.eclipse.emf.common.util.EMap;
25 import org.eclipse.emf.ecore.EAnnotation;
26 import org.eclipse.emf.ecore.EClass;
27 import org.eclipse.emf.ecore.EModelElement;
28 import org.eclipse.emf.ecore.EObject;
29 import org.eclipse.emf.ecore.EStructuralFeature;
30 import org.eclipse.emf.ecore.EcorePackage;
31 import org.eclipse.emf.ecore.InternalEObject;
32 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
33 import org.eclipse.emf.ecore.util.EObjectResolvingEList;
34 import org.eclipse.emf.ecore.util.EcoreEMap;
35 import org.eclipse.emf.ecore.util.EcoreUtil;
36 import org.eclipse.emf.ecore.util.InternalEList;
37
38 /**
39  * <!-- begin-user-doc -->
40  * An implementation of the model object '<em><b>EAnnotation</b></em>'.
41  * <!-- end-user-doc -->
42  * <p>
43  * The following features are implemented:
44  * <ul>
45  * <li>{@link org.eclipse.emf.ecore.impl.EAnnotationImpl#getSource <em>Source</em>}</li>
46  * <li>{@link org.eclipse.emf.ecore.impl.EAnnotationImpl#getDetails <em>Details</em>}</li>
47  * <li>{@link org.eclipse.emf.ecore.impl.EAnnotationImpl#getEModelElement <em>EModel Element</em>}</li>
48  * <li>{@link org.eclipse.emf.ecore.impl.EAnnotationImpl#getContents <em>Contents</em>}</li>
49  * <li>{@link org.eclipse.emf.ecore.impl.EAnnotationImpl#getReferences <em>References</em>}</li>
50  * </ul>
51  * </p>
52  *
53  * @generated
54  */

55 public class EAnnotationImpl extends EModelElementImpl implements EAnnotation
56 {
57   /**
58    * The default value of the '{@link #getSource() <em>Source</em>}' attribute.
59    * <!-- begin-user-doc -->
60    * <!-- end-user-doc -->
61    * @see #getSource()
62    * @generated
63    * @ordered
64    */

65   protected static final String JavaDoc SOURCE_EDEFAULT = null;
66
67   /**
68    * The cached value of the '{@link #getSource() <em>Source</em>}' attribute.
69    * <!-- begin-user-doc -->
70    * <!-- end-user-doc -->
71    * @see #getSource()
72    * @generated
73    * @ordered
74    */

75   protected String JavaDoc source = SOURCE_EDEFAULT;
76
77   /**
78    * The cached value of the '{@link #getDetails() <em>Details</em>}' map.
79    * <!-- begin-user-doc -->
80    * <!-- end-user-doc -->
81    * @see #getDetails()
82    * @generated
83    * @ordered
84    */

85   protected EMap details = null;
86
87   /**
88    * The cached value of the '{@link #getContents() <em>Contents</em>}' containment reference list.
89    * <!-- begin-user-doc -->
90    * <!-- end-user-doc -->
91    * @see #getContents()
92    * @generated
93    * @ordered
94    */

95   protected EList contents = null;
96
97   /**
98    * The cached value of the '{@link #getReferences() <em>References</em>}' reference list.
99    * <!-- begin-user-doc -->
100    * <!-- end-user-doc -->
101    * @see #getReferences()
102    * @generated
103    * @ordered
104    */

105   protected EList references = null;
106
107   /**
108    * <!-- begin-user-doc -->
109    * <!-- end-user-doc -->
110    * @generated
111    */

112   protected EAnnotationImpl()
113   {
114     super();
115   }
116
117   /**
118    * <!-- begin-user-doc -->
119    * <!-- end-user-doc -->
120    * @generated
121    */

122   protected EClass eStaticClass()
123   {
124     return EcorePackage.eINSTANCE.getEAnnotation();
125   }
126
127   /**
128    * <!-- begin-user-doc -->
129    * <!-- end-user-doc -->
130    * @generated
131    */

132   public String JavaDoc getSource()
133   {
134     return source;
135   }
136
137   /**
138    * <!-- begin-user-doc -->
139    * <!-- end-user-doc -->
140    * @generated
141    */

142   public void setSource(String JavaDoc newSource)
143   {
144     String JavaDoc oldSource = source;
145     source = newSource;
146     if (eNotificationRequired())
147       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.EANNOTATION__SOURCE, oldSource, source));
148   }
149
150   /**
151    * <!-- begin-user-doc -->
152    * <!-- end-user-doc -->
153    * @generated
154    */

155   public EMap getDetails()
156   {
157     if (details == null)
158     {
159       details = new EcoreEMap(EcorePackage.eINSTANCE.getEStringToStringMapEntry(), EStringToStringMapEntryImpl.class, this, EcorePackage.EANNOTATION__DETAILS);
160     }
161     return details;
162   }
163
164   /**
165    * <!-- begin-user-doc -->
166    * <!-- end-user-doc -->
167    * @generated
168    */

169   public EModelElement getEModelElement()
170   {
171     if (eContainerFeatureID != EcorePackage.EANNOTATION__EMODEL_ELEMENT) return null;
172     return (EModelElement)eContainer;
173   }
174
175   /**
176    * <!-- begin-user-doc -->
177    * <!-- end-user-doc -->
178    * @generated
179    */

180   public void setEModelElement(EModelElement newEModelElement)
181   {
182     if (newEModelElement != eContainer || (eContainerFeatureID != EcorePackage.EANNOTATION__EMODEL_ELEMENT && newEModelElement != null))
183     {
184       if (EcoreUtil.isAncestor(this, newEModelElement))
185         throw new IllegalArgumentException JavaDoc("Recursive containment not allowed for " + toString());
186       NotificationChain msgs = null;
187       if (eContainer != null)
188         msgs = eBasicRemoveFromContainer(msgs);
189       if (newEModelElement != null)
190         msgs = ((InternalEObject)newEModelElement).eInverseAdd(this, EcorePackage.EMODEL_ELEMENT__EANNOTATIONS, EModelElement.class, msgs);
191       msgs = eBasicSetContainer((InternalEObject)newEModelElement, EcorePackage.EANNOTATION__EMODEL_ELEMENT, msgs);
192       if (msgs != null) msgs.dispatch();
193     }
194     else if (eNotificationRequired())
195       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.EANNOTATION__EMODEL_ELEMENT, newEModelElement, newEModelElement));
196   }
197
198   /**
199    * <!-- begin-user-doc -->
200    * <!-- end-user-doc -->
201    * @generated
202    */

203   public EList getContents()
204   {
205     if (contents == null)
206     {
207       contents = new EObjectContainmentEList(EObject.class, this, EcorePackage.EANNOTATION__CONTENTS);
208     }
209     return contents;
210   }
211
212   /**
213    * <!-- begin-user-doc -->
214    * <!-- end-user-doc -->
215    * @generated
216    */

217   public EList getReferences()
218   {
219     if (references == null)
220     {
221       references = new EObjectResolvingEList(EObject.class, this, EcorePackage.EANNOTATION__REFERENCES);
222     }
223     return references;
224   }
225
226   /**
227    * <!-- begin-user-doc -->
228    * <!-- end-user-doc -->
229    * @generated
230    */

231   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
232   {
233     if (featureID >= 0)
234     {
235       switch (eDerivedStructuralFeatureID(featureID, baseClass))
236       {
237         case EcorePackage.EANNOTATION__EANNOTATIONS:
238           return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
239         case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
240           if (eContainer != null)
241             msgs = eBasicRemoveFromContainer(msgs);
242           return eBasicSetContainer(otherEnd, EcorePackage.EANNOTATION__EMODEL_ELEMENT, 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 EcorePackage.EANNOTATION__EANNOTATIONS:
264           return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
265         case EcorePackage.EANNOTATION__DETAILS:
266           return ((InternalEList)getDetails()).basicRemove(otherEnd, msgs);
267         case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
268           return eBasicSetContainer(null, EcorePackage.EANNOTATION__EMODEL_ELEMENT, msgs);
269         case EcorePackage.EANNOTATION__CONTENTS:
270           return ((InternalEList)getContents()).basicRemove(otherEnd, msgs);
271         default:
272           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
273       }
274     }
275     return eBasicSetContainer(null, featureID, msgs);
276   }
277
278   /**
279    * <!-- begin-user-doc -->
280    * <!-- end-user-doc -->
281    * @generated
282    */

283   public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs)
284   {
285     if (eContainerFeatureID >= 0)
286     {
287       switch (eContainerFeatureID)
288       {
289         case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
290           return eContainer.eInverseRemove(this, EcorePackage.EMODEL_ELEMENT__EANNOTATIONS, EModelElement.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 EcorePackage.EANNOTATION__EANNOTATIONS:
308         return getEAnnotations();
309       case EcorePackage.EANNOTATION__SOURCE:
310         return getSource();
311       case EcorePackage.EANNOTATION__DETAILS:
312         return getDetails();
313       case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
314         return getEModelElement();
315       case EcorePackage.EANNOTATION__CONTENTS:
316         return getContents();
317       case EcorePackage.EANNOTATION__REFERENCES:
318         return getReferences();
319     }
320     return eDynamicGet(eFeature, resolve);
321   }
322
323   /**
324    * <!-- begin-user-doc -->
325    * <!-- end-user-doc -->
326    * @generated
327    */

328   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
329   {
330     switch (eDerivedStructuralFeatureID(eFeature))
331     {
332       case EcorePackage.EANNOTATION__EANNOTATIONS:
333         getEAnnotations().clear();
334         getEAnnotations().addAll((Collection JavaDoc)newValue);
335         return;
336       case EcorePackage.EANNOTATION__SOURCE:
337         setSource((String JavaDoc)newValue);
338         return;
339       case EcorePackage.EANNOTATION__DETAILS:
340         getDetails().clear();
341         getDetails().addAll((Collection JavaDoc)newValue);
342         return;
343       case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
344         setEModelElement((EModelElement)newValue);
345         return;
346       case EcorePackage.EANNOTATION__CONTENTS:
347         getContents().clear();
348         getContents().addAll((Collection JavaDoc)newValue);
349         return;
350       case EcorePackage.EANNOTATION__REFERENCES:
351         getReferences().clear();
352         getReferences().addAll((Collection JavaDoc)newValue);
353         return;
354     }
355     eDynamicSet(eFeature, newValue);
356   }
357
358   /**
359    * <!-- begin-user-doc -->
360    * <!-- end-user-doc -->
361    * @generated
362    */

363   public void eUnset(EStructuralFeature eFeature)
364   {
365     switch (eDerivedStructuralFeatureID(eFeature))
366     {
367       case EcorePackage.EANNOTATION__EANNOTATIONS:
368         getEAnnotations().clear();
369         return;
370       case EcorePackage.EANNOTATION__SOURCE:
371         setSource(SOURCE_EDEFAULT);
372         return;
373       case EcorePackage.EANNOTATION__DETAILS:
374         getDetails().clear();
375         return;
376       case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
377         setEModelElement((EModelElement)null);
378         return;
379       case EcorePackage.EANNOTATION__CONTENTS:
380         getContents().clear();
381         return;
382       case EcorePackage.EANNOTATION__REFERENCES:
383         getReferences().clear();
384         return;
385     }
386     eDynamicUnset(eFeature);
387   }
388
389   /**
390    * <!-- begin-user-doc -->
391    * <!-- end-user-doc -->
392    * @generated
393    */

394   public boolean eIsSet(EStructuralFeature eFeature)
395   {
396     switch (eDerivedStructuralFeatureID(eFeature))
397     {
398       case EcorePackage.EANNOTATION__EANNOTATIONS:
399         return eAnnotations != null && !eAnnotations.isEmpty();
400       case EcorePackage.EANNOTATION__SOURCE:
401         return SOURCE_EDEFAULT == null ? source != null : !SOURCE_EDEFAULT.equals(source);
402       case EcorePackage.EANNOTATION__DETAILS:
403         return details != null && !details.isEmpty();
404       case EcorePackage.EANNOTATION__EMODEL_ELEMENT:
405         return getEModelElement() != null;
406       case EcorePackage.EANNOTATION__CONTENTS:
407         return contents != null && !contents.isEmpty();
408       case EcorePackage.EANNOTATION__REFERENCES:
409         return references != null && !references.isEmpty();
410     }
411     return eDynamicIsSet(eFeature);
412   }
413
414   /**
415    * <!-- begin-user-doc -->
416    * <!-- end-user-doc -->
417    * @generated
418    */

419   public String JavaDoc toString()
420   {
421     if (eIsProxy()) return super.toString();
422
423     StringBuffer JavaDoc result = new StringBuffer JavaDoc(super.toString());
424     result.append(" (source: ");
425     result.append(source);
426     result.append(')');
427     return result.toString();
428   }
429
430 } //EAnnotationImpl
431

432
Popular Tags