001/** 002 * <copyright> 003 * </copyright> 004 * 005 * $Id$ 006 */ 007package com.hammurapi.resource.xadisk.impl; 008 009import java.util.Collection; 010import java.util.Collections; 011 012import org.eclipse.emf.common.notify.Notification; 013import org.eclipse.emf.common.notify.NotificationChain; 014import org.eclipse.emf.common.notify.Notifier; 015import org.eclipse.emf.common.util.EList; 016import org.eclipse.emf.ecore.EClass; 017import org.eclipse.emf.ecore.InternalEObject; 018import org.eclipse.emf.ecore.impl.ENotificationImpl; 019import org.eclipse.emf.ecore.impl.EObjectImpl; 020import org.eclipse.emf.ecore.util.EContentAdapter; 021import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; 022import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; 023import org.eclipse.emf.ecore.util.EcoreUtil; 024import org.eclipse.emf.ecore.util.InternalEList; 025import org.xadisk.additional.XAFileInputStreamWrapper; 026import org.xadisk.additional.XAFileOutputStreamWrapper; 027import org.xadisk.bridge.proxies.interfaces.XAFileInputStream; 028import org.xadisk.bridge.proxies.interfaces.XAFileOutputStream; 029import org.xadisk.bridge.proxies.interfaces.XASession; 030 031import com.hammurapi.common.Context; 032import com.hammurapi.convert.ConversionException; 033import com.hammurapi.convert.Converter; 034import com.hammurapi.party.PartyPackage; 035import com.hammurapi.party.Role; 036import com.hammurapi.resource.CompositeResource; 037import com.hammurapi.resource.GenericResource; 038import com.hammurapi.resource.Resource; 039import com.hammurapi.resource.ResourceException; 040import com.hammurapi.resource.ResourcePackage; 041import com.hammurapi.resource.file.impl.FileImpl; 042import com.hammurapi.resource.impl.LookupHelper; 043import com.hammurapi.resource.impl.ResourceConverter; 044import com.hammurapi.resource.xadisk.XAFile; 045import com.hammurapi.resource.xadisk.XadiskPackage; 046 047/** 048 * <!-- begin-user-doc --> 049 * An implementation of the model object '<em><b>XA File</b></em>'. 050 * <!-- end-user-doc --> 051 * <p> 052 * The following features are implemented: 053 * <ul> 054 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getRoles <em>Roles</em>}</li> 055 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getParent <em>Parent</em>}</li> 056 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getName <em>Name</em>}</li> 057 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getDescription <em>Description</em>}</li> 058 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getAbsoluteName <em>Absolute Name</em>}</li> 059 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getFilteredResource <em>Filtered Resource</em>}</li> 060 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getAbsolutePath <em>Absolute Path</em>}</li> 061 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#isDirty <em>Dirty</em>}</li> 062 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getContent <em>Content</em>}</li> 063 * <li>{@link com.hammurapi.resource.xadisk.impl.XAFileImpl#getConverters <em>Converters</em>}</li> 064 * </ul> 065 * </p> 066 * 067 * @generated 068 */ 069public class XAFileImpl extends EObjectImpl implements XAFile { 070 /** 071 * The cached value of the '{@link #getRoles() <em>Roles</em>}' containment reference list. 072 * <!-- begin-user-doc --> 073 * <!-- end-user-doc --> 074 * @see #getRoles() 075 * @generated 076 * @ordered 077 */ 078 protected EList<Role> roles; 079 080 /** 081 * The default value of the '{@link #getName() <em>Name</em>}' attribute. 082 * <!-- begin-user-doc --> 083 * <!-- end-user-doc --> 084 * @see #getName() 085 * @generated 086 * @ordered 087 */ 088 protected static final String NAME_EDEFAULT = null; 089 090 /** 091 * The cached value of the '{@link #getName() <em>Name</em>}' attribute. 092 * <!-- begin-user-doc --> 093 * <!-- end-user-doc --> 094 * @see #getName() 095 * @generated 096 * @ordered 097 */ 098 protected String name = NAME_EDEFAULT; 099 100 /** 101 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute. 102 * <!-- begin-user-doc --> 103 * <!-- end-user-doc --> 104 * @see #getDescription() 105 * @generated 106 * @ordered 107 */ 108 protected static final String DESCRIPTION_EDEFAULT = null; 109 110 /** 111 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute. 112 * <!-- begin-user-doc --> 113 * <!-- end-user-doc --> 114 * @see #getDescription() 115 * @generated 116 * @ordered 117 */ 118 protected String description = DESCRIPTION_EDEFAULT; 119 120 /** 121 * The default value of the '{@link #getAbsoluteName() <em>Absolute Name</em>}' attribute. 122 * <!-- begin-user-doc --> 123 * <!-- end-user-doc --> 124 * @see #getAbsoluteName() 125 * @generated 126 * @ordered 127 */ 128 protected static final String ABSOLUTE_NAME_EDEFAULT = null; 129 130 /** 131 * The cached value of the '{@link #getFilteredResource() <em>Filtered Resource</em>}' containment reference. 132 * <!-- begin-user-doc --> 133 * <!-- end-user-doc --> 134 * @see #getFilteredResource() 135 * @generated 136 * @ordered 137 */ 138 protected Resource filteredResource; 139 140 /** 141 * The default value of the '{@link #getAbsolutePath() <em>Absolute Path</em>}' attribute. 142 * <!-- begin-user-doc --> 143 * <!-- end-user-doc --> 144 * @see #getAbsolutePath() 145 * @generated 146 * @ordered 147 */ 148 protected static final String ABSOLUTE_PATH_EDEFAULT = null; 149 150 /** 151 * The cached value of the '{@link #getAbsolutePath() <em>Absolute Path</em>}' attribute. 152 * <!-- begin-user-doc --> 153 * <!-- end-user-doc --> 154 * @see #getAbsolutePath() 155 * @generated 156 * @ordered 157 */ 158 protected String absolutePath = ABSOLUTE_PATH_EDEFAULT; 159 160 /** 161 * The default value of the '{@link #isDirty() <em>Dirty</em>}' attribute. 162 * <!-- begin-user-doc --> 163 * <!-- end-user-doc --> 164 * @see #isDirty() 165 * @generated 166 * @ordered 167 */ 168 protected static final boolean DIRTY_EDEFAULT = false; 169 170 /** 171 * The cached value of the '{@link #isDirty() <em>Dirty</em>}' attribute. 172 * <!-- begin-user-doc --> 173 * <!-- end-user-doc --> 174 * @see #isDirty() 175 * @generated 176 * @ordered 177 */ 178 protected boolean dirty = DIRTY_EDEFAULT; 179 180 /** 181 * The default value of the '{@link #getContent() <em>Content</em>}' attribute. 182 * <!-- begin-user-doc --> 183 * <!-- end-user-doc --> 184 * @see #getContent() 185 * @generated 186 * @ordered 187 */ 188 protected static final Object CONTENT_EDEFAULT = null; 189 190 /** 191 * The cached value of the '{@link #getContent() <em>Content</em>}' attribute. 192 * <!-- begin-user-doc --> 193 * <!-- end-user-doc --> 194 * @see #getContent() 195 * @generated 196 * @ordered 197 */ 198 protected Object content = CONTENT_EDEFAULT; 199 200 /** 201 * The cached value of the '{@link #getConverters() <em>Converters</em>}' attribute list. 202 * <!-- begin-user-doc --> 203 * <!-- end-user-doc --> 204 * @see #getConverters() 205 * @generated 206 * @ordered 207 */ 208 protected EList<Converter> converters; 209 210 private Context context; 211 212 private Object source; 213 214 /** 215 * <!-- begin-user-doc --> 216 * <!-- end-user-doc --> 217 * @generated 218 */ 219 protected XAFileImpl() { 220 super(); 221 } 222 223 /** 224 * <!-- begin-user-doc --> 225 * <!-- end-user-doc --> 226 * @generated 227 */ 228 @Override 229 protected EClass eStaticClass() { 230 return XadiskPackage.Literals.XA_FILE; 231 } 232 233 /** 234 * <!-- begin-user-doc --> 235 * <!-- end-user-doc --> 236 * @generated 237 */ 238 public EList<Role> getRoles() { 239 if (roles == null) { 240 roles = new EObjectContainmentWithInverseEList<Role>(Role.class, this, XadiskPackage.XA_FILE__ROLES, PartyPackage.ROLE__OWNER); 241 } 242 return roles; 243 } 244 245 /** 246 * <!-- begin-user-doc --> 247 * <!-- end-user-doc --> 248 * @generated 249 */ 250 public CompositeResource getParent() { 251 if (eContainerFeatureID() != XadiskPackage.XA_FILE__PARENT) return null; 252 return (CompositeResource)eContainer(); 253 } 254 255 /** 256 * <!-- begin-user-doc --> 257 * <!-- end-user-doc --> 258 * @generated 259 */ 260 public NotificationChain basicSetParent(CompositeResource newParent, NotificationChain msgs) { 261 msgs = eBasicSetContainer((InternalEObject)newParent, XadiskPackage.XA_FILE__PARENT, msgs); 262 return msgs; 263 } 264 265 /** 266 * <!-- begin-user-doc --> 267 * <!-- end-user-doc --> 268 * @generated 269 */ 270 public void setParent(CompositeResource newParent) { 271 if (newParent != eInternalContainer() || (eContainerFeatureID() != XadiskPackage.XA_FILE__PARENT && newParent != null)) { 272 if (EcoreUtil.isAncestor(this, newParent)) 273 throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); 274 NotificationChain msgs = null; 275 if (eInternalContainer() != null) 276 msgs = eBasicRemoveFromContainer(msgs); 277 if (newParent != null) 278 msgs = ((InternalEObject)newParent).eInverseAdd(this, ResourcePackage.COMPOSITE_RESOURCE__CHILDREN, CompositeResource.class, msgs); 279 msgs = basicSetParent(newParent, msgs); 280 if (msgs != null) msgs.dispatch(); 281 } 282 else if (eNotificationRequired()) 283 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__PARENT, newParent, newParent)); 284 } 285 286 /** 287 * <!-- begin-user-doc --> 288 * <!-- end-user-doc --> 289 * @generated 290 */ 291 public String getName() { 292 return name; 293 } 294 295 /** 296 * <!-- begin-user-doc --> 297 * <!-- end-user-doc --> 298 * @generated 299 */ 300 public void setName(String newName) { 301 String oldName = name; 302 name = newName; 303 if (eNotificationRequired()) 304 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__NAME, oldName, name)); 305 } 306 307 /** 308 * <!-- begin-user-doc --> 309 * <!-- end-user-doc --> 310 * @generated 311 */ 312 public String getDescription() { 313 return description; 314 } 315 316 /** 317 * <!-- begin-user-doc --> 318 * <!-- end-user-doc --> 319 * @generated 320 */ 321 public void setDescription(String newDescription) { 322 String oldDescription = description; 323 description = newDescription; 324 if (eNotificationRequired()) 325 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__DESCRIPTION, oldDescription, description)); 326 } 327 328 /** 329 * <!-- begin-user-doc --> 330 * <!-- end-user-doc --> 331 * @generated NOT 332 */ 333 public String getAbsoluteName() { 334 return getParent()==null ? getName() : getParent().getAbsoluteName()+"/"+getName(); 335 } 336 337 /** 338 * <!-- begin-user-doc --> 339 * <!-- end-user-doc --> 340 * @generated 341 */ 342 public Resource getFilteredResource() { 343 return filteredResource; 344 } 345 346 /** 347 * <!-- begin-user-doc --> 348 * <!-- end-user-doc --> 349 * @generated 350 */ 351 public NotificationChain basicSetFilteredResource(Resource newFilteredResource, NotificationChain msgs) { 352 Resource oldFilteredResource = filteredResource; 353 filteredResource = newFilteredResource; 354 if (eNotificationRequired()) { 355 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__FILTERED_RESOURCE, oldFilteredResource, newFilteredResource); 356 if (msgs == null) msgs = notification; else msgs.add(notification); 357 } 358 return msgs; 359 } 360 361 /** 362 * <!-- begin-user-doc --> 363 * <!-- end-user-doc --> 364 * @generated 365 */ 366 public void setFilteredResource(Resource newFilteredResource) { 367 if (newFilteredResource != filteredResource) { 368 NotificationChain msgs = null; 369 if (filteredResource != null) 370 msgs = ((InternalEObject)filteredResource).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XadiskPackage.XA_FILE__FILTERED_RESOURCE, null, msgs); 371 if (newFilteredResource != null) 372 msgs = ((InternalEObject)newFilteredResource).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XadiskPackage.XA_FILE__FILTERED_RESOURCE, null, msgs); 373 msgs = basicSetFilteredResource(newFilteredResource, msgs); 374 if (msgs != null) msgs.dispatch(); 375 } 376 else if (eNotificationRequired()) 377 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__FILTERED_RESOURCE, newFilteredResource, newFilteredResource)); 378 } 379 380 /** 381 * <!-- begin-user-doc --> 382 * <!-- end-user-doc --> 383 * @generated 384 */ 385 public String getAbsolutePath() { 386 return absolutePath; 387 } 388 389 /** 390 * <!-- begin-user-doc --> 391 * <!-- end-user-doc --> 392 * @generated 393 */ 394 public void setAbsolutePath(String newAbsolutePath) { 395 String oldAbsolutePath = absolutePath; 396 absolutePath = newAbsolutePath; 397 if (eNotificationRequired()) 398 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__ABSOLUTE_PATH, oldAbsolutePath, absolutePath)); 399 } 400 401 /** 402 * <!-- begin-user-doc --> 403 * <!-- end-user-doc --> 404 * @generated 405 */ 406 public boolean isDirty() { 407 return dirty; 408 } 409 410 /** 411 * <!-- begin-user-doc --> 412 * <!-- end-user-doc --> 413 * @generated 414 */ 415 public void setDirty(boolean newDirty) { 416 boolean oldDirty = dirty; 417 dirty = newDirty; 418 if (eNotificationRequired()) 419 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__DIRTY, oldDirty, dirty)); 420 } 421 422 /** 423 * <!-- begin-user-doc --> 424 * <!-- end-user-doc --> 425 * @generated 426 */ 427 public Object getContent() { 428 return content; 429 } 430 431 /** 432 * <!-- begin-user-doc --> 433 * <!-- end-user-doc --> 434 * @generated 435 */ 436 public void setContent(Object newContent) { 437 Object oldContent = content; 438 content = newContent; 439 if (eNotificationRequired()) 440 eNotify(new ENotificationImpl(this, Notification.SET, XadiskPackage.XA_FILE__CONTENT, oldContent, content)); 441 } 442 443 /** 444 * <!-- begin-user-doc --> 445 * <!-- end-user-doc --> 446 * @generated 447 */ 448 public EList<Converter> getConverters() { 449 if (converters == null) { 450 converters = new EDataTypeUniqueEList<Converter>(Converter.class, this, XadiskPackage.XA_FILE__CONVERTERS); 451 } 452 return converters; 453 } 454 455 /** 456 * <!-- begin-user-doc --> 457 * <!-- end-user-doc --> 458 * @generated NOT 459 */ 460 public void open(Context context) { 461 this.context = context; 462 if (getFilteredResource()!=null) { 463 getFilteredResource().open(context); 464 } 465 } 466 467 /** 468 * <!-- begin-user-doc --> 469 * <!-- end-user-doc --> 470 * @generated NOT 471 */ 472 public void load(Object source) { 473 if (source==null && getAbsolutePath()!=null && getAbsolutePath().trim().length()>0) { 474 source = new java.io.File(getAbsolutePath()); 475 } 476 this.source = source; 477 setContent(source); 478 setDirty(false); 479 if (getFilteredResource()!=null) { 480 getFilteredResource().load(this); 481 } 482 } 483 484 /** 485 * <!-- begin-user-doc --> 486 * <!-- end-user-doc --> 487 * @generated NOT 488 */ 489 public void save(Object target) { 490 if (!isDirty()) { 491 return; 492 } 493 494 if (target==null && getAbsolutePath()!=null && getAbsolutePath().trim().length()>0) { 495 target = new java.io.File(getAbsolutePath()); 496 } 497 498 if (target instanceof java.io.File) { 499 if (getFilteredResource()!=null) { 500 getFilteredResource().save(this); 501 } 502 503 XASession xaSession = context.lookup(XASession.class); 504 try { 505 java.io.File fTarget = (java.io.File) target; 506 if (xaSession.fileExists(fTarget)) { 507 xaSession.truncateFile(fTarget, 0); 508 } else { 509 xaSession.createFile(fTarget, false); 510 } 511 512 XAFileOutputStream xafos = xaSession.createXAFileOutputStream(fTarget, true); 513 XAFileOutputStreamWrapper wxafos = new XAFileOutputStreamWrapper(xafos); 514 try { 515 converter.save(getContent(), wxafos, context); 516 } finally { 517 wxafos.close(); 518 } 519 setDirty(false); 520 } catch (ResourceException e) { 521 throw e; 522 } catch (Exception e) { 523 throw new ResourceException(e); 524 } 525 526 } else { 527 throw new ResourceException("Cannot save to "+target); 528 } 529 } 530 531 /** 532 * <!-- begin-user-doc --> 533 * <!-- end-user-doc --> 534 * @generated NOT 535 */ 536 public void delete() { 537 if (getFilteredResource()!=null) { 538 getFilteredResource().delete(); 539 } 540 541 if (source instanceof java.io.File) { 542 XASession xaSession = context.lookup(XASession.class); 543 try { 544 if (xaSession.fileExists((java.io.File) source)) { 545 xaSession.deleteFile((java.io.File) source); 546 } 547 } catch (Exception e) { 548 throw new ResourceException(e); 549 } 550 } 551 } 552 553 /** 554 * <!-- begin-user-doc --> 555 * <!-- end-user-doc --> 556 * @generated NOT 557 */ 558 public void close() { 559 if (getFilteredResource()!=null) { 560 getFilteredResource().close(); 561 } 562 } 563 564 private ResourceConverter converter = new ResourceConverter(this) { 565 566 public <S, T> T convert(S source, Class<T> targetType, Context context) throws ConversionException { 567 Object theSource = source; 568 569 // If source is File then convert it to input stream with XASession before further conversion. 570 if (source instanceof java.io.File) { 571 XASession xaSession = context.lookup(XASession.class); 572 try { 573 XAFileInputStream xafis = xaSession.createXAFileInputStream((java.io.File) source, false); 574 theSource = new XAFileInputStreamWrapper(xafis); 575 } catch (Exception e) { 576 throw new ConversionException(e); 577 } 578 } 579 580 return super.convert(theSource, targetType, context); 581 }; 582 }; 583 584 /** 585 * <!-- begin-user-doc --> 586 * <!-- end-user-doc --> 587 * @generated NOT 588 */ 589 public <T> T getContentAs(Class<T> type) { 590 boolean wasDirty = isDirty(); 591 592 if (getContent()==null) { 593 return null; 594 } 595 596 T newContentFormat = converter.convert(getContent(), type, context); 597 if (newContentFormat==null) { 598 throw new ConversionException("Cannot convert from "+getContent()+" to "+type); 599 } 600 if (!FileImpl.isStream(newContentFormat)) { 601 setContent(newContentFormat); 602 if (newContentFormat instanceof Notifier) { 603 ((Notifier) newContentFormat).eAdapters().add(new EContentAdapter() { 604 605 @Override 606 public void notifyChanged(Notification notification) { 607 super.notifyChanged(notification); 608 if (notification.getEventType()!=Notification.REMOVING_ADAPTER && notification.getEventType()!=Notification.RESOLVE) { 609 setDirty(true); 610 } 611 } 612 }); 613 } 614 setDirty(wasDirty); 615 } 616 return newContentFormat; 617 } 618 619 /** 620 * <!-- begin-user-doc --> 621 * <!-- end-user-doc --> 622 * @generated 623 */ 624 @SuppressWarnings("unchecked") 625 @Override 626 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 627 switch (featureID) { 628 case XadiskPackage.XA_FILE__ROLES: 629 return ((InternalEList<InternalEObject>)(InternalEList<?>)getRoles()).basicAdd(otherEnd, msgs); 630 case XadiskPackage.XA_FILE__PARENT: 631 if (eInternalContainer() != null) 632 msgs = eBasicRemoveFromContainer(msgs); 633 return basicSetParent((CompositeResource)otherEnd, msgs); 634 } 635 return super.eInverseAdd(otherEnd, featureID, msgs); 636 } 637 638 /** 639 * <!-- begin-user-doc --> 640 * <!-- end-user-doc --> 641 * @generated 642 */ 643 @Override 644 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { 645 switch (featureID) { 646 case XadiskPackage.XA_FILE__ROLES: 647 return ((InternalEList<?>)getRoles()).basicRemove(otherEnd, msgs); 648 case XadiskPackage.XA_FILE__PARENT: 649 return basicSetParent(null, msgs); 650 case XadiskPackage.XA_FILE__FILTERED_RESOURCE: 651 return basicSetFilteredResource(null, msgs); 652 } 653 return super.eInverseRemove(otherEnd, featureID, msgs); 654 } 655 656 /** 657 * <!-- begin-user-doc --> 658 * <!-- end-user-doc --> 659 * @generated 660 */ 661 @Override 662 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { 663 switch (eContainerFeatureID()) { 664 case XadiskPackage.XA_FILE__PARENT: 665 return eInternalContainer().eInverseRemove(this, ResourcePackage.COMPOSITE_RESOURCE__CHILDREN, CompositeResource.class, msgs); 666 } 667 return super.eBasicRemoveFromContainerFeature(msgs); 668 } 669 670 /** 671 * <!-- begin-user-doc --> 672 * <!-- end-user-doc --> 673 * @generated 674 */ 675 @Override 676 public Object eGet(int featureID, boolean resolve, boolean coreType) { 677 switch (featureID) { 678 case XadiskPackage.XA_FILE__ROLES: 679 return getRoles(); 680 case XadiskPackage.XA_FILE__PARENT: 681 return getParent(); 682 case XadiskPackage.XA_FILE__NAME: 683 return getName(); 684 case XadiskPackage.XA_FILE__DESCRIPTION: 685 return getDescription(); 686 case XadiskPackage.XA_FILE__ABSOLUTE_NAME: 687 return getAbsoluteName(); 688 case XadiskPackage.XA_FILE__FILTERED_RESOURCE: 689 return getFilteredResource(); 690 case XadiskPackage.XA_FILE__ABSOLUTE_PATH: 691 return getAbsolutePath(); 692 case XadiskPackage.XA_FILE__DIRTY: 693 return isDirty(); 694 case XadiskPackage.XA_FILE__CONTENT: 695 return getContent(); 696 case XadiskPackage.XA_FILE__CONVERTERS: 697 return getConverters(); 698 } 699 return super.eGet(featureID, resolve, coreType); 700 } 701 702 /** 703 * <!-- begin-user-doc --> 704 * <!-- end-user-doc --> 705 * @generated 706 */ 707 @SuppressWarnings("unchecked") 708 @Override 709 public void eSet(int featureID, Object newValue) { 710 switch (featureID) { 711 case XadiskPackage.XA_FILE__ROLES: 712 getRoles().clear(); 713 getRoles().addAll((Collection<? extends Role>)newValue); 714 return; 715 case XadiskPackage.XA_FILE__PARENT: 716 setParent((CompositeResource)newValue); 717 return; 718 case XadiskPackage.XA_FILE__NAME: 719 setName((String)newValue); 720 return; 721 case XadiskPackage.XA_FILE__DESCRIPTION: 722 setDescription((String)newValue); 723 return; 724 case XadiskPackage.XA_FILE__FILTERED_RESOURCE: 725 setFilteredResource((Resource)newValue); 726 return; 727 case XadiskPackage.XA_FILE__ABSOLUTE_PATH: 728 setAbsolutePath((String)newValue); 729 return; 730 case XadiskPackage.XA_FILE__DIRTY: 731 setDirty((Boolean)newValue); 732 return; 733 case XadiskPackage.XA_FILE__CONTENT: 734 setContent(newValue); 735 return; 736 case XadiskPackage.XA_FILE__CONVERTERS: 737 getConverters().clear(); 738 getConverters().addAll((Collection<? extends Converter>)newValue); 739 return; 740 } 741 super.eSet(featureID, newValue); 742 } 743 744 /** 745 * <!-- begin-user-doc --> 746 * <!-- end-user-doc --> 747 * @generated 748 */ 749 @Override 750 public void eUnset(int featureID) { 751 switch (featureID) { 752 case XadiskPackage.XA_FILE__ROLES: 753 getRoles().clear(); 754 return; 755 case XadiskPackage.XA_FILE__PARENT: 756 setParent((CompositeResource)null); 757 return; 758 case XadiskPackage.XA_FILE__NAME: 759 setName(NAME_EDEFAULT); 760 return; 761 case XadiskPackage.XA_FILE__DESCRIPTION: 762 setDescription(DESCRIPTION_EDEFAULT); 763 return; 764 case XadiskPackage.XA_FILE__FILTERED_RESOURCE: 765 setFilteredResource((Resource)null); 766 return; 767 case XadiskPackage.XA_FILE__ABSOLUTE_PATH: 768 setAbsolutePath(ABSOLUTE_PATH_EDEFAULT); 769 return; 770 case XadiskPackage.XA_FILE__DIRTY: 771 setDirty(DIRTY_EDEFAULT); 772 return; 773 case XadiskPackage.XA_FILE__CONTENT: 774 setContent(CONTENT_EDEFAULT); 775 return; 776 case XadiskPackage.XA_FILE__CONVERTERS: 777 getConverters().clear(); 778 return; 779 } 780 super.eUnset(featureID); 781 } 782 783 /** 784 * <!-- begin-user-doc --> 785 * <!-- end-user-doc --> 786 * @generated 787 */ 788 @Override 789 public boolean eIsSet(int featureID) { 790 switch (featureID) { 791 case XadiskPackage.XA_FILE__ROLES: 792 return roles != null && !roles.isEmpty(); 793 case XadiskPackage.XA_FILE__PARENT: 794 return getParent() != null; 795 case XadiskPackage.XA_FILE__NAME: 796 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); 797 case XadiskPackage.XA_FILE__DESCRIPTION: 798 return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description); 799 case XadiskPackage.XA_FILE__ABSOLUTE_NAME: 800 return ABSOLUTE_NAME_EDEFAULT == null ? getAbsoluteName() != null : !ABSOLUTE_NAME_EDEFAULT.equals(getAbsoluteName()); 801 case XadiskPackage.XA_FILE__FILTERED_RESOURCE: 802 return filteredResource != null; 803 case XadiskPackage.XA_FILE__ABSOLUTE_PATH: 804 return ABSOLUTE_PATH_EDEFAULT == null ? absolutePath != null : !ABSOLUTE_PATH_EDEFAULT.equals(absolutePath); 805 case XadiskPackage.XA_FILE__DIRTY: 806 return dirty != DIRTY_EDEFAULT; 807 case XadiskPackage.XA_FILE__CONTENT: 808 return CONTENT_EDEFAULT == null ? content != null : !CONTENT_EDEFAULT.equals(content); 809 case XadiskPackage.XA_FILE__CONVERTERS: 810 return converters != null && !converters.isEmpty(); 811 } 812 return super.eIsSet(featureID); 813 } 814 815 /** 816 * <!-- begin-user-doc --> 817 * <!-- end-user-doc --> 818 * @generated 819 */ 820 @Override 821 public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { 822 if (baseClass == GenericResource.class) { 823 switch (derivedFeatureID) { 824 case XadiskPackage.XA_FILE__DIRTY: return ResourcePackage.GENERIC_RESOURCE__DIRTY; 825 case XadiskPackage.XA_FILE__CONTENT: return ResourcePackage.GENERIC_RESOURCE__CONTENT; 826 case XadiskPackage.XA_FILE__CONVERTERS: return ResourcePackage.GENERIC_RESOURCE__CONVERTERS; 827 default: return -1; 828 } 829 } 830 return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); 831 } 832 833 /** 834 * <!-- begin-user-doc --> 835 * <!-- end-user-doc --> 836 * @generated 837 */ 838 @Override 839 public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { 840 if (baseClass == GenericResource.class) { 841 switch (baseFeatureID) { 842 case ResourcePackage.GENERIC_RESOURCE__DIRTY: return XadiskPackage.XA_FILE__DIRTY; 843 case ResourcePackage.GENERIC_RESOURCE__CONTENT: return XadiskPackage.XA_FILE__CONTENT; 844 case ResourcePackage.GENERIC_RESOURCE__CONVERTERS: return XadiskPackage.XA_FILE__CONVERTERS; 845 default: return -1; 846 } 847 } 848 return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); 849 } 850 851 /** 852 * <!-- begin-user-doc --> 853 * <!-- end-user-doc --> 854 * @generated 855 */ 856 @Override 857 public String toString() { 858 if (eIsProxy()) return super.toString(); 859 860 StringBuffer result = new StringBuffer(super.toString()); 861 result.append(" (name: "); 862 result.append(name); 863 result.append(", description: "); 864 result.append(description); 865 result.append(", absolutePath: "); 866 result.append(absolutePath); 867 result.append(", dirty: "); 868 result.append(dirty); 869 result.append(", content: "); 870 result.append(content); 871 result.append(", converters: "); 872 result.append(converters); 873 result.append(')'); 874 return result.toString(); 875 } 876 877 private LookupHelper lookupHelper = new LookupHelper(this); 878 879 @Override 880 public Resource lookup(String path) { 881 return lookupHelper.lookup(path); 882 } 883 884 @Override 885 public Resource lookupOrCreate(String path, boolean isComposite) { 886 return lookupHelper.lookupOrCreate(path, isComposite); 887 } 888 889 @Override 890 public <T extends Resource> T lookup(Class<T> type) { 891 return lookupHelper.lookup(type); 892 } 893 894 @Override 895 public <T extends Resource> Collection<T> lookupAll(Class<T> type) { 896 return (Collection<T>) (type.isInstance(this) ? Collections.singleton((T) this) : Collections.emptySet()); 897 } 898 899 @Override 900 public void copyTo(Resource target) { 901 ((GenericResource) target).setContent(getContent()); 902 } 903 904} //XAFileImpl