Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java.net.URI.relativize(java.net.URI) not really working

Reply
Thread Tools

java.net.URI.relativize(java.net.URI) not really working

 
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      08-12-2005
The java.net.URI.relativize(java.net.URI) method does its job exactly
as described in the method documentation, but seems it has really no
usage that way.

I want to relativize:

http://www.example.com/path/to/linked_resource

against:

http://www.example.com/path/to/resource

The result from the URI.relativize() method is an absolute URI. It
works as expected only when the path component of the base URI is
prefix of the path of the URI to relativize, i.e. the above base needs
to be:

http://www.example.com/path/to/

Doing this test I've noticed another thing which should be considered
erroneous behavior according to the algorithm to resolve relative URIs.
If the base is:

http://www.example.com/path/to

and the URI to relativize:

http://www.example.com/path/to/linked_resource

the result is still:

linked_resource

while I expect it to be:

to/linked_resource

The documentation for the URI class also describes
<http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html>:

> Relativization, finally, is the inverse of resolution: For any two
> normalized URIs u and v,
>
> u.relativize(u.resolve(v)).equals(v) and
> u.resolve(u.relativize(v)).equals(v) .


While I couldn't figure exactly what's the meaning of the above tests
they both fail using:

u = http://www.example.com/path/to
v = http://www.example.com/path/to/linked_resource

and the first fails when:

u = http://www.example.com/path/to/
v = http://www.example.com/path/to/linked_resource

I've made my tests using the Sun's Java 1.4 on Windows.

--
Stanimir

 
Reply With Quote
 
 
 
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      08-17-2005
/Stanimir Stamenkov/:

> I want to relativize:
>
> http://www.example.com/path/to /linked_resource
>
> against:
>
> http://www.example.com/path/to /resource


Here's a related issue at the Sun's Bug Database:

"Bug ID: 6226081 URI should be able to relativize paths with partial
roots" <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6226081>

--
Stanimir

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
really interesting... or really dull. (depends on your attitude) TrevorBoydSmith@gmail.com Java 2 09-01-2006 04:38 PM
OT : But help really really needed re: Domain Name selling, hosting etc. problem nc HTML 1 02-03-2005 07:24 PM
REALLY REALLY WERID PROBLEM!!!!pls take a look Amir ASP .Net 3 01-23-2004 06:01 PM
really really mysterious IE6 problem--secure site ultraviolet353 Computer Support 7 11-22-2003 07:56 PM
MR. ED REALLY, REALLY LOVES THE D60 !!! Annika1980 Digital Photography 9 10-28-2003 04:53 PM



Advertisments