On Dec 3, 2009, at 1:00 PM, Martin Matula wrote:
> Hi,
>
> On Dec 3, 2009, at 12:26 PM, Paul Sandoz wrote:
>
>> Hi Micha,
>>
>> The current method of contextual encoding is by design in JAX-RS.  
>> Rather embarrassingly the case you describe never occurred to me or  
>> others on the EG.
>>
>> Before we modified UriBuilder to support contextual encoding we had  
>> encode(true/false) and isEncoded methods on UriBuilder. The  
>> contextual encoding approach simplified the API.
>
> I think the API is good. The problem is the encoding routine does  
> not encode "%30" properly - i.e. the following is false:
>
> decode(encode(string)).equals(string)
>
> Isn't that a bug in the URIComponent._encode() method?
Not if contextual encoding is enabled, which is the type of encoding  
that is used by UriBuilder.
Try this:
         String s =  
UriComponent.decode(UriComponent.contextualEncode("some is %30 of X",  
Type.QUERY),
                 Type.QUERY);
         System.out.println(s);
Compared to this:
         String s = UriComponent.decode(UriComponent.encode("some is  
%30 of X", Type.QUERY),
                 Type.QUERY);
         System.out.println(s);
Paul.