KickJava   Java API By Example, From Geeks To Geeks.

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


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

17 package org.eclipse.emf.ecore.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.ecore.EClass;
25 import org.eclipse.emf.ecore.ENamedElement;
26 import org.eclipse.emf.ecore.EStructuralFeature;
27 import org.eclipse.emf.ecore.EcorePackage;
28 import org.eclipse.emf.ecore.InternalEObject;
29 import org.eclipse.emf.ecore.util.InternalEList;
30
31
32 /**
33  * <!-- begin-user-doc -->
34  * An implementation of the model object '<em><b>ENamed Element</b></em>'.
35  * <!-- end-user-doc -->
36  * <p>
37  * The following features are implemented:
38  * <ul>
39  * <li>{@link org.eclipse.emf.ecore.impl.ENamedElementImpl#getName <em>Name</em>}</li>
40  * </ul>
41  * </p>
42  *
43  * @generated
44  */

45 public abstract class ENamedElementImpl extends EModelElementImpl implements ENamedElement
46 {
47   /**
48    * The default value of the '{@link #getName() <em>Name</em>}' attribute.
49    * <!-- begin-user-doc -->
50    * <!-- end-user-doc -->
51    * @see #getName()
52    * @generated
53    * @ordered
54    */

55   protected static final String JavaDoc NAME_EDEFAULT = null;
56
57   /**
58    * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
59    * <!-- begin-user-doc -->
60    * <!-- end-user-doc -->
61    * @see #getName()
62    * @generated
63    * @ordered
64    */

65   protected String JavaDoc name = NAME_EDEFAULT;
66
67   /**
68    * <!-- begin-user-doc -->
69    * <!-- end-user-doc -->
70    * @generated
71    */

72   protected ENamedElementImpl()
73   {
74     super();
75   }
76
77   /**
78    * <!-- begin-user-doc -->
79    * <!-- end-user-doc -->
80    * @generated
81    */

82   protected EClass eStaticClass()
83   {
84     return EcorePackage.eINSTANCE.getENamedElement();
85   }
86
87   /**
88    * Default is ID if name is null
89    */

90   public String JavaDoc getName()
91   {
92     return getNameGen();
93 /*
94     // if no default has been specified, use the id as the default.
95     String defaultName = this.getNameGen();
96
97     if (defaultName != null)
98       return defaultName;
99     else
100       return eID();
101 */

102   }
103
104   /**
105    * <!-- begin-user-doc -->
106    * <!-- end-user-doc -->
107    * @generated
108    */

109   public String JavaDoc toString()
110   {
111     if (eIsProxy()) return super.toString();
112
113     StringBuffer JavaDoc result = new StringBuffer JavaDoc(super.toString());
114     result.append(" (name: ");
115     result.append(name);
116     result.append(')');
117     return result.toString();
118   }
119
120   /**
121    * <!-- begin-user-doc -->
122    * <!-- end-user-doc -->
123    * @generated
124    */

125   public String JavaDoc getNameGen()
126   {
127     return name;
128   }
129
130   /**
131    * <!-- begin-user-doc -->
132    * <!-- end-user-doc -->
133    * @generated
134    */

135   public void setName(String JavaDoc newName)
136   {
137     String JavaDoc oldName = name;
138     name = newName;
139     if (eNotificationRequired())
140       eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ENAMED_ELEMENT__NAME, oldName, name));
141   }
142
143   /**
144    * <!-- begin-user-doc -->
145    * <!-- end-user-doc -->
146    * @generated
147    */

148   public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
149   {
150     if (featureID >= 0)
151     {
152       switch (eDerivedStructuralFeatureID(featureID, baseClass))
153       {
154         case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS:
155           return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
156         default:
157           return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
158       }
159     }
160     if (eContainer != null)
161       msgs = eBasicRemoveFromContainer(msgs);
162     return eBasicSetContainer(otherEnd, featureID, msgs);
163   }
164
165   /**
166    * <!-- begin-user-doc -->
167    * <!-- end-user-doc -->
168    * @generated
169    */

170   public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class JavaDoc baseClass, NotificationChain msgs)
171   {
172     if (featureID >= 0)
173     {
174       switch (eDerivedStructuralFeatureID(featureID, baseClass))
175       {
176         case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS:
177           return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
178         default:
179           return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
180       }
181     }
182     return eBasicSetContainer(null, featureID, msgs);
183   }
184
185   /**
186    * <!-- begin-user-doc -->
187    * <!-- end-user-doc -->
188    * @generated
189    */

190   public Object JavaDoc eGet(EStructuralFeature eFeature, boolean resolve)
191   {
192     switch (eDerivedStructuralFeatureID(eFeature))
193     {
194       case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS:
195         return getEAnnotations();
196       case EcorePackage.ENAMED_ELEMENT__NAME:
197         return getName();
198     }
199     return eDynamicGet(eFeature, resolve);
200   }
201
202   /**
203    * <!-- begin-user-doc -->
204    * <!-- end-user-doc -->
205    * @generated
206    */

207   public boolean eIsSet(EStructuralFeature eFeature)
208   {
209     switch (eDerivedStructuralFeatureID(eFeature))
210     {
211       case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS:
212         return eAnnotations != null && !eAnnotations.isEmpty();
213       case EcorePackage.ENAMED_ELEMENT__NAME:
214         return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
215     }
216     return eDynamicIsSet(eFeature);
217   }
218
219   /**
220    * <!-- begin-user-doc -->
221    * <!-- end-user-doc -->
222    * @generated
223    */

224   public void eSet(EStructuralFeature eFeature, Object JavaDoc newValue)
225   {
226     switch (eDerivedStructuralFeatureID(eFeature))
227     {
228       case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS:
229         getEAnnotations().clear();
230         getEAnnotations().addAll((Collection JavaDoc)newValue);
231         return;
232       case EcorePackage.ENAMED_ELEMENT__NAME:
233         setName((String JavaDoc)newValue);
234         return;
235     }
236     eDynamicSet(eFeature, newValue);
237   }
238
239   /**
240    * <!-- begin-user-doc -->
241    * <!-- end-user-doc -->
242    * @generated
243    */

244   public void eUnset(EStructuralFeature eFeature)
245   {
246     switch (eDerivedStructuralFeatureID(eFeature))
247     {
248       case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS:
249         getEAnnotations().clear();
250         return;
251       case EcorePackage.ENAMED_ELEMENT__NAME:
252         setName(NAME_EDEFAULT);
253         return;
254     }
255     eDynamicUnset(eFeature);
256   }
257
258 }
259
Popular Tags