[VFS] Why resolveFile API doesn't accepting URI ?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[VFS] Why resolveFile API doesn't accepting URI ?

vmassol
Hi there,

I've just tried to use VFS and I was surprised to see that the resolveFile
API does not have a signature accepting a URI object. I'm pretty sure there
must be a good reason for this but I'm curious to understand why. It does
accept a string representing a URI according to the doc though.

The reason I'm keen to understand the reason behind this is because I'm
trying to transform Cargo's API to use only URI objects and remove all File
objects (to be able to then use VFS transparently behind the hood). I'm
wondering if I should use String parameters rather than URI ones. I'm more
leaning towards URI ones for now as it's typed. Hence my question... :-)

Thanks a lot
-Vincent


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] Why resolveFile API doesn't accepting URI ?

Mario Ivankovits
Hi!
> I've just tried to use VFS and I was surprised to see that the resolveFile
> API does not have a signature accepting a URI object.
I think (this decision were felt before I jumped to VFS) the main reason
is, that vfs supports "layered" URIs. So you can have
tar:gz:http://www.......
The java URI class cant really deal with this, can it?

Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [VFS] Why resolveFile API doesn't accepting URI ?

vmassol
Hi Mario,

> -----Original Message-----
> From: Mario Ivankovits [mailto:[hidden email]]
> Sent: lundi 17 juillet 2006 08:25
> To: Jakarta Commons Users List
> Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
>
> Hi!
> > I've just tried to use VFS and I was surprised to see that the
> resolveFile
> > API does not have a signature accepting a URI object.
> I think (this decision were felt before I jumped to VFS) the main reason
> is, that vfs supports "layered" URIs. So you can have
> tar:gz:http://www.......
> The java URI class cant really deal with this, can it?

I think it can. See
http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html

They give this example in the javadoc:
urn:isbn:096139210x

In addition the general format is: [scheme:]scheme-specific-part[#fragment]
I'm not an expert but I guess one could consider that the scheme is
"tar:gz:http" in your example above.

Thanks!
-Vincent


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] Why resolveFile API doesn't accepting URI ?

Philippe Poulard
Vincent Massol wrote:

