1 17 package org.eclipse.emf.ecore.impl; 18 19 import java.util.Collection ; 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 55 public class EAnnotationImpl extends EModelElementImpl implements EAnnotation 56 { 57 65 protected static final String SOURCE_EDEFAULT = null; 66 67 75 protected String source = SOURCE_EDEFAULT; 76 77 85 protected EMap details = null; 86 87 95 protected EList contents = null; 96 97 105 protected EList references = null; 106 107 112 protected EAnnotationImpl() 113 { 114 super(); 115 } 116 117 122 protected EClass eStaticClass() 123 { 124 return EcorePackage.eINSTANCE.getEAnnotation(); 125 } 126 127 132 public String getSource() 133 { 134 return source; 135 } 136 137 142 public void setSource(String newSource) 143 { 144 String oldSource = source; 145 source = newSource; 146 if (eNotificationRequired()) 147 eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.EANNOTATION__SOURCE, oldSource, source)); 148 } 149 150 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 169 public EModelElement getEModelElement() 170 { 171 if (eContainerFeatureID != EcorePackage.EANNOTATION__EMODEL_ELEMENT) return null; 172 return (EModelElement)eContainer; 173 } 174 175 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 ("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 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 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 231 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class 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 257 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class 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 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 303 public Object 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 328 public void eSet(EStructuralFeature eFeature, Object newValue) 329 { 330 switch (eDerivedStructuralFeatureID(eFeature)) 331 { 332 case EcorePackage.EANNOTATION__EANNOTATIONS: 333 getEAnnotations().clear(); 334 getEAnnotations().addAll((Collection )newValue); 335 return; 336 case EcorePackage.EANNOTATION__SOURCE: 337 setSource((String )newValue); 338 return; 339 case EcorePackage.EANNOTATION__DETAILS: 340 getDetails().clear(); 341 getDetails().addAll((Collection )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 )newValue); 349 return; 350 case EcorePackage.EANNOTATION__REFERENCES: 351 getReferences().clear(); 352 getReferences().addAll((Collection )newValue); 353 return; 354 } 355 eDynamicSet(eFeature, newValue); 356 } 357 358 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 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 419 public String toString() 420 { 421 if (eIsProxy()) return super.toString(); 422 423 StringBuffer result = new StringBuffer (super.toString()); 424 result.append(" (source: "); 425 result.append(source); 426 result.append(')'); 427 return result.toString(); 428 } 429 430 } 432 | Popular Tags |