1 17 package org.eclipse.emf.ecore.resource; 18 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.io.OutputStream ; 23 import java.io.PrintStream ; 24 import java.io.PrintWriter ; 25 import java.util.Map ; 26 27 import org.eclipse.emf.common.notify.NotificationChain; 28 import org.eclipse.emf.common.notify.Notifier; 29 import org.eclipse.emf.common.util.EList; 30 import org.eclipse.emf.common.util.TreeIterator; 31 import org.eclipse.emf.common.util.URI; 32 import org.eclipse.emf.ecore.EObject; 33 import org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl; 34 35 36 79 public interface Resource extends Notifier 80 { 81 84 int RESOURCE__RESOURCE_SET = 0; 85 86 89 int RESOURCE__URI = 1; 90 91 94 int RESOURCE__CONTENTS = 2; 95 96 99 int RESOURCE__IS_MODIFIED = 3; 100 101 104 int RESOURCE__IS_LOADED = 4; 105 106 109 int RESOURCE__IS_TRACKING_MODIFICATION = 5; 110 111 114 int RESOURCE__ERRORS = 6; 115 116 119 int RESOURCE__WARNINGS = 7; 120 121 132 ResourceSet getResourceSet(); 133 134 144 URI getURI(); 145 146 151 void setURI(URI uri); 152 153 166 EList getContents(); 167 168 175 TreeIterator getAllContents(); 176 177 196 String getURIFragment(EObject eObject); 197 198 199 212 EObject getEObject(String uriFragment); 213 214 230 void save(Map options) throws IOException ; 231 232 253 void load(Map options) throws IOException ; 254 255 265 void save(OutputStream outputStream, Map options) throws IOException ; 266 267 277 void load(InputStream inputStream, Map options) throws IOException ; 278 279 290 boolean isTrackingModification(); 291 292 299 void setTrackingModification(boolean isTrackingModification); 300 301 312 boolean isModified(); 313 314 323 void setModified(boolean isModified); 324 325 339 boolean isLoaded(); 340 341 353 void unload(); 354 355 364 EList getErrors(); 365 366 375 EList getWarnings(); 376 377 380 interface Diagnostic 381 { 382 386 String getMessage(); 387 388 393 String getLocation(); 394 395 400 int getLine(); 401 402 407 int getColumn(); 408 } 409 410 418 interface Factory 419 { 420 430 Resource createResource(URI uri); 431 432 439 interface Descriptor 440 { 441 449 Factory createFactory(); 450 } 451 452 470 interface Registry 471 { 472 486 Factory getFactory(URI uri); 487 488 494 Map getProtocolToFactoryMap(); 495 496 500 String DEFAULT_EXTENSION = "*"; 501 502 516 Map getExtensionToFactoryMap(); 517 518 525 Registry INSTANCE = new ResourceFactoryRegistryImpl(); 526 527 } 528 } 529 530 538 class IOWrappedException extends IOException 539 { 540 543 protected Exception exception; 544 545 549 public IOWrappedException(Exception exception) 550 { 551 super(exception.getLocalizedMessage()); 552 this.exception = exception; 553 } 554 555 559 public Exception getWrappedException() 560 { 561 return exception; 562 } 563 564 568 public String getLocalizedMessage() 569 { 570 return exception.getLocalizedMessage(); 571 } 572 573 577 public String getMessage() 578 { 579 return exception.getMessage(); 580 } 581 582 585 public void printStackTrace() 586 { 587 exception.printStackTrace(); 588 } 589 590 594 public void printStackTrace(PrintStream printStream) 595 { 596 exception.printStackTrace(printStream); 597 } 598 599 603 public void printStackTrace(PrintWriter printWriter) 604 { 605 exception.printStackTrace(printWriter); 606 } 607 } 608 609 620 interface Internal extends Resource 621 { 622 638 void attached(EObject eObject); 639 640 656 void detached(EObject eObject); 657 658 665 NotificationChain basicSetResourceSet(ResourceSet resourceSet, NotificationChain notifications); 666 } 667 } 668 | Popular Tags |