Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » resource
resource [message #416931] Wed, 20 February 2008 16:15 Go to next message
a is currently offline aFriend
Messages: 75
Registered: July 2009
Member
Hello,

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
public class merge {
public static void main(String[] args) {
URI uri = URI.createFileURI("C:/uml.ecore");
Resource res =
Resource.Factory.Registry.INSTANCE.getFactory(uri).createRes ource(uri);
}}

I got NullPointerException for this so short code.
I use simple java with plugin dependencies, and I would like to create a
file using uri, resource.
What should be the mistake and how can I repair it?

Regards,
Attila
Re: resource [message #416934 is a reply to message #416931] Wed, 20 February 2008 17:39 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi Attila,

When you are not executing your code as an Eclipse bundle, you need to
do a few registrations by hand. There is an FAQ entry on this topic:
http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_use_EMF_i n_standalone_applications_.28such_as_an_ordinary_main.29.3F

Cheers,
Marcelo

Attila wrote:
> Hello,
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.resource.Resource;
> public class merge {
> public static void main(String[] args) {
> URI uri = URI.createFileURI("C:/uml.ecore");
> Resource res =
> Resource.Factory.Registry.INSTANCE.getFactory(uri).createRes ource(uri);
> }}
>
> I got NullPointerException for this so short code.
> I use simple java with plugin dependencies, and I would like to create a
> file using uri, resource.
> What should be the mistake and how can I repair it?
>
> Regards,
> Attila
>
Re: resource [message #416942 is a reply to message #416934] Wed, 20 February 2008 19:01 Go to previous messageGo to next message
a is currently offline aFriend
Messages: 75
Registered: July 2009
Member
Hello,


I tried put e.g. this line in the beginning of the file,
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "library",
new XMIResourceFactoryImpl());
but I got an error despite having correct plug-in dependencies.
Do I have to register every line where needed, or only once?

What should I modify in this code to be operable?

And what about bundle?

Regards,
Attila
Re: resource [message #416943 is a reply to message #416942] Wed, 20 February 2008 19:02 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Attila,

In your first example you try to load a file with extension "ecore". Why do you register the factory for extension "library"?

/Eike


Attila schrieb:
> Hello,
>
>
> I tried put e.g. this line in the beginning of the file,
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "library",
> new XMIResourceFactoryImpl());
> but I got an error despite having correct plug-in dependencies. Do I
> have to register every line where needed, or only once?
> What should I modify in this code to be operable?
> And what about bundle?
>
> Regards,
> Attila
>


Re: resource [message #416944 is a reply to message #416943] Wed, 20 February 2008 19:16 Go to previous messageGo to next message
a is currently offline aFriend
Messages: 75
Registered: July 2009
Member
Hello,

I am new in EMF, and I don't know what should I do, but this is only a
short code and I would like to create a file.

Regards,
Attila
Re: resource [message #416945 is a reply to message #416944] Wed, 20 February 2008 19:42 Go to previous message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi Attila,

If you generate the tests plug-in, you will get a Java file called
<YourModel>Example.java. This implements a stand-alone application that
loads and saves instances of your model. It may be a good place to
start if you are a bit lost now.

Going through the tutorials and articles in our documentation page is
also recommended. You could also read the EMF book (the draft of the
2nd version is available as a rough cut at Safari).

Cheers,
Marcelo

Attila wrote:
> Hello,
>
> I am new in EMF, and I don't know what should I do, but this is only a
> short code and I would like to create a file.
>
> Regards,
> Attila
>
Previous Topic:collapsable schema elements
Next Topic:I don't want to reinvent the wheel
Goto Forum:
  


Current Time: Wed Apr 24 16:53:05 GMT 2024

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

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

Back to the top