Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resource from a non-physical file
Resource from a non-physical file [message #1724390] Tue, 23 February 2016 15:03 Go to next message
aurel pestell is currently offline aurel pestellFriend
Messages: 90
Registered: October 2013
Location: Sweden
Member
Hi,

Does a Resource always boil down to a physical file ?
In my case I have the content of a xml file that is stored in a java String.
Do I really need to save it on the disk and load the Resource from there, that way:
Resource resource = resourceSet.getResource(fileURI, true);


or is there a way to avoid saving on the disk ?

Thank you.

Aurel
Re: Resource from a non-physical file [message #1724395 is a reply to message #1724390] Tue, 23 February 2016 16:17 Go to previous messageGo to next message
Pavel Vlasov is currently offline Pavel VlasovFriend
Messages: 23
Registered: December 2015
Junior Member
You can load resourse from anything as long as there is a URI handler which knows how to open stream for your "anything". In one of my projects I used mem: protocol and a custom protocol handler to load models from in-memory resourses.
Re: Resource from a non-physical file [message #1724398 is a reply to message #1724390] Tue, 23 February 2016 16:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6043
Registered: July 2009
Senior Member
Hi

You can use ResourceSet.createResource to create the resource then load
it from a stream.

Regards

Ed Willink


On 23/02/2016 15:03, aurel pestell wrote:
> Hi,
>
> Does a Resource always boil down to a physical file ?
> In my case I have the content of a xml file that is stored in a java
> String.
> Do I really need to save it on the disk and load the Resource from
> there, that way:
> Resource resource = resourceSet.getResource(fileURI, true);
>
> or is there a way to avoid saving on the disk ?
>
> Thank you.
>
> Aurel
Re: Resource from a non-physical file [message #1724401 is a reply to message #1724398] Tue, 23 February 2016 17:06 Go to previous message
aurel pestell is currently offline aurel pestellFriend
Messages: 90
Registered: October 2013
Location: Sweden
Member
Thanks, something like that should work (inspired from the XMLProcessor):

InputSource inputSource = new InputSource(new StringReader(xmlContent));
		XMLResource resource = (XMLResource) resourceSet.createResource(URI.createFileURI("xml"));
		resource.load(inputSource, null);
Previous Topic:[genmodel] model directory
Next Topic:[ECP] Send command line arguments to an ECP application
Goto Forum:
  


Current Time: Mon Sep 24 22:04:59 GMT 2018

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

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

Back to the top