Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Why is resourceSet.createResource(fileURI) always returning null ?
Why is resourceSet.createResource(fileURI) always returning null ? [message #524677] Thu, 01 April 2010 18:54 Go to next message
aravind  is currently offline aravind Friend
Messages: 10
Registered: July 2009
Junior Member
Why is the below code returning null even while running from eclipse. The javadoc says "If there is no registered factory, null will be returned; when running within Eclipse, a default XMI factory will be registered, and this will never return null."

I am running eclipse Galileo Build id: 20090920-1017

ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI(new File("c:/response.xml").getAbsolutePath());
Resource respResource = resourceSet.createResource(fileURI);
Re: Why is resourceSet.createResource(fileURI) always returning null ? [message #524690 is a reply to message #524677] Thu, 01 April 2010 19:12 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070106020204000700010408
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Aravind,

Again the debugger will help answer questions like this faster than me.
You'd step through this method and realize that you've not registered a
resource factory that can deal with your URI.

public Resource createResource(URI uri, String contentType)
{
Resource.Factory resourceFactory =
getResourceFactoryRegistry().getFactory(uri, contentType);
if (resourceFactory != null)
{
Resource result = resourceFactory.createResource(uri);
getResources().add(result);
return result;
}
else
{
return null;
}
}



aravind wrote:
> Why is the below code returning null even while running from eclipse.
> The javadoc says "If there is no registered factory, null will be
> returned; when running within Eclipse, a default XMI factory will be
> registered, and this will never return null."
>
> I am running eclipse Galileo Build id: 20090920-1017
>
> ResourceSet resourceSet = new ResourceSetImpl();
> URI fileURI = URI.createFileURI(new
> File("c:/response.xml").getAbsolutePath());
> Resource respResource = resourceSet.createResource(fileURI);

--------------070106020204000700010408
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Aravind,<br>
<br>
Again the debugger will help answer questions like this faster than
me.  You'd step through this method and realize that you've not
registered a resource factory  that can deal with your URI. <br>
<br>
<blockquote><small>  public Resource createResource(URI uri, String
contentType)</small><br>
<small>  {</small><br>
<small>    Resource.Factory resourceFactory =
getResourceFactoryRegistry().getFactory(uri, contentType);</small><br>
<small>    if (resourceFactory != null)</small><br>
<small>    {</small><br>
<small>      Resource result = resourceFactory.createResource(uri);</small><br>
<small>      getResources().add(result);</small><br>
<small>      return result;</small><br>
<small>    }</small><br>
<small>    else</small><br>
<small>    {</small><br>
<small>      return null;</small><br>
<small>    }</small><br>
<small>  }</small><br>
</blockquote>
<br>
<br>
aravind wrote:
<blockquote cite="mid:hp2q4j$9gm$1@build.eclipse.org" type="cite">Why
is the below code returning null even while running from eclipse. The
javadoc says "If there is no registered factory, null will be returned;
when running within Eclipse, a default XMI factory will be registered,
and this will never return null."
<br>
<br>
I am running eclipse Galileo Build id: 20090920-1017
<br>
<br>
ResourceSet resourceSet = new ResourceSetImpl();
<br>
URI fileURI = URI.createFileURI(new
File("c:/response.xml").getAbsolutePath());
<br>
Resource respResource = resourceSet.createResource(fileURI);
<br>
</blockquote>
</body>
</html>

--------------070106020204000700010408--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Generic EMF Annotations
Next Topic:EClass.eSet method only takes collection?
Goto Forum:
  


Current Time: Fri Apr 26 04:48:47 GMT 2024

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

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

Back to the top