1 17 package org.eclipse.emf.ecore.impl; 18 19 20 import java.util.Iterator ; 21 22 import org.eclipse.emf.common.notify.Notification; 23 import org.eclipse.emf.common.notify.NotificationChain; 24 import org.eclipse.emf.common.notify.impl.BasicNotifierImpl; 25 import org.eclipse.emf.common.notify.impl.NotificationChainImpl; 26 import org.eclipse.emf.common.util.AbstractTreeIterator; 27 import org.eclipse.emf.common.util.EList; 28 import org.eclipse.emf.common.util.TreeIterator; 29 import org.eclipse.emf.common.util.URI; 30 import org.eclipse.emf.common.util.WrappedException; 31 import org.eclipse.emf.ecore.EAttribute; 32 import org.eclipse.emf.ecore.EClass; 33 import org.eclipse.emf.ecore.EObject; 34 import org.eclipse.emf.ecore.EReference; 35 import org.eclipse.emf.ecore.EStructuralFeature; 36 import org.eclipse.emf.ecore.EcorePackage; 37 import org.eclipse.emf.ecore.InternalEObject; 38 import org.eclipse.emf.ecore.resource.Resource; 39 import org.eclipse.emf.ecore.util.EContentsEList; 40 import org.eclipse.emf.ecore.util.ECrossReferenceEList; 41 import org.eclipse.emf.ecore.util.EcoreUtil; 42 import org.eclipse.emf.ecore.util.ExtendedMetaData; 43 import org.eclipse.emf.ecore.util.FeatureMap; 44 import org.eclipse.emf.ecore.util.FeatureMapUtil; 45 import org.eclipse.emf.ecore.util.InternalEList; 46 47 48 51 public class BasicEObjectImpl extends BasicNotifierImpl implements EObject, InternalEObject 52 { 53 56 protected interface EPropertiesHolder extends EStructuralFeature.Internal.DynamicValueHolder 57 { 58 EClass getEClass(); 59 void setEClass(EClass eClass); 60 61 URI getEProxyURI(); 62 void setEProxyURI(URI eProxyURI); 63 64 Resource.Internal getEResource(); 65 void setEResource(Resource.Internal eResource); 66 67 EList getEContents(); 68 void setEContents(EList eContents); 69 70 EList getECrossReferences(); 71 void setECrossReferences(EList eCrossReferences); 72 73 boolean hasSettings(); 74 void allocateSettings(int dynamicFeatureCount); 75 } 76 77 80 protected static class EPropertiesHolderImpl implements EPropertiesHolder 81 { 82 protected EClass eClass; 83 protected URI eProxyURI; 84 protected Resource.Internal eResource; 85 protected EList eContents; 86 protected EList eCrossReferences; 87 protected Object [] eSettings; 88 89 protected static final Object [] NO_SETTINGS = new Object [0]; 90 91 public EClass getEClass() 92 { 93 return eClass; 94 } 95 96 public void setEClass(EClass eClass) 97 { 98 this.eClass = eClass; 99 } 100 101 public URI getEProxyURI() 102 { 103 return eProxyURI; 104 } 105 106 public void setEProxyURI(URI eProxyURI) 107 { 108 this.eProxyURI = eProxyURI; 109 } 110 111 public Resource.Internal getEResource() 112 { 113 return eResource; 114 } 115 116 public void setEResource(Resource.Internal eResource) 117 { 118 this.eResource = eResource; 119 } 120 121 public EList getEContents() 122 { 123 return eContents; 124 } 125 126 public void setEContents(EList eContents) 127 { 128 this.eContents = eContents; 129 } 130 131 public EList getECrossReferences() 132 { 133 return eCrossReferences; 134 } 135 136 public void setECrossReferences(EList eCrossReferences) 137 { 138 this.eCrossReferences = eCrossReferences; 139 } 140 141 public boolean hasSettings() 142 { 143 return eSettings != null; 144 } 145 146 public void allocateSettings(int dynamicFeatureCount) 147 { 148 eSettings = dynamicFeatureCount == 0 ? NO_SETTINGS : new Object [dynamicFeatureCount]; 149 } 150 151 public Object dynamicGet(int dynamicFeatureID) 152 { 153 return eSettings[dynamicFeatureID]; 154 } 155 156 public void dynamicSet(int dynamicFeatureID, Object value) 157 { 158 eSettings[dynamicFeatureID] = value; 159 } 160 161 public void dynamicUnset(int dynamicFeatureID) 162 { 163 eSettings[dynamicFeatureID] = null; 164 } 165 } 166 167 170 protected BasicEObjectImpl() 171 { 172 super(); 173 } 174 175 protected int eStaticFeatureCount() 176 { 177 return eStaticClass().getFeatureCount(); 178 } 179 180 protected EPropertiesHolder eProperties() 181 { 182 throw new UnsupportedOperationException (); 183 } 189 190 protected EPropertiesHolder eBasicProperties() 191 { 192 throw new UnsupportedOperationException (); 193 } 195 196 protected boolean eHasSettings() 197 { 198 EPropertiesHolder eProperties = eBasicProperties(); 199 return eProperties != null && eProperties.hasSettings(); 200 } 201 202 protected EStructuralFeature.Internal.DynamicValueHolder eSettings() 203 { 204 if (!eHasSettings()) 205 { 206 int size = eClass().getFeatureCount() - eStaticFeatureCount(); 207 eProperties().allocateSettings(size); 208 } 209 210 return eBasicProperties(); 211 } 212 213 protected int eDynamicFeatureID(EStructuralFeature eStructuralFeature) 214 { 215 return eClass().getFeatureID(eStructuralFeature) - eStaticFeatureCount(); 216 } 217 218 protected EStructuralFeature eDynamicFeature(int dynamicFeatureID) 219 { 220 return eClass().getEStructuralFeature(dynamicFeatureID + eStaticFeatureCount()); 221 } 222 223 public String eURIFragmentSegment(EStructuralFeature eStructuralFeature, EObject eObject) 224 { 225 if (eStructuralFeature == null) 226 { 227 for (EContentsEList.FeatureIterator crossReferences = 228 (EContentsEList.FeatureIterator)((InternalEList)eCrossReferences()).basicIterator(); 229 crossReferences.hasNext(); ) 230 { 231 EObject crossReference = (EObject)crossReferences.next(); 232 if (crossReference == eObject) 233 { 234 eStructuralFeature = crossReferences.feature(); 235 } 236 } 237 } 238 239 if (eStructuralFeature instanceof EAttribute) 240 { 241 FeatureMap featureMap = (FeatureMap)eGet(eStructuralFeature, false); 242 for (int i = 0, size = featureMap.size(); i < size; ++i) 243 { 244 if (featureMap.getValue(i) == eObject) 245 { 246 EStructuralFeature entryFeature = featureMap.getEStructuralFeature(i); 247 if (entryFeature instanceof EReference && ((EReference)entryFeature).isContainment()) 248 { 249 return '@' + eStructuralFeature.getName() + '.' + i; 250 } 251 } 252 } 253 return '@' + eStructuralFeature.getName() + ".-1"; 254 } 255 else if (eStructuralFeature.isMany()) 256 { 257 EList eList = (EList)eGet(eStructuralFeature, false); 258 int index = eList.indexOf(eObject); 259 return '@' + eStructuralFeature.getName() + '.' + index; 260 } 261 else 262 { 263 return '@' + eStructuralFeature.getName(); 264 } 265 } 266 267 public EObject eObjectForURIFragmentSegment(String uriFragmentSegment) 268 { 269 int dotIndex = uriFragmentSegment.indexOf("."); 270 if (dotIndex == -1) 271 { 272 String name = uriFragmentSegment.substring(1); 273 EStructuralFeature eStructuralFeature = eClass().getEStructuralFeature(name); 274 if (eStructuralFeature == null) 275 { 276 throw new IllegalArgumentException ("The feature '" + name + "' is not a valid feature"); 277 } 278 return (EObject)eGet(eStructuralFeature, false); 279 } 280 else 281 { 282 String name = uriFragmentSegment.substring(1, dotIndex); 283 EStructuralFeature eStructuralFeature = eClass().getEStructuralFeature(name); 284 if (eStructuralFeature == null) 285 { 286 throw new IllegalArgumentException ("The feature '" + name + "' is not a valid feature"); 287 } 288 EList eList = (EList)eGet(eStructuralFeature, false); 289 int position = 0; 290 try 291 { 292 position = Integer.parseInt(uriFragmentSegment.substring(dotIndex + 1)); 293 } 294 catch (NumberFormatException exception) 295 { 296 throw new WrappedException(exception); 297 } 298 if (position < eList.size()) 299 { 300 Object result = eList.get(position); 301 if (result instanceof FeatureMap.Entry) 302 { 303 result = ((FeatureMap.Entry)result).getValue(); 304 } 305 return (EObject)result; 306 } 307 else 308 { 309 return null; 310 } 311 } 312 } 313 314 public boolean eContains(EObject eObject) 315 { 316 return EcoreUtil.isAncestor(this, eObject); 317 } 318 319 public EObject eContainer() 320 { 321 return eInternalContainer(); 322 } 323 324 protected InternalEObject eInternalContainer() 325 { 326 throw new UnsupportedOperationException (); 327 } 329 330 public int eContainerFeatureID() 331 { 332 throw new UnsupportedOperationException (); 333 } 335 336 protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID) 337 { 338 throw new UnsupportedOperationException (); 339 } 342 343 public EList eContents() 344 { 345 EList result = eProperties().getEContents(); 346 if (result == null) 347 { 348 eBasicProperties().setEContents(result = new EContentsEList(this)); 349 } 350 351 return result; 352 } 353 354 public EList eCrossReferences() 355 { 356 EList result = eProperties().getECrossReferences(); 357 if (result == null) 358 { 359 eBasicProperties().setECrossReferences(result = new ECrossReferenceEList(this)); 360 } 361 362 return result; 363 } 364 365 public TreeIterator eAllContents() 366 { 367 return 368 new AbstractTreeIterator(this, false) 369 { 370 public Iterator getChildren(Object object) 371 { 372 return ((EObject)object).eContents().iterator(); 373 } 374 }; 375 } 376 377 public EReference eContainmentFeature() 378 { 379 EObject eContainer = eContainer(); 380 if (eContainer == null) 381 { 382 return null; 383 } 384 else 385 { 386 int eContainerFeatureID = eContainerFeatureID(); 387 if (eContainerFeatureID <= EOPPOSITE_FEATURE_BASE) 388 { 389 EStructuralFeature eFeature = eContainer.eClass().getEStructuralFeature(EOPPOSITE_FEATURE_BASE - eContainerFeatureID); 390 if (eFeature instanceof EReference) 391 { 392 return (EReference)eFeature; 393 } 394 else 395 { 396 FeatureMap featureMap = (FeatureMap)eContainer.eGet(eFeature); 397 for (int i = 0, size = featureMap.size(); i < size; ++i) 398 { 399 if (featureMap.getValue(i) == this) 400 { 401 EStructuralFeature entryFeature = featureMap.getEStructuralFeature(i); 402 if (entryFeature instanceof EReference) 403 { 404 EReference entryReference = (EReference)entryFeature; 405 if (entryReference.isContainment()) 406 { 407 return entryReference; 408 } 409 } 410 } 411 } 412 throw new IllegalStateException ("The containment feature could not be located"); 413 } 414 } 415 else 416 { 417 return ((EReference)eClass().getEStructuralFeature(eContainerFeatureID)).getEOpposite(); 418 } 419 } 420 } 421 422 public EStructuralFeature eContainingFeature() 423 { 424 EObject eContainer = eContainer(); 425 if (eContainer == null) 426 { 427 return null; 428 } 429 else 430 { 431 int eContainerFeatureID = eContainerFeatureID(); 432 return 433 eContainerFeatureID <= EOPPOSITE_FEATURE_BASE ? 434 eContainer.eClass().getEStructuralFeature(EOPPOSITE_FEATURE_BASE - eContainerFeatureID) : 435 ((EReference)eClass().getEStructuralFeature(eContainerFeatureID)).getEOpposite(); 436 } 437 } 438 439 protected Resource.Internal eDirectResource() 440 { 441 return eBasicProperties() == null ? null : eBasicProperties().getEResource(); 442 } 443 444 public Resource eResource() 445 { 446 return eInternalResource(); 447 } 448 449 public Resource.Internal eInternalResource() 450 { 451 Resource.Internal result = eDirectResource(); 452 if (result == null) 453 { 454 InternalEObject eContainer = eInternalContainer(); 455 if (eContainer != null) 456 { 457 result = eContainer.eInternalResource(); 458 } 459 } 460 return result; 461 } 462 463 public NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications) 464 { 465 Resource oldResource = eDirectResource(); 466 if (oldResource != null) 467 { 468 notifications = ((InternalEList)oldResource.getContents()).basicRemove(this, notifications); 469 } 470 else if (eContainer() != null) 471 { 472 notifications = eBasicRemoveFromContainer(notifications); 473 notifications = eBasicSetContainer(null, -1, notifications); 474 } 475 476 eProperties().setEResource(resource); 477 478 return notifications; 479 } 480 481 public Object eGet(EStructuralFeature eFeature) 482 { 483 return eGet(eFeature, true); 484 } 485 486 public Object eGet(EStructuralFeature eFeature, boolean resolve) 487 { 488 return eDynamicGet(eFeature, resolve); 489 } 490 491 public Object eDynamicGet(EStructuralFeature eFeature, boolean resolve) 492 { 493 int dynamicFeatureID = eDynamicFeatureID(eFeature); 494 return 495 dynamicFeatureID <= -1 ? 496 eOpenGet(eFeature, resolve) : 497 eSettingDelegate(eFeature).dynamicGet(this, eSettings(), dynamicFeatureID, resolve); 498 } 499 500 public Object eOpenGet(EStructuralFeature eFeature, boolean resolve) 501 { 502 EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); 503 if (openFeature != null) 504 { 505 if (!FeatureMapUtil.isFeatureMap(openFeature)) 506 { 507 openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); 508 } 509 FeatureMap featureMap = (FeatureMap)eGet(openFeature); 510 return ((FeatureMap.Internal)featureMap).get(eFeature, resolve); 511 } 512 else 513 { 514 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid feature"); 515 } 516 } 517 518 public void eSet(EStructuralFeature eFeature, Object newValue) 519 { 520 eDynamicSet(eFeature, newValue); 521 } 522 523 public void eDynamicSet(EStructuralFeature eFeature, Object newValue) 524 { 525 if (!eFeature.isChangeable()) 526 { 527 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); 528 } 529 int dynamicFeatureID = eDynamicFeatureID(eFeature); 530 if (dynamicFeatureID <= -1) 531 { 532 eOpenSet(eFeature, newValue); 533 } 534 else 535 { 536 eSettingDelegate(eFeature).dynamicSet(this, eSettings(), dynamicFeatureID, newValue); 537 } 538 } 539 540 public void eOpenSet(EStructuralFeature eFeature, Object newValue) 541 { 542 EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); 543 if (openFeature != null) 544 { 545 if (!FeatureMapUtil.isFeatureMap(openFeature)) 546 { 547 openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); 548 } 549 FeatureMap featureMap = (FeatureMap)eGet(openFeature); 550 ((FeatureMap.Internal)featureMap).set(eFeature, newValue); 551 } 552 else 553 { 554 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); 555 } 556 } 557 558 public void eUnset(EStructuralFeature eFeature) 559 { 560 eDynamicUnset(eFeature); 561 } 562 563 public void eDynamicUnset(EStructuralFeature eFeature) 564 { 565 if (!eFeature.isChangeable()) 566 { 567 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); 568 } 569 int dynamicFeatureID = eDynamicFeatureID(eFeature); 570 if (dynamicFeatureID <= -1) 571 { 572 eOpenUnset(eFeature); 573 } 574 else 575 { 576 eSettingDelegate(eFeature).dynamicUnset(this, eSettings(), dynamicFeatureID); 577 } 578 } 579 580 public void eOpenUnset(EStructuralFeature eFeature) 581 { 582 EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); 583 if (openFeature != null) 584 { 585 if (!FeatureMapUtil.isFeatureMap(openFeature)) 586 { 587 openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); 588 } 589 FeatureMap featureMap = (FeatureMap)eGet(openFeature); 590 ((FeatureMap.Internal)featureMap).unset(eFeature); 591 } 592 else 593 { 594 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); 595 } 596 } 597 598 public boolean eIsSet(EStructuralFeature eFeature) 599 { 600 return eDynamicIsSet(eFeature); 601 } 602 603 public boolean eDynamicIsSet(EStructuralFeature eFeature) 604 { 605 int dynamicFeatureID = eDynamicFeatureID(eFeature); 606 return 607 dynamicFeatureID <= -1 ? 608 eOpenIsSet(eFeature) : 609 eHasSettings() && eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), dynamicFeatureID); 610 } 611 612 public boolean eOpenIsSet(EStructuralFeature eFeature) 613 { 614 EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); 615 if (openFeature != null) 616 { 617 if (!FeatureMapUtil.isFeatureMap(openFeature)) 618 { 619 openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); 620 } 621 FeatureMap featureMap = (FeatureMap)eGet(openFeature); 622 return ((FeatureMap.Internal)featureMap).isSet(eFeature); 623 } 624 else 625 { 626 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid feature"); 627 } 628 } 629 630 public NotificationChain eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID, NotificationChain msgs) 631 { 632 Resource.Internal oldResource = this.eDirectResource(); 633 if (oldResource != null) 634 { 635 msgs = ((InternalEList)oldResource.getContents()).basicRemove(this, msgs); 636 eBasicProperties().setEResource(oldResource = null); 637 } 638 else 639 { 640 oldResource = this.eInternalResource(); 641 } 642 643 Resource.Internal newResource = newContainer == null ? null : newContainer.eInternalResource(); 644 if (oldResource != newResource && oldResource != null) 645 { 646 oldResource.detached(this); 647 } 648 649 EObject oldContainer = eContainer(); 650 int oldContainerFeatureID = eContainerFeatureID(); 651 eBasicSetContainer(newContainer, newContainerFeatureID); 652 653 if (oldResource != newResource && newResource != null) 654 { 655 newResource.attached(this); 656 } 657 658 if (eNotificationRequired()) 659 { 660 if (msgs == null) msgs = new NotificationChainImpl(4); 661 if (oldContainer != null && oldContainerFeatureID >=0 && oldContainerFeatureID != newContainerFeatureID) 662 { 663 msgs.add 664 (new ENotificationImpl 665 (this, 666 Notification.SET, 667 oldContainerFeatureID, 668 oldContainer, 669 null)); 670 } 671 if (newContainerFeatureID >= 0) 672 { 673 msgs.add 674 (new ENotificationImpl 675 (this, 676 Notification.SET, 677 newContainerFeatureID, 678 oldContainerFeatureID == newContainerFeatureID ? oldContainer : null, 679 newContainer)); 680 } 681 } 682 return msgs; 683 } 684 685 public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) 686 { 687 int eContainerFeatureID = eContainerFeatureID(); 688 if (eContainerFeatureID >= 0) 689 { 690 return eDynamicBasicRemoveFromContainer(msgs); 691 } 692 else 693 { 694 return eInternalContainer().eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); 695 } 696 } 697 698 public NotificationChain eDynamicBasicRemoveFromContainer(NotificationChain msgs) 699 { 700 EReference inverseFeature = ((EReference)eClass().getEStructuralFeature(eContainerFeatureID())).getEOpposite(); 701 return eInternalContainer().eInverseRemove(this, inverseFeature.getFeatureID(), inverseFeature.getContainerClass(), msgs); 702 } 703 704 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 705 { 706 if (featureID >= 0) 707 { 708 return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); 709 } 710 else 711 { 712 if (eContainer() != null) 713 { 714 msgs = eBasicRemoveFromContainer(msgs); 715 } 716 return eBasicSetContainer(otherEnd, featureID, msgs); 717 } 718 } 719 720 public NotificationChain eDynamicInverseAdd(InternalEObject otherEnd, int featureID, Class inverseClass, NotificationChain msgs) 721 { 722 EStructuralFeature.Internal feature = (EStructuralFeature.Internal)eClass().getEStructuralFeature(featureID); 723 return 724 feature.getSettingDelegate().dynamicInverseAdd 725 (this, eSettings(), featureID - eStaticFeatureCount(), otherEnd, msgs); 726 } 727 728 729 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 730 { 731 if (featureID >= 0) 732 { 733 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 734 } 735 else 736 { 737 return eBasicSetContainer(null, featureID, msgs); 738 } 739 } 740 741 public NotificationChain eDynamicInverseRemove(InternalEObject otherEnd, int featureID, Class inverseClass, NotificationChain msgs) 742 { 743 EStructuralFeature.Internal feature = (EStructuralFeature.Internal)eClass().getEStructuralFeature(featureID); 744 return feature.getSettingDelegate().dynamicInverseRemove 745 (this, eSettings(), featureID - eStaticFeatureCount(), otherEnd, msgs); 746 } 747 748 public URI eProxyURI() 749 { 750 return eBasicProperties() == null ? null : eBasicProperties().getEProxyURI(); 751 } 752 753 public void eSetProxyURI(URI uri) 754 { 755 eProperties().setEProxyURI(uri); 756 } 757 758 public EObject eResolveProxy(InternalEObject proxy) 759 { 760 return EcoreUtil.resolve(proxy, this); 761 } 762 763 public boolean eIsProxy() 764 { 765 return eBasicProperties() != null && eBasicProperties().getEProxyURI() != null; 766 } 767 768 public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) 769 { 770 return derivedFeatureID; 771 } 772 773 public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) 774 { 775 return baseFeatureID; 776 } 777 778 public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) 779 { 780 Class containerClass = eStructuralFeature.getContainerClass(); 781 return 782 containerClass == null ? 783 eClass().getFeatureID(eStructuralFeature) : 784 eDerivedStructuralFeatureID(eStructuralFeature.getFeatureID(), containerClass); 785 } 786 787 public EClass eClass() 788 { 789 if (eBasicProperties() != null) 790 { 791 EClass result = eBasicProperties().getEClass(); 792 if (result != null) 793 { 794 return result; 795 } 796 } 797 return eStaticClass(); 798 } 799 800 protected EClass eStaticClass() 802 { 803 return EcorePackage.eINSTANCE.getEObject(); 804 } 805 806 protected EClass eDynamicClass() 807 { 808 return 809 eBasicProperties() == null ? 810 null : 811 eBasicProperties().getEClass(); 812 813 } 814 815 public void eSetClass(EClass eClass) 816 { 817 eProperties().setEClass(eClass); 818 } 819 820 protected EStructuralFeature.Internal.SettingDelegate eSettingDelegate(EStructuralFeature eFeature) 821 { 822 return ((EStructuralFeature.Internal)eFeature).getSettingDelegate(); 823 } 824 825 public EStructuralFeature.Setting eSetting(final EStructuralFeature eFeature) 826 { 827 int index = eClass().getFeatureID(eFeature); 828 int dynamicIndex = eStaticFeatureCount(); 829 if (index >= dynamicIndex) 830 { 831 return eSettingDelegate(eFeature).dynamicSetting(this, eSettings(), index - dynamicIndex); 832 } 833 else if (index <= -1) 834 { 835 throw new IllegalArgumentException ("The feature '" + eFeature.getName() + "' is not a valid feature"); 836 } 837 else if (eFeature.isMany()) 838 { 839 return (EStructuralFeature.Setting)eGet(eFeature, false); 840 } 841 else 842 { 843 EStructuralFeature.Setting setting = 844 new EStructuralFeature.Setting() 845 { 846 public EObject getEObject() 847 { 848 return BasicEObjectImpl.this; 849 } 850 851 public EStructuralFeature getEStructuralFeature() 852 { 853 return eFeature; 854 } 855 856 public Object get(boolean resolve) 857 { 858 return BasicEObjectImpl.this.eGet(eFeature, resolve); 859 } 860 861 public void set(Object newValue) 862 { 863 BasicEObjectImpl.this.eSet(eFeature, newValue); 864 } 865 866 public boolean isSet() 867 { 868 return BasicEObjectImpl.this.eIsSet(eFeature); 869 } 870 871 public void unset() 872 { 873 BasicEObjectImpl.this.eUnset(eFeature); 874 } 875 }; 876 return setting; 877 } 878 } 879 880 public InternalEObject.EStore eStore() 881 { 882 return null; 883 } 884 885 public void eSetStore(InternalEObject.EStore store) 886 { 887 throw new UnsupportedOperationException (); 888 } 889 890 public String toString() 891 { 892 895 StringBuffer result = new StringBuffer (getClass().getName()); 896 result.append('@'); 897 result.append(Integer.toHexString(hashCode())); 898 899 if (eIsProxy()) 900 { 901 result.append(" (eProxyURI: "); 902 result.append(eProxyURI()); 903 if (eDynamicClass() != null) 904 { 905 result.append(" eClass: "); 906 result.append(eDynamicClass()); 907 } 908 result.append(')'); 909 } 910 else if (eDynamicClass() != null) 911 { 912 result.append(" (eClass: "); 913 result.append(eDynamicClass()); 914 result.append(')'); 915 } 916 917 return result.toString(); 918 } 919 } 920 | Popular Tags |