Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Problems about loading UML file
Problems about loading UML file [message #625861] Wed, 09 January 2008 08:30
Eclipse UserFriend
Originally posted by: heiyuchuanxia.163.com

Hi, everyone, I'm a newbie here. Now I encounter a problem about loading
a uml file. I can load the resource and get the content but I just can't
get the package in this uml file.

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

URI fileURI =URI.createFileURI(new
File("model/bpel.uml").getAbsolutePath());
org.eclipse.uml2.uml.Package umlpackage=load(fileURI);

the code of load method:
protected static org.eclipse.uml2.uml.Package load(URI uri) {
org.eclipse.uml2.uml.Package package_ = null;

try {
Resource resource = RESOURCE_SET.getResource(uri, true);

package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
.getObjectByType(resource.getContents(),
UMLPackage.Literals.PACKAGE);
} catch (WrappedException we) {
err(we.getMessage());
System.exit(1);
}

return package_;
}

after these code, the umlpackage is null and the return Package of the
load method is null.

I debuged these code, and it's really call the UMLResourceFactory.

It seems there is some wrong in the getObjectByType method, since the
content object is
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@16877f8 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@19c7c21 (name: Package)
(instanceClassName: null) (abstract: false, interface: false)) but the
type is org.eclipse.emf.ecore.impl.EClassImpl@170ec24 (name: Package)
(instanceClassName: null) (abstract: false, interface: false) , so the
type.isInstance(object) is false.

How can I get the package of the uml model.

Thanks very much for caring about my question.
Stefanie
Previous Topic:How to save UML2 model as XMI (standalone)
Next Topic:Problems about loading UML file
Goto Forum:
  


Current Time: Tue Aug 16 04:36:24 GMT 2022

Powered by FUDForum. Page generated in 0.02066 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top