Re: [Fwd: Re: [xml-dev] creating a URI class]

On Sat, 2002-02-16 at 17:27, Simon St.Laurent wrote:
> I'm curious whether this URI class (part of Java 1.4) really passes
> muster.  In particular, I'm wondering about whether its equals() method
> is true to the different notions of equality in the different schemes.
> 
> http://java.sun.com/j2se/1.4/docs/api/java/net/URI.html
> 
> Any thoughts?

On equality...

URIs are character sequences; they're equal when they
have the same characters an unequal when they don't.
i.e. strcmp() is necessary and sufficient for comparing URIs.

There are cases when the URI spec guarantees that two URIs
point to the same thing; e.g.
	http://www.w3.org/
and
	http://WWW.W3.ORG/

but that doesn't make the two URIs equal. If you want
to be sure that consumers realize you mean the same thing,
I recommend writing it the same way, rather than relying
on consumers to do scheme-specific equivalence processing.

Also...

It seems odd, to me, to make a URI class; URIs don't have
any state. Passing strings around seems necessary and
sufficient.

While we're on the subject of URI class APIs...

I had some thoughts on URI API design a while ago...

  * URI API design
  Dan Connolly (Sun, Aug 12 2001)
  http://lists.w3.org/Archives/Public/uri/2001Aug/0021.html

basically, I'd like to see the interface for peeking
under the covers in APIs separated from the API
for just absolutizing them and grabbing the fragment,
which is all most clients need.

I'm sorta kicking myself for letting another API
(this Java 1.4 API) get deployed without this separation.
And I was chatting with folks at python10 about
bugs in the python urlparse module. And I was
thinking about URIs in the TAG context; prompted
by all that, I finally managed to write a little code:

  http://www.w3.org/2000/10/swap/uripath.py
  $Id: uripath.py,v 1.1 2002/02/19 22:52:42 connolly Exp $

It has splitFrag(), join(), and pathTo().

More than half the code in the module is unit test stuff.

I'll be thinking about encoding form arguments,
encoding Unicode strings, etc. next.

For completeness, I should write the low-level
API, I suppose.

Meanwhile, I went over the relative URI tests
in RFC2396, and I was surprised by some of them.
I need to think them over a bit.


-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/

Received on Tuesday, 19 February 2002 18:05:46 UTC