Java Reference
In-Depth Information
{
if (args.length != 2)
{
System.err.println("usage: java resolve baseuri
uri");
return;
}
URI uri = new URI(args[0]);
System.out.println("resolved
uri
=
"+uri.resolve(args[1]));
}
}
java Resolve
http://java.sun.com/j2se/1.3/docs/guide/col-
lections/designfaq.html#28
.
You should observe the following output:
Resolved URI = http://java.sun.com/j2se/1.3/docs/guide/
collections/designfaq.html#28
Relativization
Relativization
istheinverseofresolution.ForanytwonormalizedURIs,relativization
undoestheworkperformedbyresolutionandresolutionundoestheworkperformedby
relativization.
URI
declares a
URI relativize(URI uri)
method for relativizing its
uri
argument against the URI in the current
URI
object (on which this method was
called)—
relativize()
throws
NullPointerException
when
uri
is
null
.
Note
For any two normalized
URI
instances
u
and
v
,
u.relativize(u.resolve(v)).equals(v)
and
u.resolve(u.relativize(v)).equals(v)
evaluate to true.
relativize()
performsrelativizationofits
URI
argument'sURIagainsttheURI
in the
URI
object on which this method was called as follows:
• IfeitherthisURIortheargumentURIisopaque,oriftheschemeandauthority
components of the two URIs aren't identical, or if the path of this URI isn't a
prefix of the path of the argument URI, the argument URI is returned.