org.weborganic.furi
Class URICoder

java.lang.Object
  extended by org.weborganic.furi.URICoder

public class URICoder
extends Object

An encoder/decoder for use by URI templates. Only unreserved characters according to RFC 3986 do not need to be encoded within a variable:

 unreserved = ALPHA / DIGIT / '-' / '.' / '_' / '˜';
 

This encoder/decoder should be designed so that URI which contain only unreserved characters are processed faster.

Version:
11 June 2009
Author:
Christophe Lauret
See Also:
RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax, RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax - Appendix A. Collected ABNF for URI, UAX #15: Unicode Normalization

Method Summary
static String decode(String s)
          Decode the string as valid URI fragment.
static String encode(String s)
          Encodes the string as valid URI fragment.
static String encode(String s, char c)
          Encodes the string as valid URI fragment.
static String minimalEncode(String s)
          Encodes the string as valid URI fragment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static String encode(String s)
Encodes the string as valid URI fragment.

This encoder will encode all but unreserved characters using the escape sequence.

Parameters:
s - The string to encode.
Returns:
The corresponding encoded string.

encode

public static String encode(String s,
                            char c)
Encodes the string as valid URI fragment.

This encoder will percent-encode all but unreserved characters.

Parameters:
s - The string to encode.
c - An ASCII character that should not be encoded if found in the string.
Returns:
The corresponding encoded string.

minimalEncode

public static String minimalEncode(String s)
Encodes the string as valid URI fragment.

This encoder will percent-encode all but illegal characters.

Parameters:
s - The string to encode.
Returns:
The corresponding encoded string.

decode

public static String decode(String s)
Decode the string as valid URI fragment.

Parameters:
s - The string to decode.
Returns:
The corresponding decoded string.