Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » creating Resource
creating Resource [message #623669] Mon, 16 July 2007 10:34
Jan Reimann is currently offline Jan ReimannFriend
Messages: 90
Registered: July 2009
Hello NG,
I want to do something like the following to save a model:

private static void saveModel(String name, Model model) {
String filename = outDir + name + "." + UMLResource.FILE_EXTENSION;
File file = new File(filename);
URI uri = URI.createFileURI(file.getAbsolutePath());

ResourceSet resourceSet = new ResourceSetImpl();
// problem on following line
Resource resource = resourceSet.createResource(uri);

EList<EObject> contents = resource.getContents();


Iterator<Element> allContents = model.getOwnedElements().iterator();
while (allContents.hasNext()) {
EObject eObject = (EObject);
if (eObject instanceof Element) {
contents.addAll(((Element) eObject).getStereotypeApplications());
try {;

} catch (IOException ioe) {
System.out.println("Speichern schiefgegangen!");

but I have a problem on the marked line when creating the Resource. I
always get null. The Javadoc says that null is be returned when no
factory is registered. But I do register my factory(the standard one)
one line before, don't I? So where is my problem? Or better - what is
wrong in my code?

Previous Topic:undo notification
Next Topic:How to add a StateMachine to a Class?
Goto Forum:

Current Time: Wed Apr 01 05:41:58 GMT 2020

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

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

Back to the top