On 4/11/07, Thierry Boileau <[EMAIL PROTECTED]> wrote:
Hello Justin,
thanks a lot for your effort, you point crucial issues.
You help fixing a bug with the computing of the relative part. The
StackOverflowError was thrown when the base reference was not defined.
However, as said in chapter "5.1. Establishing a Base URI", of the Uri
reference (http://www.ietf.org/rfc/rfc3986.txt), a relative part cannot
be used in a context where the base reference is not defined. The fix
consists of throwing an IllegalArgumentException.
That doesn't seem consistent with the other behavior of e.g.,
returning null (or even an empty string).
[...]
And the last but not the least. The Reference class was intended to wrap
an URI and to leave the user free to choose the way he builds
references, and to memorize as much as possible these primary choices.
That's why some behaviours are disturbing; The safer way to get the
final complete URI is to call the "getTargetRef" method, which needed
some correction, as you point very judiciously.
I am very concerned that these "disturbing" behaviors don't seem to be
consistent which means they will be brittle to use because different
assumptions will be made depending on a slew of things that may or may
not be apparent.
I send an attached file, the list of all actualized tests and their results.
Finally, I must say that I did not see wrong URIs. I have the feeling
that you think about such cases:
Reference fulldir = new Reference("http://host.com/dir");
Reference fulldirsub = new Reference(fulldir, "sub");
fulldirsub.getTargetRef() => http://host.com/sub
In my opinion, the result is correct, because it is conform to what you
can notice with the relative URLs in HTML pages.
Can you tell me more about this point?
Please feel free to give your feeling, ideas.
Actually, no, that's not the behavior for web pages. To get
"http://host.com/sub" you would have to add "/sub" to e.g.,
"http://host.com/dir". Adding "sub" to e.g. "http://host.com/dir"
should result in "http://host.com/dir/sub".
[...]
**************** host = new Reference("http://host.com")
Scheme http
Authority host.com
Path null
RemainingPart http://host.com
toString http://host.com
TargetRef http://host.com
RelativePart IllegalArgumentException
Sticking to the convention of using null for missing elements, I'd say
that the RelativePart should be null. It's just missing (or "not
applicable", if you will) -- just like the Path.
**************** slashdir = new Reference(host, "/dir")
Scheme null
Authority null
Path /dir
RemainingPart null
toString /dir
TargetRef http://host.com/dir
RelativePart /dir
If this is built relative to the 'host' reference, why isn't slashdir
"inheriting" the information from the 'host'?
I.e., the abstract model of what Reference has been created for needs
to be clear and clearly explained. Is it a DAG or a tree or a wacky
string or what? How does each Reference stand on it's own? How do all
of the pieces compose and why? What about other facets of a reference
such as anchors (e.g. "#footer1") and parameters get folded in? Etc.
Basically, how can users understand how it should work without going
insane?
IMHO, *everything* follows from the answers to this fundamental
question of, in essence, identity works because it's the fundamental
pivot around which the entire notion of REST revolves.
Hope this makes sense,
John