> Hi Mario,
>
>
>>-----Original Message-----
>>From: Mario Ivankovits [mailto:[hidden email]]
>>Sent: lundi 17 juillet 2006 08:25
>>To: Jakarta Commons Users List
>>Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
>>
>>Hi!
>>
>>>I've just tried to use VFS and I was surprised to see that the
>>
>>resolveFile
>>
>>>API does not have a signature accepting a URI object.
>>
>>I think (this decision were felt before I jumped to VFS) the main reason
>>is, that vfs supports "layered" URIs. So you can have
>>tar:gz:http://www.......
>>The java URI class cant really deal with this, can it?
>
>
> I think it can. See
> http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html
>
> They give this example in the javadoc:
> urn:isbn:096139210x
>
> In addition the general format is: [scheme:]scheme-specific-part[#fragment]
> I'm not an expert but I guess one could consider that the scheme is
> "tar:gz:http" in your example above.

not at all : the scheme is "tar" and the scheme specific part is the
remainder ; unfortunately, the URI class doesn't perform further parsing
for the other parts because the RFCs doesn't specify a separator ; VFS
uses "!"

--
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [VFS] Why resolveFile API doesn't accepting URI ?

vmassol
Hi Philippe,

> -----Original Message-----
> From: Philippe Poulard [mailto:[hidden email]]
> Sent: lundi 17 juillet 2006 11:28
> To: Jakarta Commons Users List
> Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
>
> Vincent Massol wrote:
> > Hi Mario,
> >
> >
> >>-----Original Message-----
> >>From: Mario Ivankovits [mailto:[hidden email]]
> >>Sent: lundi 17 juillet 2006 08:25
> >>To: Jakarta Commons Users List
> >>Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
> >>
> >>Hi!
> >>
> >>>I've just tried to use VFS and I was surprised to see that the
> >>
> >>resolveFile
> >>
> >>>API does not have a signature accepting a URI object.
> >>
> >>I think (this decision were felt before I jumped to VFS) the main reason
> >>is, that vfs supports "layered" URIs. So you can have
> >>tar:gz:http://www.......
> >>The java URI class cant really deal with this, can it?
> >
> >
> > I think it can. See
> > http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html
> >
> > They give this example in the javadoc:
> > urn:isbn:096139210x
> >
> > In addition the general format is: [scheme:]scheme-specific-
> part[#fragment]
> > I'm not an expert but I guess one could consider that the scheme is
> > "tar:gz:http" in your example above.
>
> not at all : the scheme is "tar" and the scheme specific part is the
> remainder ;

Ah right. As I said I'm not an expert ;-)

> unfortunately, the URI class doesn't perform further parsing
> for the other parts because the RFCs doesn't specify a separator ; VFS
> uses "!"

What do you think would not work if VFS used an URI class? It seems to me
that getScheme() and getSchemeSpecificPart() will always return the full
URI, no?

I wrote a little unit test to ensure I understand what's going on:

public void testURI() throws Exception
{
    URI uri1 = new URI("file://c:/anyhost/dir/mytar.tar.gz");
    assertEquals("file", uri1.getScheme());
    assertEquals("//c:/anyhost/dir/mytar.tar.gz",
        uri1.getSchemeSpecificPart());
    assertEquals("c:", uri1.getAuthority());
    assertEquals("/anyhost/dir/mytar.tar.gz", uri1.getPath());

    URI uri2 = new URI("tar:gz:http://anyhost/dir/mytar.tar.gz!/mytar.tar!"
        + "/path/in/tar/README.txt");
    assertEquals("tar", uri2.getScheme());
    assertEquals("gz:http://anyhost/dir/mytar.tar.gz!/mytar.tar!"
        + "/path/in/tar/README.txt", uri2.getSchemeSpecificPart());
    assertNull(uri2.getAuthority());
    assertNull(uri2.getPath());
}

As the general format is "[scheme:]scheme-specific-part[#fragment]" if we
used only the getScheme() and getSchemeSpecificPart() APIs wouldn't it work
just fine?

The scheme-specific part would be parsed as it's currently done.

In other words what do you think wouldn't work if we used the URI Java
class?

Thanks
-Vincent


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] Why resolveFile API doesn't accepting URI ?

Philippe Poulard
Vincent Massol wrote:

> Hi Philippe,
>
>
>>-----Original Message-----
>>From: Philippe Poulard [mailto:[hidden email]]
>>Sent: lundi 17 juillet 2006 11:28
>>To: Jakarta Commons Users List
>>Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
>>
>>Vincent Massol wrote:
>>
>>>Hi Mario,
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Mario Ivankovits [mailto:[hidden email]]
>>>>Sent: lundi 17 juillet 2006 08:25
>>>>To: Jakarta Commons Users List
>>>>Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
>>>>
>>>>Hi!
>>>>
>>>>
>>>>>I've just tried to use VFS and I was surprised to see that the
>>>>
>>>>resolveFile
>>>>
>>>>
>>>>>API does not have a signature accepting a URI object.
>>>>
>>>>I think (this decision were felt before I jumped to VFS) the main reason
>>>>is, that vfs supports "layered" URIs. So you can have
>>>>tar:gz:http://www.......
>>>>The java URI class cant really deal with this, can it?
>>>
>>>
>>>I think it can. See
>>>http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html
>>>
>>>They give this example in the javadoc:
>>>urn:isbn:096139210x
>>>
>>>In addition the general format is: [scheme:]scheme-specific-
>>
>>part[#fragment]
>>
>>>I'm not an expert but I guess one could consider that the scheme is
>>>"tar:gz:http" in your example above.
>>
>>not at all : the scheme is "tar" and the scheme specific part is the
>>remainder ;
>
>
> Ah right. As I said I'm not an expert ;-)
>
>
>>unfortunately, the URI class doesn't perform further parsing
>>for the other parts because the RFCs doesn't specify a separator ; VFS
>>uses "!"
>
>
> What do you think would not work if VFS used an URI class? It seems to me
> that getScheme() and getSchemeSpecificPart() will always return the full
> URI, no?
>
> I wrote a little unit test to ensure I understand what's going on:
>
> public void testURI() throws Exception
> {
>     URI uri1 = new URI("file://c:/anyhost/dir/mytar.tar.gz");
>     assertEquals("file", uri1.getScheme());
>     assertEquals("//c:/anyhost/dir/mytar.tar.gz",
>         uri1.getSchemeSpecificPart());
>     assertEquals("c:", uri1.getAuthority());
>     assertEquals("/anyhost/dir/mytar.tar.gz", uri1.getPath());
>
>     URI uri2 = new URI("tar:gz:http://anyhost/dir/mytar.tar.gz!/mytar.tar!"
>         + "/path/in/tar/README.txt");
>     assertEquals("tar", uri2.getScheme());
>     assertEquals("gz:http://anyhost/dir/mytar.tar.gz!/mytar.tar!"
>         + "/path/in/tar/README.txt", uri2.getSchemeSpecificPart());
>     assertNull(uri2.getAuthority());
>     assertNull(uri2.getPath());
> }
>
> As the general format is "[scheme:]scheme-specific-part[#fragment]" if we
> used only the getScheme() and getSchemeSpecificPart() APIs wouldn't it work
> just fine?

URIs are classified in opaque URIs and hierarchical URIs ; the uri1 in
your example is hierarchical, the uri2 is opaque, but it looks like a
hierarchical URI ; what we can't do with opaque URIs ? well... resolving
a relative URI regarding it

>
> The scheme-specific part would be parsed as it's currently done.
>
> In other words what do you think wouldn't work if we used the URI Java
> class?

if you have to resolve URIs upon a base URI, you'll certainly have some
troubles if you have "layered" URIs à la VFS

what you need is a specific class that understand "layered" URIs ; it
could be a class based on the existing URI class ; what you have to do
is to test if you have an opaque URI if the scheme specific part up to
the last "!" is itself an URI

VFS works like this

--
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [VFS] Why resolveFile API doesn't accepting URI ?

vmassol


> -----Original Message-----
> From: Philippe Poulard [mailto:[hidden email]]
> Sent: lundi 17 juillet 2006 13:12
> To: Jakarta Commons Users List
> Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?

[snip]
 
> URIs are classified in opaque URIs and hierarchical URIs ; the uri1 in
> your example is hierarchical, the uri2 is opaque, but it looks like a
> hierarchical URI ; what we can't do with opaque URIs ? well... resolving
> a relative URI regarding it

Ok, that's a good point. I believe it would still be possible for VFS to
transform an opaque URI object into an internal hierarchical layered URI,
but fine I now understand the point.

As I mentioned in my first mail, the reason I'm asking all these questions
is because I need to take the decision as to whether to use the URI class in
Cargo or a String object. From what you say I think a URI would still work
and I would call resolveFile() passing it myURI.toString().

Thanks for your help,
-Vincent


       

       
               
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [VFS] Why resolveFile API doesn't accepting URI ?

vmassol
In reply to this post by vmassol


> -----Original Message-----
> From: Vincent Massol [mailto:[hidden email]]
> Sent: lundi 17 juillet 2006 13:25
> To: 'Jakarta Commons Users List'
> Subject: RE: [VFS] Why resolveFile API doesn't accepting URI ?
>
>
>
> > -----Original Message-----
> > From: Philippe Poulard [mailto:[hidden email]]
> > Sent: lundi 17 juillet 2006 13:12
> > To: Jakarta Commons Users List
> > Subject: Re: [VFS] Why resolveFile API doesn't accepting URI ?
>
> [snip]
>
> > URIs are classified in opaque URIs and hierarchical URIs ; the uri1 in
> > your example is hierarchical, the uri2 is opaque, but it looks like a
> > hierarchical URI ; what we can't do with opaque URIs ? well... resolving
> > a relative URI regarding it
>
> Ok, that's a good point. I believe it would still be possible for VFS to
> transform an opaque URI object into an internal hierarchical layered URI,
> but fine I now understand the point.
>
> As I mentioned in my first mail, the reason I'm asking all these questions
> is because I need to take the decision as to whether to use the URI class
> in Cargo or a String object. From what you say I think a URI would still
> work and I would call resolveFile() passing it myURI.toString().

FWIW, I now think we should use Strings and not URIs... :-) (see
http://tinyurl.com/f6uu4 for the reasons).

The main reason is that I'd like Cargo end users to use the "c:/tmp" syntax
to represent a file and new File(new URI("c:/tmp")) doesn't work as the
scheme is "c" and not "file". Using "file://c:/tmp"

Thanks
-Vincent


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]