Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » help about URIConverter
help about URIConverter [message #421726] Tue, 12 August 2008 13:56 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I should use the hooks provided by EMF (e.g. register a URIConverter
with the ResourceSet) to silently convert filenames to complete URIs.

For instance "includedfile.foo" should be converted automatically and
transparently to "platform:resource/mypath/includedfile.foo".

Could you please point me to some code snippet/example?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: help about URIConverter [message #421728 is a reply to message #421726] Tue, 12 August 2008 14:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000109040300040501050307
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Lorenzo,

Comments below.


Lorenzo Bettini wrote:
> Hi
>
> I should use the hooks provided by EMF (e.g. register a URIConverter
> with the ResourceSet) to silently convert filenames to complete URIs.
>
> For instance "includedfile.foo" should be converted automatically and
> transparently to "platform:resource/mypath/includedfile.foo".
>
> Could you please point me to some code snippet/example?
It sounds like you'd want to create a derived ExtensibleURIConverterImpl
and specialize the normalize method. Perhaps populating the URI map of
the existing converter is sufficient though:


Map<URI, URI>
org.eclipse.emf.ecore.resource.URIConverter.getURIMap()

Returns the map used for remapping a logical URI to a physical URI
when |normalizing
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82%E2%98%82normalize >|.


An implementation will typically also delegate to the |global
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URIConverter%E2%98%82URI_MAP >|
map, so registrations made in this map are /local/ to this URI
converter, i.e., they augment or override those of the global map.

The map generally specifies instance to instance mapping, except for
the case that both the key URI and the value URI end with "/", which
specifies a folder to folder mapping. A folder mapping will remap
any URI that has the key as its |prefix
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82replacePrefix >|,
e.g., if the map contains:

http://www.example.com/ -> platform:/resource/example/


then the URI

http://www.example.com/a/b/c.d


will map to

platform:/resource/example/a/b/c.d


A matching instance mapping is considered first. If there isn't one,
the folder mappings are considered starting with the |longest
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82segmentCount%E2%98%82 >|
prefix.


>
> thanks in advance
> Lorenzo
>

--------------000109040300040501050307
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Lorenzo,<br>
<br>
Comments below.<br>
<br>
<br>
Lorenzo Bettini wrote:
<blockquote cite="mid:g7s4q3$gh1$1@build.eclipse.org" type="cite">Hi
<br>
<br>
I should use the hooks provided by EMF (e.g. register a URIConverter
with the ResourceSet) to silently convert filenames to complete URIs.
<br>
<br>
For instance "includedfile.foo" should be converted automatically and
transparently to "platform:resource/mypath/includedfile.foo".
<br>
<br>
Could you please point me to some code snippet/example?
<br>
</blockquote>
It sounds like you'd want to create a derived
ExtensibleURIConverterImpl and specialize the normalize method.&nbsp;&nbsp;
Perhaps populating the URI map of the existing converter is sufficient
though:<br>
<br>
<blockquote>
<h5>
<div style="margin-top: 0px; margin-left: 22px;">Map&lt;URI, URI&gt;
org.eclipse.emf.ecore.resource.URIConverter.getURIMap()</div >
</h5>
<p>Returns the map used for remapping a logical URI to a physical URI
when <code><a
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82%E2%98%82normalize ">normalizing</a></code>.
</p>
<p>An implementation will typically also delegate to the <code><a
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URIConverter%E2%98%82URI_MAP ">global</a></code>
map, so registrations made in this map are <em>local</em> to this URI
converter, i.e., they augment or override those of the global map. </p>
<p>The map generally specifies instance to instance mapping, except
for the case that both the key URI and the value URI end with "/",
which specifies a folder to folder mapping. A folder mapping will remap
any URI that has the key as its <code><a
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82replacePrefix ">prefix</a></code>,
e.g., if the map contains: </p>
<pre> <a class="moz-txt-link-freetext" href="http://www.example.com/">http://www.example.com/</a> -&gt; platform:/resource/example/
</pre>
then the URI
<pre> <a class="moz-txt-link-freetext" href="http://www.example.com/a/b/c.d">http://www.example.com/a/b/c.d</a>
</pre>
will map to
<pre> platform:/resource/example/a/b/c.d
</pre>
A matching instance mapping is considered first. If there isn't one,
the folder mappings are considered starting with the <code><a
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82segmentCount%E2%98%82 ">longest</a></code>
prefix. </blockquote>
<br>
<blockquote cite="mid:g7s4q3$gh1$1@build.eclipse.org" type="cite"><br>
thanks in advance
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Lorenzo
<br>
<br>
</blockquote>
</body>
</html>

--------------000109040300040501050307--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: help about URIConverter [message #421733 is a reply to message #421728] Tue, 12 August 2008 16:58 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Yes, probably this would be enough... but how to set such specialized
converter? I mean, where?

thanks
Lorenzo

Ed Merks wrote:
> Lorenzo,
>
> Comments below.
>
>
> Lorenzo Bettini wrote:
>> Hi
>>
>> I should use the hooks provided by EMF (e.g. register a URIConverter
>> with the ResourceSet) to silently convert filenames to complete URIs.
>>
>> For instance "includedfile.foo" should be converted automatically and
>> transparently to "platform:resource/mypath/includedfile.foo".
>>
>> Could you please point me to some code snippet/example?
> It sounds like you'd want to create a derived ExtensibleURIConverterImpl
> and specialize the normalize method. Perhaps populating the URI map of
> the existing converter is sufficient though:
>
>
> Map<URI, URI>
> org.eclipse.emf.ecore.resource.URIConverter.getURIMap()
>
> Returns the map used for remapping a logical URI to a physical URI
> when |normalizing
> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82%E2%98%82normalize >|.
>
>
> An implementation will typically also delegate to the |global
> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URIConverter%E2%98%82URI_MAP >|
> map, so registrations made in this map are /local/ to this URI
> converter, i.e., they augment or override those of the global map.
>
> The map generally specifies instance to instance mapping, except for
> the case that both the key URI and the value URI end with "/", which
> specifies a folder to folder mapping. A folder mapping will remap
> any URI that has the key as its |prefix
> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82replacePrefix >|,
> e.g., if the map contains:
>
> http://www.example.com/ -> platform:/resource/example/
>
>
> then the URI
>
> http://www.example.com/a/b/c.d
>
>
> will map to
>
> platform:/resource/example/a/b/c.d
>
>
> A matching instance mapping is considered first. If there isn't one,
> the folder mappings are considered starting with the |longest
> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82segmentCount%E2%98%82 >|
> prefix.
>
>
>>
>> thanks in advance
>> Lorenzo
>>


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: help about URIConverter [message #421735 is a reply to message #421733] Tue, 12 August 2008 17:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Lorenzo,

ResourceSet.setURIConverter would let you set a specialized
implementation and ResourceSet.getURIConverter().getURIMap().put(...,
....) would let you populate mappings.


Lorenzo Bettini wrote:
> Yes, probably this would be enough... but how to set such specialized
> converter? I mean, where?
>
> thanks
> Lorenzo
>
> Ed Merks wrote:
>> Lorenzo,
>>
>> Comments below.
>>
>>
>> Lorenzo Bettini wrote:
>>> Hi
>>>
>>> I should use the hooks provided by EMF (e.g. register a URIConverter
>>> with the ResourceSet) to silently convert filenames to complete URIs.
>>>
>>> For instance "includedfile.foo" should be converted automatically
>>> and transparently to "platform:resource/mypath/includedfile.foo".
>>>
>>> Could you please point me to some code snippet/example?
>> It sounds like you'd want to create a derived
>> ExtensibleURIConverterImpl and specialize the normalize method.
>> Perhaps populating the URI map of the existing converter is
>> sufficient though:
>>
>>
>> Map<URI, URI>
>> org.eclipse.emf.ecore.resource.URIConverter.getURIMap()
>>
>> Returns the map used for remapping a logical URI to a physical URI
>> when |normalizing
>>
>> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82%E2%98%82normalize >|.
>>
>>
>>
>> An implementation will typically also delegate to the |global
>>
>> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URIConverter%E2%98%82URI_MAP >|
>>
>> map, so registrations made in this map are /local/ to this URI
>> converter, i.e., they augment or override those of the global map.
>>
>> The map generally specifies instance to instance mapping, except for
>> the case that both the key URI and the value URI end with "/", which
>> specifies a folder to folder mapping. A folder mapping will remap
>> any URI that has the key as its |prefix
>>
>> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82replacePrefix >|,
>>
>> e.g., if the map contains:
>>
>> http://www.example.com/ -> platform:/resource/example/
>>
>> then the URI
>>
>> http://www.example.com/a/b/c.d
>>
>> will map to
>>
>> platform:/resource/example/a/b/c.d
>>
>> A matching instance mapping is considered first. If there isn't one,
>> the folder mappings are considered starting with the |longest
>>
>> < eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore.resource%7BURIConverter.java%E2%98%83URIConv erter%7EgetURIMap%E2%98%82URI%E2%98%82segmentCount%E2%98%82 >|
>>
>> prefix.
>>
>>>
>>> thanks in advance
>>> Lorenzo
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: help about URIConverter [message #421779 is a reply to message #421735] Wed, 13 August 2008 13:08 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Ed Merks wrote:
> Lorenzo,
>
> ResourceSet.setURIConverter would let you set a specialized
> implementation and ResourceSet.getURIConverter().getURIMap().put(...,
> ...) would let you populate mappings.

Thanks, I'll try... but an example in the documentation would help ;-)

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: help about URIConverter [message #421782 is a reply to message #421779] Wed, 13 August 2008 13:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Lorenzo,

The Javadoc has an example of populating the map and an example of
calling the setter seems a little mundane. Of course there is a wiki
where folks can contribute to the EMF recipes and the FAQ where folks
can add questions and answers that would be useful to others...


Lorenzo Bettini wrote:
> Ed Merks wrote:
>> Lorenzo,
>>
>> ResourceSet.setURIConverter would let you set a specialized
>> implementation and ResourceSet.getURIConverter().getURIMap().put(...,
>> ...) would let you populate mappings.
>
> Thanks, I'll try... but an example in the documentation would help ;-)
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:xsd import/export
Next Topic:Properties editor
Goto Forum:
  


Current Time: Tue Apr 16 23:45:16 GMT 2024

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

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

Back to the top