1 17 package org.eclipse.emf.ecore.impl; 18 19 20 import java.util.Collection ; 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 45 public abstract class ENamedElementImpl extends EModelElementImpl implements ENamedElement 46 { 47 55 protected static final String NAME_EDEFAULT = null; 56 57 65 protected String name = NAME_EDEFAULT; 66 67 72 protected ENamedElementImpl() 73 { 74 super(); 75 } 76 77 82 protected EClass eStaticClass() 83 { 84 return EcorePackage.eINSTANCE.getENamedElement(); 85 } 86 87 90 public String getName() 91 { 92 return getNameGen(); 93 102 } 103 104 109 public String toString() 110 { 111 if (eIsProxy()) return super.toString(); 112 113 StringBuffer result = new StringBuffer (super.toString()); 114 result.append(" (name: "); 115 result.append(name); 116 result.append(')'); 117 return result.toString(); 118 } 119 120 125 public String getNameGen() 126 { 127 return name; 128 } 129 130 135 public void setName(String newName) 136 { 137 String oldName = name; 138 name = newName; 139 if (eNotificationRequired()) 140 eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ENAMED_ELEMENT__NAME, oldName, name)); 141 } 142 143 148 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class 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 170 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class 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 190 public Object 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 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 224 public void eSet(EStructuralFeature eFeature, Object newValue) 225 { 226 switch (eDerivedStructuralFeatureID(eFeature)) 227 { 228 case EcorePackage.ENAMED_ELEMENT__EANNOTATIONS: 229 getEAnnotations().clear(); 230 getEAnnotations().addAll((Collection )newValue); 231 return; 232 case EcorePackage.ENAMED_ELEMENT__NAME: 233 setName((String )newValue); 234 return; 235 } 236 eDynamicSet(eFeature, newValue); 237 } 238 239 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 |