Home » Modeling » EMF » How can I create URI that refers to in-memory byte array stream?
| | |
Re: How can I create URI that refers to in-memory byte array stream? [message #421026 is a reply to message #421018] |
Tue, 22 July 2008 07:24 |
koloale Messages: 41 Registered: July 2009 |
Member |
|
|
Thank you, Dave, for your answer. However it seems a litle strange to
require passing not null URI in 'createResource(URI uri)' method if I'm
going to use other streams in two-argument methods.
Dave Steinberg wrote:
> Hi Alexy,
>
> You can use any non-null URI (even URI.createURI("") should be fine) to
> create the resource. If you use the two-argument form of save() and
> load(), as suggested by Maximilian, it won't need to use the URI to try
> to obtain a stream (since you'll have provided it directly).
>
> Then, the only reason the URI might come into play is to compute or
> resolve proxy URIs for cross-document references.
>
> Cheers,
> Dave
>
>
> koloale wrote:
>> Hello,
>>
>> I want to save/load model instance to some strings in memory. When
>> using ResourceSet it needs to pass URI in 'createResource' method, so
>> I need to create URI on ByteArrayStream. Passing null in
>> 'createResource' method causes exception.
>>
>> Thanks in advance
>> Alexey
|
|
|
Re: How can I create URI that refers to in-memory byte array stream? [message #421034 is a reply to message #421026] |
Tue, 22 July 2008 14:28 |
David Steinberg Messages: 489 Registered: July 2009 |
Senior Member |
|
|
koloale wrote:
> Thank you, Dave, for your answer. However it seems a litle strange to
> require passing not null URI in 'createResource(URI uri)' method if I'm
> going to use other streams in two-argument methods.
Hi Alexy,
It may seem a little strange, but I can live with that if you can. ;)
As I hinted in my previous reply, URIs play other roles in the
framework: they determine the type of each resource being created, they
uniquely identify a resource in a resource set, and they're instrumental
in persisting cross-resource references. So, from that perspective, it
doesn't make much sense to allow a resource not to have one.
Cheers,
Dave
|
|
|
Re: How can I create URI that refers to in-memory byte array stream? [message #421370 is a reply to message #421018] |
Wed, 06 August 2008 06:36 |
Shahar Ronen Messages: 17 Registered: July 2009 |
Junior Member |
|
|
Hello Dave,
Is there a way to create a resource from a ByteArrayStream via getResource()
or other ResourceSet methods? Passing a URI isn't a problem, but I want the
resource to be set from an in-memory byte stream, not from the file on the
disk whose URI is passed.
Thanks
Shahar.
"Dave Steinberg" <davidms@ca.ibm.com> wrote in message
news:g62om4$5ae$1@build.eclipse.org...
> Hi Alexy,
>
> You can use any non-null URI (even URI.createURI("") should be fine) to
> create the resource. If you use the two-argument form of save() and
> load(), as suggested by Maximilian, it won't need to use the URI to try to
> obtain a stream (since you'll have provided it directly).
>
> Then, the only reason the URI might come into play is to compute or
> resolve proxy URIs for cross-document references.
>
> Cheers,
> Dave
>
>
> koloale wrote:
>> Hello,
>>
>> I want to save/load model instance to some strings in memory. When using
>> ResourceSet it needs to pass URI in 'createResource' method, so I need to
>> create URI on ByteArrayStream. Passing null in 'createResource' method
>> causes exception.
>>
>> Thanks in advance
>> Alexey
|
|
|
Re: How can I create URI that refers to in-memory byte array stream? [message #421388 is a reply to message #421370] |
Wed, 06 August 2008 11:51 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Shahar,
Using resource.load(<inputStream>, <options) does the trick. The same
caveat about the URI applies, i.e., it's typical to use
resourceSet.createResource(<uri>) where the URI determines the type of
resource created (and there's a new-to-EMF 2.4 version that allows you
to specify the content type explicitly) and the URI will be used to
resolve any relative URIs within the byte stream.
Shahar Ronen wrote:
> Hello Dave,
>
> Is there a way to create a resource from a ByteArrayStream via
> getResource() or other ResourceSet methods? Passing a URI isn't a
> problem, but I want the resource to be set from an in-memory byte
> stream, not from the file on the disk whose URI is passed.
>
> Thanks
> Shahar.
>
> "Dave Steinberg" <davidms@ca.ibm.com> wrote in message
> news:g62om4$5ae$1@build.eclipse.org...
>> Hi Alexy,
>>
>> You can use any non-null URI (even URI.createURI("") should be fine)
>> to create the resource. If you use the two-argument form of save()
>> and load(), as suggested by Maximilian, it won't need to use the URI
>> to try to obtain a stream (since you'll have provided it directly).
>>
>> Then, the only reason the URI might come into play is to compute or
>> resolve proxy URIs for cross-document references.
>>
>> Cheers,
>> Dave
>>
>>
>> koloale wrote:
>>> Hello,
>>>
>>> I want to save/load model instance to some strings in memory. When
>>> using ResourceSet it needs to pass URI in 'createResource' method,
>>> so I need to create URI on ByteArrayStream. Passing null in
>>> 'createResource' method causes exception.
>>>
>>> Thanks in advance
>>> Alexey
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Thu Apr 25 22:13:11 GMT 2024
Powered by FUDForum. Page generated in 0.03763 seconds
|