Re: UriBuilder <was> Re: How to create URIs?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 29 Aug 2007 10:58:50 +0200

Dhanji R. Prasanna wrote:
> As part of the UriBuilder implementation we will need to write
> context-specific (path, query etc) character validation, and encode
> methods. This is because there is insufficient public accessible
> functionality in* and URI. How about we expose validation,
> encode and decode as general methods?
> Im happy with exposing encode and decode, but not sure about
> validation--what specifically are you referring to validation of?
> If it is whole-URL validation I would be against it as it seems like
> duplication of JSR-303 specification. Is there a reason a user (or us)
> can't use the jsr303 (a JSE API) artifacts directly? Apart from the fact
> that the horsemen may come before we release the spec =)

It would not be validation of the URI ABNF it would only be validation
of characters of a URI component (scheme, user info, host, path, query
or fragment).

We discussed throwing exceptions as early as possible in building process:

For example,

         encode(false).path("/a/no space/c").

The following could throw an exception when build() is called, or an
exception could be thrown closer to the source of the error when 'path'
is called.

For the latter case some character validation functionality would be
required (we could reuse URI to validate but it is very inefficient,
e.g. new URI(null, null, "/a/no space/c", null).getRawPath())

The URI component needs to be declared when encoding as different
components have different sets of ASCII characters that require
percent-encoding. The component for decoding is also required but only
for distinguishing a host component, since an IPv6 address may contain
scope-ids (a % character may be present between the '[' and ']').


| ? + ? = To question
    Paul Sandoz