|
Re: creating a URI containing Path Variables [message #1250651 is a reply to message #1250617] |
Wed, 19 February 2014 12:57 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Kevin,
Comments below.
On 19/02/2014 1:10 PM, Kevin Milburn wrote:
> I've been playing with some code utilising IPathVariableManager and
> have a small issue, the resolveURI function appears unusable (or I've
> missed something).
>
> If I do this, IPath p = new Path("${PROJECT_LOC}/file/in/project");
> p = pathVariableManager.resolvePath(p);
> everything works as expected, but I get a warning that resolve path is
> deprecated and should use resolveURI instead.
That's kind of annoying... It appears that both implementations of
resolveURI only work with (i.e., return something useful for) relative
URIs , which can just as nicely be represented as paths...
>
> The snag is, how to create a URI which contains a path variable.
>
> URI uri = new URI("${PROJECT_LOC}/file/in/project");causes a
> java.net.URISyntaxException: Illegal character in path at index 1:
> ${project_loc}/file/in/project (adding file:/ just moves the error to
> index 7)
Looking at the implementation I imagine that you're supposed to pass in
new URI("$%7BPROJECT_LOC%7D/file/in/project")...
>
> URI uri = new File("${PROJECT_LOC}/file/in/project").toURI();creates a
> URI along the lines of
> c:/work/eclipse/$%7BPROJECT_LOC%7D/file/in/project, which is invalid
> and won't resovle.
>
> Given that the resolveURI method exists, is a replacement for
> resolvePath and its javadoc implies it will do the required resoltion
> of variables, how do you create a URI containing the approriate value
> to pass to the method?
I think that if you used this constructor, it would escape the braces
and it looks like
java.net.URI uri = new java.net.URI(null, "${x}/y", null);
System.out.println("###" + uri.getRawSchemeSpecificPart());
System.out.println("###" + uri.getSchemeSpecificPart());
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03319 seconds