1 17 18 package org.eclipse.emf.ecore.impl; 19 20 21 import java.util.Collection ; 22 import java.util.HashMap ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 26 import org.eclipse.emf.common.notify.Notification; 27 import org.eclipse.emf.common.notify.NotificationChain; 28 import org.eclipse.emf.common.util.BasicEList; 29 import org.eclipse.emf.common.util.EList; 30 import org.eclipse.emf.common.util.UniqueEList; 31 import org.eclipse.emf.ecore.EAttribute; 32 import org.eclipse.emf.ecore.EClass; 33 import org.eclipse.emf.ecore.EClassifier; 34 import org.eclipse.emf.ecore.EObject; 35 import org.eclipse.emf.ecore.EOperation; 36 import org.eclipse.emf.ecore.EPackage; 37 import org.eclipse.emf.ecore.EReference; 38 import org.eclipse.emf.ecore.EStructuralFeature; 39 import org.eclipse.emf.ecore.EcorePackage; 40 import org.eclipse.emf.ecore.InternalEObject; 41 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; 42 import org.eclipse.emf.ecore.util.EObjectResolvingEList; 43 import org.eclipse.emf.ecore.util.EcoreEList; 44 import org.eclipse.emf.ecore.util.EcoreUtil; 45 import org.eclipse.emf.ecore.util.ExtendedMetaData; 46 import org.eclipse.emf.ecore.util.FeatureMapUtil; 47 import org.eclipse.emf.ecore.util.InternalEList; 48 49 50 78 public class EClassImpl extends EClassifierImpl implements EClass, ESuperAdapter.Holder 79 { 80 public interface FeatureSubsetSupplier 81 { 82 EStructuralFeature [] containments(); 83 EStructuralFeature [] crossReferences(); 84 EStructuralFeature [] features(); 85 } 86 87 protected EAttribute eIDAttribute; 88 protected BasicEList eAllAttributes; 89 protected BasicEList eAllReferences; 90 protected BasicEList eAllStructuralFeatures; 91 protected EStructuralFeature[] eAllStructuralFeaturesData; 92 protected BasicEList eAllContainments; 93 protected BasicEList eAllOperations; 94 protected BasicEList eAllSuperTypes; 95 protected Map eNameToFeatureMap; 96 protected ESuperAdapter eSuperAdapter; 97 98 103 protected EClassImpl() 104 { 105 super(); 106 } 107 108 public void freeze() 109 { 110 getEAllAttributes(); 111 getEAllReferences(); 112 getEAllContainments(); 113 getEAllOperations(); 114 getEAllStructuralFeatures(); 115 getEAllSuperTypes(); 116 117 getESuperAdapter().getSubclasses().clear(); 118 119 super.freeze(); 120 } 121 122 public boolean isFrozen() 123 { 124 return super.isFrozen(); 125 } 126 127 132 protected EClass eStaticClass() 133 { 134 return EcorePackage.eINSTANCE.getEClass(); 135 } 136 137 142 public EAttribute getEIDAttribute() 143 { 144 getEAllAttributes(); 145 return eIDAttribute; 146 } 147 148 153 public EList getEStructuralFeatures() 154 { 155 if (eStructuralFeatures == null) 156 { 157 eStructuralFeatures = new EObjectContainmentWithInverseEList(EStructuralFeature.class, this, EcorePackage.ECLASS__ESTRUCTURAL_FEATURES, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS); 158 } 159 return eStructuralFeatures; 160 } 161 162 public EList getEAllAttributes() 163 { 164 if (eAllAttributes == null) 165 { 166 eIDAttribute = null; 167 168 BasicEList result = 169 new UniqueEList() 170 { 171 protected Object [] newData(int capacity) 172 { 173 return new EAttribute [capacity]; 174 } 175 176 protected boolean useEquals() 177 { 178 return false; 179 } 180 181 protected void didAdd(int index, Object object) 182 { 183 EAttribute eAttribute = (EAttribute)object; 184 if (eAttribute.isID() && eIDAttribute == null) 185 { 186 eIDAttribute = eAttribute; 187 } 188 } 189 }; 190 191 BasicEList attributes = 192 new UniqueEList() 193 { 194 protected Object [] newData(int capacity) 195 { 196 return new EAttribute [capacity]; 197 } 198 199 protected boolean useEquals() 200 { 201 return false; 202 } 203 }; 204 205 for (Iterator i = getESuperTypes().iterator(); i.hasNext(); ) 206 { 207 EClass eSuperType = (EClass)i.next(); 208 result.addAll(eSuperType.getEAllAttributes()); 209 } 210 for (Iterator i = getEStructuralFeatures().iterator(); i.hasNext(); ) 211 { 212 EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next(); 213 if (eStructuralFeature instanceof EAttribute) 214 { 215 attributes.add(eStructuralFeature); 216 } 217 } 218 219 attributes.shrink(); 220 eAttributes = 221 new EcoreEList.UnmodifiableEList.FastCompare 222 (this, EcorePackage.eINSTANCE.getEClass_EAttributes(), attributes.size(), attributes.data()) 223 { 224 public void addUnique(Object object) 225 { 226 ((InternalEList)getEStructuralFeatures()).addUnique(object); 227 } 228 229 public boolean add(Object object) 230 { 231 System.err.println("Please fix your code to add using EClass.getEStructuralFeatures() instead of EClass.getEAttributes()"); 232 return ((InternalEList)getEStructuralFeatures()).add(object); 233 } 234 }; 235 236 result.addAll(eAttributes); 237 result.shrink(); 238 eAllAttributes = 239 new EcoreEList.UnmodifiableEList.FastCompare 240 (this, EcorePackage.eINSTANCE.getEClass_EAllAttributes(), result.size(), result.data()); 241 getESuperAdapter().setAllAttributesCollectionModified(false); 242 } 243 244 return eAllAttributes; 245 } 246 247 public EList getEAllReferences() 248 { 249 if (eAllReferences == null) 250 { 251 class ReferenceList extends UniqueEList 252 { 253 public ReferenceList() 254 { 255 } 256 257 protected Object [] newData(int capacity) 258 { 259 return new EReference [capacity]; 260 } 261 262 protected boolean useEquals() 263 { 264 return false; 265 } 266 } 267 BasicEList result = new ReferenceList(); 268 BasicEList references = new ReferenceList(); 269 270 for (Iterator i = getESuperTypes().iterator(); i.hasNext(); ) 271 { 272 EClass eSuperType = (EClass)i.next(); 273 result.addAll(eSuperType.getEAllReferences()); 274 } 275 for (Iterator i = getEStructuralFeatures().iterator(); i.hasNext(); ) 276 { 277 EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next(); 278 if (eStructuralFeature instanceof EReference) 279 { 280 references.add(eStructuralFeature); 281 } 282 } 283 284 references.shrink(); 285 eReferences = 286 new EcoreEList.UnmodifiableEList.FastCompare 287 (this, EcorePackage.eINSTANCE.getEClass_EReferences(), references.size(), references.data()) 288 { 289 public void addUnique(Object object) 290 { 291 ((InternalEList)getEStructuralFeatures()).addUnique(object); 292 } 293 294 public boolean add(Object object) 295 { 296 System.err.println("Please fix your code to add using EClass.getEStructuralFeatures() instead of EClass.getEReferences()"); 297 return ((InternalEList)getEStructuralFeatures()).add(object); 298 } 299 }; 300 301 result.addAll(eReferences); 302 result.shrink(); 303 eAllReferences = 304 new EcoreEList.UnmodifiableEList.FastCompare 305 (this, EcorePackage.eINSTANCE.getEClass_EAllReferences(), result.size(), result.data()); 306 getESuperAdapter().setAllReferencesCollectionModified(false); 307 } 308 309 return eAllReferences; 310 } 311 312 317 public EList getEReferences() 318 { 319 getEAllReferences(); 320 return eReferences; 321 } 322 323 328 public EList getEAttributes() 329 { 330 getEAllAttributes(); 331 return eAttributes; 332 } 333 334 339 public EList getEAllStructuralFeatures() 340 { 341 if (eAllStructuralFeatures == null) 349 { 350 class EStructuralFeatureUniqueEList extends UniqueEList 351 { 352 protected Object [] newData(int capacity) 353 { 354 return new EStructuralFeature [capacity]; 355 } 356 357 protected boolean useEquals() 358 { 359 return false; 360 } 361 } 362 363 BasicEList result = new EStructuralFeatureUniqueEList(); 364 365 for (Iterator i = getESuperTypes().iterator(); i.hasNext(); ) 366 { 367 EClass eSuperType = (EClass)i.next(); 368 result.addAll(eSuperType.getEAllStructuralFeatures()); 369 } 370 int featureID = result.size(); 371 for (Iterator i = getEStructuralFeatures().iterator(); i.hasNext(); ++featureID) 372 { 373 ((EStructuralFeatureImpl)i.next()).setFeatureID(featureID); 374 } 375 result.addAll(getEStructuralFeatures()); 376 377 class EAllStructuralFeaturesList extends EcoreEList.UnmodifiableEList.FastCompare implements FeatureSubsetSupplier 378 { 379 protected EStructuralFeature [] containments; 380 protected EStructuralFeature [] crossReferences; 381 382 public EAllStructuralFeaturesList(BasicEList eAllStructuralFeatures) 383 { 384 super 385 (EClassImpl.this, 386 EcorePackage.eINSTANCE.getEClass_EAllStructuralFeatures(), 387 eAllStructuralFeatures.size(), 388 eAllStructuralFeatures.data()) ; 389 390 BasicEList containmentsList = new EStructuralFeatureUniqueEList(); 391 BasicEList crossReferencesList = new EStructuralFeatureUniqueEList(); 392 boolean isMixed = "mixed".equals(EcoreUtil.getAnnotation(EClassImpl.this, ExtendedMetaData.ANNOTATION_URI, "kind")); 393 for (int i = 0; i < size; ++i) 394 { 395 EStructuralFeature eStructuralFeature = (EStructuralFeature)data[i]; 398 if (eStructuralFeature instanceof EReference) 399 { 400 EReference eReference = (EReference)eStructuralFeature; 401 if (eReference.isContainment()) 402 { 403 if (!eReference.isDerived()) 404 { 405 containmentsList.add(eReference); 406 } 407 } 408 else if (!eReference.isContainer()) 409 { 410 if (!eReference.isDerived() || 413 !isMixed && EcoreUtil.getAnnotation(eReference, ExtendedMetaData.ANNOTATION_URI, "group") == null) 414 { 415 crossReferencesList.add(eReference); 416 } 417 } 418 } 419 else if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) 420 { 421 if (!eStructuralFeature.isDerived()) 422 { 423 containmentsList.add(eStructuralFeature); 424 crossReferencesList.add(eStructuralFeature); 425 } 426 } 427 } 428 containmentsList.shrink(); 429 crossReferencesList.shrink(); 430 containments = (EStructuralFeature [])containmentsList.data(); 431 crossReferences = (EStructuralFeature [])crossReferencesList.data(); 432 } 433 434 public EStructuralFeature [] containments() 435 { 436 return containments; 437 } 438 439 public EStructuralFeature [] crossReferences() 440 { 441 return crossReferences; 442 } 443 444 public EStructuralFeature [] features() 445 { 446 return (EStructuralFeature [])data; 447 } 448 449 public int indexOf(Object object) 450 { 451 if (object instanceof EStructuralFeature) 452 { 453 EStructuralFeature eStructuralFeature = (EStructuralFeature)object; 454 int index = eStructuralFeature.getFeatureID(); 455 if (index != -1) 456 { 457 for (int last = this.size; index < last; ++index) 458 { 459 if (data[index] == object) 460 { 461 return index; 462 } 463 } 464 } 465 } 466 return -1; 467 } 468 } 469 470 result.shrink(); 471 eAllStructuralFeatures = new EAllStructuralFeaturesList(result); 472 eAllStructuralFeaturesData = (EStructuralFeature[])result.data(); 473 if (eAllStructuralFeaturesData == null) 474 { 475 eAllStructuralFeaturesData = NO_EALL_STRUCTURE_FEATURES_DATA; 476 } 477 478 eNameToFeatureMap = null; 479 480 getESuperAdapter().setAllStructuralFeaturesCollectionModified(false); 481 } 482 483 return eAllStructuralFeatures; 484 } 485 486 private static final EStructuralFeature[] NO_EALL_STRUCTURE_FEATURES_DATA = {}; 487 488 493 public EList getEAllOperations() 494 { 495 if (eAllOperations == null) 496 { 497 BasicEList result = 498 new UniqueEList() 499 { 500 protected Object [] newData(int capacity) 501 { 502 return new EOperation [capacity]; 503 } 504 505 protected boolean useEquals() 506 { 507 return false; 508 } 509 }; 510 511 for (Iterator i = getESuperTypes().iterator(); i.hasNext(); ) 512 { 513 result.addAll(((EClass)i.next()).getEAllOperations()); 514 } 515 result.addAll(getEOperations()); 516 result.shrink(); 517 eAllOperations = 518 new EcoreEList.UnmodifiableEList.FastCompare 519 (this, EcorePackage.eINSTANCE.getEClass_EAllOperations(), result.size(), result.data()); 520 getESuperAdapter().setAllOperationsCollectionModified(false); 521 } 522 523 return eAllOperations; 524 } 525 526 531 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 532 { 533 if (featureID >= 0) 534 { 535 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 536 { 537 case EcorePackage.ECLASS__EANNOTATIONS: 538 return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs); 539 case EcorePackage.ECLASS__EPACKAGE: 540 return eBasicSetContainer(null, EcorePackage.ECLASS__EPACKAGE, msgs); 541 case EcorePackage.ECLASS__EOPERATIONS: 542 return ((InternalEList)getEOperations()).basicRemove(otherEnd, msgs); 543 case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES: 544 return ((InternalEList)getEStructuralFeatures()).basicRemove(otherEnd, msgs); 545 default: 546 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 547 } 548 } 549 return eBasicSetContainer(null, featureID, msgs); 550 } 551 552 557 public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) 558 { 559 if (eContainerFeatureID >= 0) 560 { 561 switch (eContainerFeatureID) 562 { 563 case EcorePackage.ECLASS__EPACKAGE: 564 return eContainer.eInverseRemove(this, EcorePackage.EPACKAGE__ECLASSIFIERS, EPackage.class, msgs); 565 default: 566 return eDynamicBasicRemoveFromContainer(msgs); 567 } 568 } 569 return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); 570 } 571 572 public EList getEAllContainments() 573 { 574 if (eAllContainments == null) 575 { 576 BasicEList result = 577 new UniqueEList() 578 { 579 protected Object [] newData(int capacity) 580 { 581 return new EReference [capacity]; 582 } 583 584 protected boolean useEquals() 585 { 586 return false; 587 } 588 }; 589 590 for (Iterator i = getEAllReferences().iterator(); i.hasNext(); ) 591 { 592 EReference eReference = (EReference)i.next(); 593 if (eReference.isContainment()) 594 { 595 result.add(eReference); 596 } 597 } 598 599 result.shrink(); 600 eAllContainments = 601 new EcoreEList.UnmodifiableEList.FastCompare 602 (this, EcorePackage.eINSTANCE.getEClass_EAllContainments(), result.size(), result.data()); 603 getESuperAdapter().setAllContainmentsCollectionModified(false); 604 } 605 606 return eAllContainments; 607 } 608 609 public EStructuralFeature getEStructuralFeature(String name) 610 { 611 getFeatureCount(); 612 if (eNameToFeatureMap == null) 613 { 614 Map result = new HashMap (3 * eAllStructuralFeatures.size() / 2 + 1); 615 for (Iterator i = eAllStructuralFeatures.iterator(); i.hasNext(); ) 616 { 617 EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next(); 618 result.put(eStructuralFeature.getName(), eStructuralFeature); 619 } 620 eNameToFeatureMap = result; 621 } 622 return (EStructuralFeatureImpl)eNameToFeatureMap.get(name); 623 } 624 625 protected EStructuralFeature[] getEAllStructuralFeaturesData() 626 { 627 if (eAllStructuralFeaturesData == null) 628 { 629 getEAllStructuralFeatures(); 630 } 631 return eAllStructuralFeaturesData; 632 } 633 634 639 public int getFeatureCount() 640 { 641 return getEAllStructuralFeaturesData().length; 642 } 643 644 public EStructuralFeature getEStructuralFeature(int featureID) 645 { 646 EStructuralFeature [] eAllStructuralFeaturesData = getEAllStructuralFeaturesData(); 647 return 648 featureID >= 0 && featureID < eAllStructuralFeaturesData.length ? 649 eAllStructuralFeaturesData[featureID] : 650 null; 651 } 652 653 658 public int getFeatureID(EStructuralFeature feature) 659 { 660 EStructuralFeature [] eAllStructuralFeaturesData = getEAllStructuralFeaturesData(); 661 int index = feature.getFeatureID(); 662 if (index != -1) 663 { 664 for (int last = eAllStructuralFeaturesData.length; index < last; ++index) 665 { 666 if (eAllStructuralFeaturesData[index] == feature) 667 { 668 return index; 669 } 670 } 671 } 672 return -1; 673 } 674 675 680 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 681 { 682 if (featureID >= 0) 683 { 684 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 685 { 686 case EcorePackage.ECLASS__EANNOTATIONS: 687 return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs); 688 case EcorePackage.ECLASS__EPACKAGE: 689 if (eContainer != null) 690 msgs = eBasicRemoveFromContainer(msgs); 691 return eBasicSetContainer(otherEnd, EcorePackage.ECLASS__EPACKAGE, msgs); 692 case EcorePackage.ECLASS__EOPERATIONS: 693 return ((InternalEList)getEOperations()).basicAdd(otherEnd, msgs); 694 case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES: 695 return ((InternalEList)getEStructuralFeatures()).basicAdd(otherEnd, msgs); 696 default: 697 return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); 698 } 699 } 700 if (eContainer != null) 701 msgs = eBasicRemoveFromContainer(msgs); 702 return eBasicSetContainer(otherEnd, featureID, msgs); 703 } 704 705 713 protected static final boolean ABSTRACT_EDEFAULT = false; 714 715 723 protected static final int ABSTRACT_EFLAG = 1 << 8; 724 725 733 protected static final boolean INTERFACE_EDEFAULT = false; 734 735 743 protected static final int INTERFACE_EFLAG = 1 << 9; 744 745 753 protected EList eSuperTypes = null; 754 755 763 protected EList eOperations = null; 764 765 773 protected BasicEList eReferences = null; 774 775 783 protected BasicEList eAttributes = null; 784 785 793 protected EList eStructuralFeatures = null; 794 795 800 public boolean isAbstract() 801 { 802 return (eFlags & ABSTRACT_EFLAG) != 0; 803 } 804 805 810 public void setAbstract(boolean newAbstract) 811 { 812 boolean oldAbstract = (eFlags & ABSTRACT_EFLAG) != 0; 813 if (newAbstract) eFlags |= ABSTRACT_EFLAG; else eFlags &= ~ABSTRACT_EFLAG; 814 if (eNotificationRequired()) 815 eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ECLASS__ABSTRACT, oldAbstract, newAbstract)); 816 } 817 818 823 public boolean isInterface() 824 { 825 return (eFlags & INTERFACE_EFLAG) != 0; 826 } 827 828 833 public void setInterface(boolean newInterface) 834 { 835 boolean oldInterface = (eFlags & INTERFACE_EFLAG) != 0; 836 if (newInterface) eFlags |= INTERFACE_EFLAG; else eFlags &= ~INTERFACE_EFLAG; 837 if (eNotificationRequired()) 838 eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.ECLASS__INTERFACE, oldInterface, newInterface)); 839 } 840 841 846 public Object eGet(EStructuralFeature eFeature, boolean resolve) 847 { 848 switch (eDerivedStructuralFeatureID(eFeature)) 849 { 850 case EcorePackage.ECLASS__EANNOTATIONS: 851 return getEAnnotations(); 852 case EcorePackage.ECLASS__NAME: 853 return getName(); 854 case EcorePackage.ECLASS__INSTANCE_CLASS_NAME: 855 return getInstanceClassName(); 856 case EcorePackage.ECLASS__INSTANCE_CLASS: 857 return getInstanceClass(); 858 case EcorePackage.ECLASS__DEFAULT_VALUE: 859 return getDefaultValue(); 860 case EcorePackage.ECLASS__EPACKAGE: 861 return getEPackage(); 862 case EcorePackage.ECLASS__ABSTRACT: 863 return isAbstract() ? Boolean.TRUE : Boolean.FALSE; 864 case EcorePackage.ECLASS__INTERFACE: 865 return isInterface() ? Boolean.TRUE : Boolean.FALSE; 866 case EcorePackage.ECLASS__ESUPER_TYPES: 867 return getESuperTypes(); 868 case EcorePackage.ECLASS__EOPERATIONS: 869 return getEOperations(); 870 case EcorePackage.ECLASS__EALL_ATTRIBUTES: 871 return getEAllAttributes(); 872 case EcorePackage.ECLASS__EALL_REFERENCES: 873 return getEAllReferences(); 874 case EcorePackage.ECLASS__EREFERENCES: 875 return getEReferences(); 876 case EcorePackage.ECLASS__EATTRIBUTES: 877 return getEAttributes(); 878 case EcorePackage.ECLASS__EALL_CONTAINMENTS: 879 return getEAllContainments(); 880 case EcorePackage.ECLASS__EALL_OPERATIONS: 881 return getEAllOperations(); 882 case EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES: 883 return getEAllStructuralFeatures(); 884 case EcorePackage.ECLASS__EALL_SUPER_TYPES: 885 return getEAllSuperTypes(); 886 case EcorePackage.ECLASS__EID_ATTRIBUTE: 887 return getEIDAttribute(); 888 case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES: 889 return getEStructuralFeatures(); 890 } 891 return eDynamicGet(eFeature, resolve); 892 } 893 894 899 public boolean eIsSet(EStructuralFeature eFeature) 900 { 901 switch (eDerivedStructuralFeatureID(eFeature)) 902 { 903 case EcorePackage.ECLASS__EANNOTATIONS: 904 return eAnnotations != null && !eAnnotations.isEmpty(); 905 case EcorePackage.ECLASS__NAME: 906 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); 907 case EcorePackage.ECLASS__INSTANCE_CLASS_NAME: 908 return INSTANCE_CLASS_NAME_EDEFAULT == null ? instanceClassName != null : !INSTANCE_CLASS_NAME_EDEFAULT.equals(instanceClassName); 909 case EcorePackage.ECLASS__INSTANCE_CLASS: 910 return INSTANCE_CLASS_EDEFAULT == null ? getInstanceClass() != null : !INSTANCE_CLASS_EDEFAULT.equals(getInstanceClass()); 911 case EcorePackage.ECLASS__DEFAULT_VALUE: 912 return DEFAULT_VALUE_EDEFAULT == null ? getDefaultValue() != null : !DEFAULT_VALUE_EDEFAULT.equals(getDefaultValue()); 913 case EcorePackage.ECLASS__EPACKAGE: 914 return getEPackage() != null; 915 case EcorePackage.ECLASS__ABSTRACT: 916 return ((eFlags & ABSTRACT_EFLAG) != 0) != ABSTRACT_EDEFAULT; 917 case EcorePackage.ECLASS__INTERFACE: 918 return ((eFlags & INTERFACE_EFLAG) != 0) != INTERFACE_EDEFAULT; 919 case EcorePackage.ECLASS__ESUPER_TYPES: 920 return eSuperTypes != null && !eSuperTypes.isEmpty(); 921 case EcorePackage.ECLASS__EOPERATIONS: 922 return eOperations != null && !eOperations.isEmpty(); 923 case EcorePackage.ECLASS__EALL_ATTRIBUTES: 924 return !getEAllAttributes().isEmpty(); 925 case EcorePackage.ECLASS__EALL_REFERENCES: 926 return !getEAllReferences().isEmpty(); 927 case EcorePackage.ECLASS__EREFERENCES: 928 return !getEReferences().isEmpty(); 929 case EcorePackage.ECLASS__EATTRIBUTES: 930 return !getEAttributes().isEmpty(); 931 case EcorePackage.ECLASS__EALL_CONTAINMENTS: 932 return !getEAllContainments().isEmpty(); 933 case EcorePackage.ECLASS__EALL_OPERATIONS: 934 return !getEAllOperations().isEmpty(); 935 case EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES: 936 return !getEAllStructuralFeatures().isEmpty(); 937 case EcorePackage.ECLASS__EALL_SUPER_TYPES: 938 return !getEAllSuperTypes().isEmpty(); 939 case EcorePackage.ECLASS__EID_ATTRIBUTE: 940 return getEIDAttribute() != null; 941 case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES: 942 return eStructuralFeatures != null && !eStructuralFeatures.isEmpty(); 943 } 944 return eDynamicIsSet(eFeature); 945 } 946 947 952 public void eSet(EStructuralFeature eFeature, Object newValue) 953 { 954 switch (eDerivedStructuralFeatureID(eFeature)) 955 { 956 case EcorePackage.ECLASS__EANNOTATIONS: 957 getEAnnotations().clear(); 958 getEAnnotations().addAll((Collection )newValue); 959 return; 960 case EcorePackage.ECLASS__NAME: 961 setName((String )newValue); 962 return; 963 case EcorePackage.ECLASS__INSTANCE_CLASS_NAME: 964 setInstanceClassName((String )newValue); 965 return; 966 case EcorePackage.ECLASS__ABSTRACT: 967 setAbstract(((Boolean )newValue).booleanValue()); 968 return; 969 case EcorePackage.ECLASS__INTERFACE: 970 setInterface(((Boolean )newValue).booleanValue()); 971 return; 972 case EcorePackage.ECLASS__ESUPER_TYPES: 973 getESuperTypes().clear(); 974 getESuperTypes().addAll((Collection )newValue); 975 return; 976 case EcorePackage.ECLASS__EOPERATIONS: 977 getEOperations().clear(); 978 getEOperations().addAll((Collection )newValue); 979 return; 980 case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES: 981 getEStructuralFeatures().clear(); 982 getEStructuralFeatures().addAll((Collection )newValue); 983 return; 984 } 985 eDynamicSet(eFeature, newValue); 986 } 987 988 993 public void eUnset(EStructuralFeature eFeature) 994 { 995 switch (eDerivedStructuralFeatureID(eFeature)) 996 { 997 case EcorePackage.ECLASS__EANNOTATIONS: 998 getEAnnotations().clear(); 999 return; 1000 case EcorePackage.ECLASS__NAME: 1001 setName(NAME_EDEFAULT); 1002 return; 1003 case EcorePackage.ECLASS__INSTANCE_CLASS_NAME: 1004 setInstanceClassName(INSTANCE_CLASS_NAME_EDEFAULT); 1005 return; 1006 case EcorePackage.ECLASS__ABSTRACT: 1007 setAbstract(ABSTRACT_EDEFAULT); 1008 return; 1009 case EcorePackage.ECLASS__INTERFACE: 1010 setInterface(INTERFACE_EDEFAULT); 1011 return; 1012 case EcorePackage.ECLASS__ESUPER_TYPES: 1013 getESuperTypes().clear(); 1014 return; 1015 case EcorePackage.ECLASS__EOPERATIONS: 1016 getEOperations().clear(); 1017 return; 1018 case EcorePackage.ECLASS__ESTRUCTURAL_FEATURES: 1019 getEStructuralFeatures().clear(); 1020 return; 1021 } 1022 eDynamicUnset(eFeature); 1023 } 1024 1025 1030 public String toString() 1031 { 1032 if (eIsProxy()) return super.toString(); 1033 1034 StringBuffer result = new StringBuffer (super.toString()); 1035 result.append(" (abstract: "); 1036 result.append((eFlags & ABSTRACT_EFLAG) != 0); 1037 result.append(", interface: "); 1038 result.append((eFlags & INTERFACE_EFLAG) != 0); 1039 result.append(')'); 1040 return result.toString(); 1041 } 1042 1043 1048 public EList getESuperTypesGen() 1049 { 1050 if (eSuperTypes == null) 1051 { 1052 eSuperTypes = new EObjectResolvingEList(EClass.class, this, EcorePackage.ECLASS__ESUPER_TYPES); 1053 } 1054 return eSuperTypes; 1055 } 1056 1057 public EList getESuperTypes() 1058 { 1059 getESuperAdapter(); 1060 return getESuperTypesGen(); 1061 } 1062 1063 1068 public EList getEOperations() 1069 { 1070 if (eOperations == null) 1071 { 1072 eOperations = new EObjectContainmentWithInverseEList(EOperation.class, this, EcorePackage.ECLASS__EOPERATIONS, EcorePackage.EOPERATION__ECONTAINING_CLASS); 1073 } 1074 return eOperations; 1075 } 1076 1077 1083 public boolean isSuperTypeOf(EClass someClass) 1084 { 1085 return someClass == this || someClass.getEAllSuperTypes().contains(this); 1086 } 1087 1088 1091 public EList getEAllSuperTypes() 1092 { 1093 if (eAllSuperTypes == null) 1094 { 1095 BasicEList result = 1096 new UniqueEList() 1097 { 1098 protected Object [] newData(int capacity) 1099 { 1100 return new EClassifier [capacity]; 1101 } 1102 1103 protected boolean useEquals() 1104 { 1105 return false; 1106 } 1107 }; 1108 1109 EList immediateSupers = getESuperTypes(); 1110 Iterator i = immediateSupers.iterator(); 1111 while (i.hasNext()) 1112 { 1113 EClass supertype = (EClass)i.next(); 1114 EList higherSupers = supertype.getEAllSuperTypes(); 1115 result.addAll(higherSupers); 1116 result.add(supertype); 1117 } 1118 1119 result.shrink(); 1120 eAllSuperTypes = 1121 new EcoreEList.UnmodifiableEList.FastCompare 1122 (this, EcorePackage.eINSTANCE.getEClass_EAllSuperTypes(), result.size(), result.data()); 1123 getESuperAdapter().setAllSuperCollectionModified(false); 1124 } 1125 1126 return eAllSuperTypes; 1127 } 1128 1129 protected boolean dynamicIsInstance(EObject eObject) 1130 { 1131 return isSuperTypeOf(eObject.eClass()); 1132 } 1133 1134 public ESuperAdapter getESuperAdapter() 1135 { 1136 if (eSuperAdapter == null) 1137 { 1138 eSuperAdapter = 1139 new ESuperAdapter() 1140 { 1141 void setFlags(int featureId) 1142 { 1143 super.setFlags(featureId); 1144 1145 if (isAllAttributesCollectionModified()) 1146 { 1147 eAllAttributes = null; 1148 } 1149 if (isAllReferencesCollectionModified()) 1150 { 1151 eAllReferences = null; 1152 } 1153 if (isAllStructuralFeaturesCollectionModified()) 1154 { 1155 eAllStructuralFeatures = null; 1156 eAllStructuralFeaturesData = null; 1157 } 1158 if (isAllOperationsCollectionModified()) 1159 { 1160 eAllOperations = null; 1161 } 1162 if (isAllContainmentsCollectionModified()) 1163 { 1164 eAllContainments = null; 1165 } 1166 if (isAllSuperCollectionModified()) 1167 { 1168 eAllSuperTypes = null; 1169 } 1170 } 1171 }; 1172 eAdapters().add(0, eSuperAdapter); 1173 } 1174 return eSuperAdapter; 1175 } 1176 1177 public void eSetDeliver(boolean deliver) 1178 { 1179 super.eSetDeliver(deliver); 1180 1181 if (deliver) 1182 { 1183 for (Iterator eSuperTypes = getESuperTypes().iterator(); eSuperTypes.hasNext(); ) 1184 { 1185 EClass eSuperType = (EClass)eSuperTypes.next(); 1186 ESuperAdapter eSuperAdapter = ((ESuperAdapter.Holder)eSuperType).getESuperAdapter(); 1187 eSuperAdapter.getSubclasses().add(this); 1188 } 1189 } 1190 } 1191} 1192 | Popular Tags |