| 1 17 package org.eclipse.emf.ecore.util; 18 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 import java.util.Collections ; 23 import java.util.HashMap ; 24 import java.util.Hashtable ; 25 import java.util.List ; 26 import java.util.Map ; 27 import java.util.StringTokenizer ; 28 29 import org.eclipse.emf.common.util.EMap; 30 import org.eclipse.emf.common.util.UniqueEList; 31 import org.eclipse.emf.ecore.EAnnotation; 32 import org.eclipse.emf.ecore.EAttribute; 33 import org.eclipse.emf.ecore.EClass; 34 import org.eclipse.emf.ecore.EClassifier; 35 import org.eclipse.emf.ecore.EDataType; 36 import org.eclipse.emf.ecore.EModelElement; 37 import org.eclipse.emf.ecore.EPackage; 38 import org.eclipse.emf.ecore.EReference; 39 import org.eclipse.emf.ecore.EStructuralFeature; 40 import org.eclipse.emf.ecore.ETypedElement; 41 import org.eclipse.emf.ecore.EcoreFactory; 42 import org.eclipse.emf.ecore.EcorePackage; 43 import org.eclipse.emf.ecore.xml.type.XMLTypePackage; 44 45 46 49 public class BasicExtendedMetaData implements ExtendedMetaData 50 { 51 protected String annotationURI; 52 protected EPackage.Registry registry; 53 protected EPackage.Registry demandRegistry; 54 protected Map extendedMetaDataHolderCache; 55 protected Map annotationMap; 56 57 public BasicExtendedMetaData() 58 { 59 this(ANNOTATION_URI, EPackage.Registry.INSTANCE); 60 } 61 62 public BasicExtendedMetaData(EPackage.Registry registry) 63 { 64 this(ANNOTATION_URI, registry); 65 } 66 67 public BasicExtendedMetaData(String annotationURI, EPackage.Registry registry) 68 { 69 this(annotationURI, registry, null); 70 } 71 72 public BasicExtendedMetaData(String annotationURI, EPackage.Registry registry, Map annotationMap) 73 { 74 this.annotationURI = annotationURI.intern(); 75 this.registry = registry; 76 this.demandRegistry = new org.eclipse.emf.ecore.impl.EPackageRegistryImpl(); 77 this.annotationMap = annotationMap; 78 79 if (annotationURI != ANNOTATION_URI) 80 { 81 extendedMetaDataHolderCache = new HashMap (); 82 } 83 } 84 85 protected EAnnotation getAnnotation(EModelElement eModelElement, boolean demandCreate) 86 { 87 if (annotationMap != null) 88 { 89 EAnnotation result = (EAnnotation)annotationMap.get(eModelElement); 90 if (result == null && demandCreate) 91 { 92 result = EcoreFactory.eINSTANCE.createEAnnotation(); 93 result.setSource(annotationURI); 94 annotationMap.put(eModelElement, result); 95 } 96 return result; 97 } 98 else 99 { 100 EAnnotation result = eModelElement.getEAnnotation(annotationURI); 101 if (result == null && demandCreate) 102 { 103 result = EcoreFactory.eINSTANCE.createEAnnotation(); 104 result.setSource(annotationURI); 105 eModelElement.getEAnnotations().add(result); 106 } 107 return result; 108 } 109 } 110 111 public EClassifier getType(EPackage ePackage, String name) 112 { 113 List eClassifiers = ePackage.getEClassifiers(); 114 for (int i = 0, size = eClassifiers.size(); i < size; ++i) 115 { 116 EClassifier eClassifier = (EClassifier)eClassifiers.get(i); 117 if (name.equals(getName(eClassifier))) 118 { 119 return eClassifier; 120 } 121 } 122 return null; 123 } 124 125 public EPackage getPackage(String namespace) 126 { 127 EPackage ePackage = registry.getEPackage(namespace); 128 134 return ePackage; 135 } 136 137 public void putPackage(String namespace, EPackage ePackage) 138 { 139 registry.put(namespace, ePackage); 140 } 141 142 public EClass getDocumentRoot(EPackage ePackage) 143 { 144 return (EClass)getType(ePackage, ""); 145 } 146 147 public void setDocumentRoot(EClass eClass) 148 { 149 setName(eClass, ""); 150 setContentKind(eClass, MIXED_CONTENT); 151 } 152 153 public EReference getXMLNSPrefixMapFeature(EClass eClass) 154 { 155 if (getContentKind(eClass) == MIXED_CONTENT) 156 { 157 List eAllReferences = eClass.getEAllReferences(); 158 for (int i = 0, size = eAllReferences.size(); i < size; ++i) 159 { 160 EReference eReference = (EReference)eAllReferences.get(i); 161 if ("xmlns:prefix".equals(getName(eReference))) 162 { 163 return eReference; 164 } 165 } 166 } 167 168 return null; 169 } 170 171 public EReference getXSISchemaLocationMapFeature(EClass eClass) 172 { 173 if (getContentKind(eClass) == MIXED_CONTENT) 174 { 175 List eAllReferences = eClass.getEAllReferences(); 176 for (int i = 0, size = eAllReferences.size(); i < size; ++i) 177 { 178 EReference eReference = (EReference)eAllReferences.get(i); 179 if ("xsi:schemaLocation".equals(getName(eReference))) 180 { 181 return eReference; 182 } 183 } 184 } 185 186 return null; 187 } 188 189 public boolean isQualified(EPackage ePackage) 190 { 191 return getExtendedMetaData(ePackage).isQualified(); 192 } 193 194 protected boolean basicIsQualified(EPackage ePackage) 195 { 196 EAnnotation eAnnotation = getAnnotation(ePackage, false); 197 return eAnnotation == null || !"false".equals(eAnnotation.getDetails().get("qualified")); 198 } 199 200 public void setQualified(EPackage ePackage, boolean isQualified) 201 { 202 if (!isQualified) 203 { 204 EAnnotation eAnnotation = getAnnotation(ePackage, true); 205 eAnnotation.getDetails().put("qualified", "false"); 206 } 207 else 208 { 209 EAnnotation eAnnotation = getAnnotation(ePackage, false); 210 if (eAnnotation != null) 211 { 212 eAnnotation.getDetails().remove("qualified"); 213 } 214 } 215 getExtendedMetaData(ePackage).setQualified(isQualified); 216 } 217 218 public String getNamespace(EPackage ePackage) 219 { 220 if (isQualified(ePackage)) 221 { 222 return (ePackage).getNsURI(); 223 } 224 else 225 { 226 return null; 227 } 228 } 229 230 public String getNamespace(EClassifier eClassifier) 231 { 232 return getNamespace(eClassifier.getEPackage()); 233 } 234 235 public String getNamespace(EStructuralFeature eStructuralFeature) 236 { 237 return getExtendedMetaData(eStructuralFeature).getNamespace(); 238 } 239 240 public String basicGetNamespace(EStructuralFeature eStructuralFeature) 241 { 242 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, false); 243 if (eAnnotation == null) 244 { 245 return null; 246 } 247 else 248 { 249 String result = (String )eAnnotation.getDetails().get("namespace"); 250 if ("##targetNamespace".equals(result)) 251 { 252 return getNamespace(eStructuralFeature.getEContainingClass().getEPackage()); 253 } 254 else 255 { 256 return result; 257 } 258 } 259 } 260 261 public void setNamespace(EStructuralFeature eStructuralFeature, String namespace) 262 { 263 String packageNamespace = getNamespace(eStructuralFeature.getEContainingClass().getEPackage()); 264 String convertedNamespace = namespace; 265 if (namespace == null ? packageNamespace == null : namespace.equals(packageNamespace)) 266 { 267 convertedNamespace="##targetNamespace"; 268 } 269 270 if (convertedNamespace != null) 271 { 272 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, true); 273 eAnnotation.getDetails().put("namespace", convertedNamespace); 274 } 275 else 276 { 277 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, false); 278 if (eAnnotation != null) 279 { 280 eAnnotation.getDetails().remove("namespace"); 281 } 282 } 283 getExtendedMetaData(eStructuralFeature).setNamespace(namespace); 284 } 285 286 public String getName(EClassifier eClassifier) 287 { 288 return getExtendedMetaData(eClassifier).getName(); 289 } 290 291 protected String basicGetName(EClassifier eClassifier) 292 { 293 EAnnotation eAnnotation = getAnnotation(eClassifier, false); 294 if (eAnnotation != null) 295 { 296 String result = (String )eAnnotation.getDetails().get("name"); 297 if (result != null) 298 { 299 return result; 300 } 301 } 302 return eClassifier.getName(); 303 } 304 305 public void setName(EClassifier eClassifier, String name) 306 { 307 EAnnotation eAnnotation = getAnnotation(eClassifier, true); 308 eAnnotation.getDetails().put("name", name); 309 getExtendedMetaData(eClassifier).setName(name); 310 } 311 312 public boolean isAnonymous(EClassifier eClassifier) 313 { 314 String name = getExtendedMetaData(eClassifier).getName(); 315 return name.length() == 0 || name.indexOf("_._") != -1; 316 } 317 318 public String getName(EStructuralFeature eStructuralFeature) 319 { 320 return getExtendedMetaData(eStructuralFeature).getName(); 321 } 322 323 protected String basicGetName(EStructuralFeature eStructuralFeature) 324 { 325 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, false); 326 if (eAnnotation != null) 327 { 328 String result = (String )eAnnotation.getDetails().get("name"); 329 if (result != null) 330 { 331 return result; 332 } 333 } 334 return eStructuralFeature.getName(); 335 } 336 337 public void setName(EStructuralFeature eStructuralFeature, String name) 338 { 339 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, true); 340 eAnnotation.getDetails().put("name", name); 341 getExtendedMetaData(eStructuralFeature).setName(name); 342 } 343 344 protected String getQualifiedName(String defaultNamespace, EClassifier eClassifier) 345 { 346 String namespace = getNamespace(eClassifier); 347 String name = getName(eClassifier); 348 if (namespace == null) 349 { 350 return namespace == defaultNamespace ? name : "#" + name; 351 } 352 else 353 { 354 return namespace.equals(defaultNamespace) ? name : namespace + "#" + name; 355 } 356 } 357 358 protected String getQualifiedName(String defaultNamespace, EStructuralFeature eStructuralFeature) 359 { 360 String namespace = getNamespace(eStructuralFeature); 361 String name = getName(eStructuralFeature); 362 if (namespace == null) 363 { 364 return namespace == defaultNamespace ? name : "#" + name; 365 } 366 else 367 { 368 return namespace.equals(defaultNamespace) ? name : namespace + "#" + name; 369 } 370 } 371 372 public EClassifier getType(String namespace, String name) 373 { 374 EPackage ePackage = getPackage(namespace); 375 return ePackage == null ? null : getType(ePackage, name); 376 } 377 378 public EStructuralFeature getAttribute(String namespace, String name) 379 { 380 EPackage ePackage = getPackage(namespace); 381 if (ePackage != null) 382 { 383 EClass documentRoot = getDocumentRoot(ePackage); 384 if (documentRoot != null) 385 { 386 return getLocalAttribute(documentRoot, namespace, name); 387 } 388 } 389 390 return null; 391 } 392 393 public EStructuralFeature getElement(String namespace, String name) 394 { 395 EPackage ePackage = getPackage(namespace); 396 if (ePackage != null) 397 { 398 EClass documentRoot = getDocumentRoot(ePackage); 399 if (documentRoot != null) 400 { 401 return getLocalElement(documentRoot, namespace, name); 402 } 403 } 404 405 return null; 406 } 407 408 public int getFeatureKind(EStructuralFeature eStructuralFeature) 409 { 410 return getExtendedMetaData(eStructuralFeature).getFeatureKind(); 411 } 412 413 protected int basicGetFeatureKind(EStructuralFeature eStructuralFeature) 414 { 415 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, false); 416 if (eAnnotation != null) 417 { 418 Object kind = eAnnotation.getDetails().get("kind"); 419 if (kind != null) 420 { 421 for (int i = 1; i < FEATURE_KINDS.length; ++i) 422 { 423 if (FEATURE_KINDS[i].equals(kind)) 424 { 425 return i; 426 } 427 } 428 } 429 } 430 431 return 0; 432 } 433 434 public void setFeatureKind(EStructuralFeature eStructuralFeature, int kind) 435 { 436 if (kind > 0 && kind < FEATURE_KINDS.length) 437 { 438 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, true); 439 eAnnotation.getDetails().put("kind", FEATURE_KINDS[kind]); 440 } 441 else 442 { 443 EAnnotation eAnnotation = getAnnotation(eStructuralFeature, false); 444 if (eAnnotation != null) 445 { 446 eAnnotation.getDetails().remove("kind"); 447 } 448 } 449 getExtendedMetaData(eStructuralFeature).setFeatureKind(kind); 450 } 451 452 public int getContentKind(EClass eClass) 453 { 454 return getExtendedMetaData(eClass).getContentKind(); 455 } 456 457 protected int basicGetContentKind(EClass eClass) 458 { 459 EAnnotation eAnnotation = getAnnotation(eClass, false); 460 if (eAnnotation != null) 461 { 462 Object kind = eAnnotation.getDetails().get("kind"); 463 if (kind != null) 464 { 465 for (int i = 1; i < CONTENT_KINDS.length; ++i) 466 { 467 if (CONTENT_KINDS[i].equals(kind)) 468 { 469 return i; 470 } 471 } 472 } 473 } 474 475 return 0; 476 } 477 478 public void setContentKind(EClass eClass, int kind) 479 { 480 if (kind > 0 && kind < CONTENT_KINDS.length) 481 { 482 EAnnotation eAnnotation = getAnnotation(eClass, true); 483 eAnnotation.getDetails().put("kind", CONTENT_KINDS[kind]); 484 } 485 else 486 { 487 EAnnotation eAnnotation = getAnnotation(eClass, false); 488 if (eAnnotation != null) 489 { 490 eAnnotation.getDetails().remove("kind"); 491 } 492 } 493 getExtendedMetaData(eClass).setContentKind(kind); 494 } 495 496 public int getDerivationKind(EDataType eDataType) 497 { 498 return getExtendedMetaData(eDataType).getDerivationKind(); 499 } 500 501 protected int basicGetDerivationKind(EClassifier eClassifier) 502 { 503 EAnnotation eAnnotation = getAnnotation(eClassifier, false); 504 if (eAnnotation != null) 505 { 506 EMap details = eAnnotation.getDetails(); 507 Object kind = details.get("restriction"); 508 if (kind != null) 509 { 510 return RESTRICTION_DERIVATION; 511 } 512 kind = details.get("list"); 513 if (kind != null) 514 { 515 return LIST_DERIVATION; 516 } 517 kind = details.get("union"); 518 if (kind != null) 519 { 520 return UNION_DERIVATION; 521 } 522 } 523 524 return 0; 525 } 526 527 public EDataType getBaseType(EDataType eDataType) 528 { 529 return getExtendedMetaData(eDataType).getBaseType(); 530 } 531 532 public EDataType basicGetBaseType(EDataType eDataType) 533 { 534 EAnnotation eAnnotation = getAnnotation(eDataType, false); 535 if (eAnnotation != null) 536 { 537 EMap details = eAnnotation.getDetails(); 538 String baseType = (String )details.get("baseType"); 539 if (baseType != null) 540 { 541 int index = baseType.lastIndexOf("#"); 542 EClassifier type = 543 index == -1 ? 544 getType(eDataType.getEPackage(), baseType) : 545 index == 0 ? 546 getType((String )null, baseType.substring(1)) : 547 getType(baseType.substring(0, index), baseType.substring(index + 1)); 548 if (type instanceof EDataType) 549 { 550 return (EDataType)type; 551 } 552 } 553 } 554 555 return null; 556 } 557 558 public void setBaseType(EDataType eDataType, EDataType baseType) 559 { 560 if (baseType == null) 561 { 562 EAnnotation eAnnotation = getAnnotation(eDataType, false); 563 if (eAnnotation != null) 564 { 565 eAnnotation.getDetails().remove("baseType"); 566 } 567 } 568 else 569 { 570 EAnnotation eAnnotation = getAnnotation(eDataType, true); 571 eAnnotation.getDetails().put("baseType", getQualifiedName(getNamespace(eDataType), baseType)); 572 } 573 getExtendedMetaData(eDataType).setBaseType(baseType); 574 } 575 576 public EDataType getItemType(EDataType eDataType) 577 { 578 return getExtendedMetaData(eDataType).getItemType(); 579 } 580 581 protected EDataType basicGetItemType(EDataType eDataType) 582 { 583 EAnnotation eAnnotation = getAnnotation(eDataType, false); 584 if (eAnnotation != null) 585 { 586 EMap details = eAnnotation.getDetails(); 587 String itemType = (String )details.get("itemType"); 588 if (itemType != null) 589 { 590 int index = itemType.lastIndexOf("#"); 591 EClassifier type = 592 index == -1 ? 593 getType(eDataType.getEPackage(), itemType) : 594 index == 0 ? 595 getType((String )null, itemType.substring(1)) : 596 getType(itemType.substring(0, index), itemType.substring(index + 1)); 597 if (type instanceof EDataType) 598 { 599 return (EDataType)type; 600 } 601 } 602 } 603 604 return null; 605 } 606 607 public void setItemType(EDataType eDataType, EDataType itemType) 608 { 609 if (itemType == null) 610 { 611 EAnnotation eAnnotation = getAnnotation(eDataType, false); 612 if (eAnnotation != null) 613 { 614 eAnnotation.getDetails().remove("itemType"); 615 } 616 } 617 else 618 { 619 EAnnotation eAnnotation = getAnnotation(eDataType, true); 620 eAnnotation.getDetails().put("itemType", getQualifiedName(getNamespace(eDataType), itemType)); 621 } 622 getExtendedMetaData(eDataType).setItemType(itemType); 623 } 624 625 public List getMemberTypes(EDataType eDataType) 626 { 627 return getExtendedMetaData(eDataType).getMemberTypes(); 628 } 629 630 protected List basicGetMemberTypes(EDataType eDataType) 631 { 632 EAnnotation eAnnotation = getAnnotation(eDataType, false); 633 if (eAnnotation != null) 634 { 635 String memberTypes = (String )eAnnotation.getDetails().get("memberTypes"); 636 if (memberTypes != null) 637 { 638 List result = new ArrayList (); 639 for (StringTokenizer stringTokenizer = new StringTokenizer (memberTypes); stringTokenizer.hasMoreTokens(); ) 640 { 641 String member = stringTokenizer.nextToken(); 642 int index = member.lastIndexOf("#"); 643 EClassifier type = 644 index == -1 ? 645 getType(eDataType.getEPackage(), member) : 646 index == 0 ? 647 getType((String )null, member.substring(1)) : 648 getType(member.substring(0, index), member.substring(index + 1)); 649 if (type instanceof EDataType) 650 { 651 result.add(type); 652 } 653 } 654 return result; 655 } 656 } 657 658 return Collections.EMPTY_LIST; 659 } 660 661 public void setMemberTypes(EDataType eDataType, List memberTypes) 662 { 663 if (memberTypes.isEmpty()) 664 { 665 EAnnotation eAnnotation = getAnnotation(eDataType, false); 666 if (eAnnotation != null) 667 { 668 eAnnotation.getDetails().remove("memberTypes"); 669 } 670 } 671 else 672 { 673 EAnnotation eAnnotation = getAnnotation(eDataType, true); 674 String namespace = getNamespace(eDataType); 675 StringBuffer result = new StringBuffer (); 676 for (int i = 0, size = memberTypes.size(); i < size; ++i) 677 { 678 result.append(getQualifiedName(namespace, (EDataType)memberTypes.get(i))); 679 result.append(' '); 680 } 681 eAnnotation.getDetails().put("memberTypes", result.substring(0, result.length() - 1)); 682 } 683 getExtendedMetaData(eDataType).setMemberTypes(memberTypes); 684 } 685 686 protected boolean isFeatureKindSpecific() 687 { 688 return true; 689 } 690 691 public EStructuralFeature getLocalAttribute(EClass eClass, String namespace, String name) 692 { 693 if (isFeatureKindSpecific()) 694 { 695 List allAttributes = getAllAttributes(eClass); 696 for (int i = 0, size = allAttributes.size(); i < size; ++i) 697 { 698 EStructuralFeature eStructuralFeature = (EStructuralFeature)allAttributes.get(i); 699 if (name.equals(getName(eStructuralFeature)) && 700 (namespace == null ? getNamespace(eStructuralFeature) == null : namespace.equals(getNamespace(eStructuralFeature)))) 701 { 702 return eStructuralFeature; 703 } 704 } 705 } 706 else 707 { 708 for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) 709 { 710 EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); 711 switch (getFeatureKind(eStructuralFeature)) 712 { 713 case UNSPECIFIED_FEATURE: 714 case ATTRIBUTE_FEATURE: 715 { 716 if (name.equals(getName(eStructuralFeature)) && 717 (namespace == null ? getNamespace(eStructuralFeature) == null : namespace.equals(getNamespace(eStructuralFeature)))) 718 { 719 return eStructuralFeature; 720 } 721 break; 722 } 723 } 724 } 725 } 726 727 return null; 728 } 729 730 public EStructuralFeature getAttribute(EClass eClass, String namespace, String name) 731 { 732 EStructuralFeature result = getLocalAttribute(eClass, namespace, name); 733 if (result == null) 734 { 735 result = getAttribute(namespace, name); 736 if (result != null && getAffiliation(eClass, result) == null) 737 { 738 return null; 739 } 740 } 741 return result; 742 } 743 744 protected EStructuralFeature getLocalElement(EClass eClass, String namespace, String name) 745 { 746 if (isFeatureKindSpecific()) 747 { 748 List allElements = getAllElements(eClass); 749 for (int i = 0, size = allElements.size(); i < size; ++i) 750 { 751 EStructuralFeature eStructuralFeature = (EStructuralFeature)allElements.get(i); 752 if (name.equals(getName(eStructuralFeature)) && 753 (namespace == null ? getNamespace(eStructuralFeature) == null : namespace.equals(getNamespace(eStructuralFeature)))) 754 { 755 return eStructuralFeature; 756 } 757 } 758 } 759 else 760 { 761 for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) 762 { 763 EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); 764 switch (getFeatureKind(eStructuralFeature)) 765 { 766 case UNSPECIFIED_FEATURE: 767 case ELEMENT_FEATURE: 768 { 769 if (name.equals(getName(eStructuralFeature)) && 770 (namespace == null ? getNamespace(eStructuralFeature) == null : namespace.equals(getNamespace(eStructuralFeature)))) 771 { 772 return eStructuralFeature; 773 } 774 break; 775 } 776 } 777 } 778 } 779 780 return null; 781 } 782 783 public EStructuralFeature getElement(EClass eClass, String namespace, String name) 784 { 785 EStructuralFeature result = getLocalElement(eClass, namespace, name); 786 if (result == null) 787 { 788 result = getElement(namespace, name); 789 if (result != null && getAffiliation(eClass, result) == null) 790 { 791 return null; 792 } 793 } 794 return result; 795 } 796 797 public List getAllAttributes(EClass eClass) 798 { 799 List superTypes = eClass.getESuperTypes(); 800 List result = null; 801 boolean changeable = false; 802 for (int i = 0, size = superTypes.size(); i < size; ++i) 803 { 804 EClass eSuperType = (EClass)superTypes.get(i); 805 List allAttributes = getAllAttributes(eSuperType); 806 if (!allAttributes.isEmpty()) 807 { 808 if (result == null) 809 { 810 result = allAttributes; 811 } 812 else 813 { 814 if (!changeable) 815 { 816 changeable = true; 817 result = new UniqueEList(result); 818 } 819 result.addAll(allAttributes); 820 } 821 } 822 } 823 List attributes = getAttributes(eClass); 824 if (!attributes.isEmpty()) 825 { 826 if (result == null) 827 { 828 return attributes; 829 } 830 else 831 { 832 if (!changeable) 833 { 834 result = new UniqueEList(result); 835 } 836 result.addAll(attributes); 837 return result; 838 } 839 } 840 else 841 { 842 return result == null ? Collections.EMPTY_LIST : result; 843 } 844 } 845 846 public List getAllElements(EClass eClass) 847 { 848 List superTypes = eClass.getESuperTypes(); 849 List result = null; 850 boolean changeable = false; 851 for (int i = 0, size = superTypes.size(); i < size; ++i) 852 { 853 EClass eSuperType = (EClass)superTypes.get(i); 854 List allElements = getAllElements(eSuperType); 855 if (!allElements.isEmpty()) 856 { 857 if (result == null) 858 { 859 result = allElements; 860 } 861 else 862 { 863 if (!changeable) 864 { 865 changeable = true; 866 result = new UniqueEList(result); 867 } 868 result.addAll(allElements); 869 } 870 } 871 } 872 List elements = getElements(eClass); 873 if (!elements.isEmpty()) 874 { 875 if (result == null) 876 { 877 return elements; 878 } 879 else 880 { 881 if (!changeable) 882 { 883 result = new UniqueEList(result); 884 } 885 result.addAll(elements); 886 return result; 887 } 888 } 889 else 890 { 891 return result == null ? Collections.EMPTY_LIST : result; 892 } 893 } 894 895 public List getAttributes(EClass eClass) 896 { 897 |