com.novell.sentinel.uri
Class PercentCodex

java.lang.Object
  extended by com.novell.sentinel.uri.PercentCodex

public class PercentCodex
extends Object

Class for encoding and decoding URI components.


Field Summary
static String BASE_RESERVED_CHARS
          The set of general delims (gen-delims) in RFC 3986.
 
Constructor Summary
PercentCodex()
          Construct a default codex that will encode spaces and the "gen-delims" from RFC 3986
PercentCodex(String additionalReservedChars)
          Construct a codex that will encode spaces, the "gen-delims" from RFC 3986, plus any additional characters passed.
PercentCodex(String additionalReservedChars, String removedReservedChars)
          Construct a codex that will encode spaces, the "gen-delims" from RFC 3986, plus any additional characters passed, minus any specified characters.
 
Method Summary
protected static String _decode(CharSequence string, boolean strict)
          Decode the passed character sequence.
static String decode(CharSequence string)
          Decode the passed percent-encoded string.
static String decodeStrict(CharSequence string)
          Decode the passed percent-encoded string, throwing an exception if an illegal percent-encoded sequence is found.
 String encode(CharSequence string)
          Encode spaces and any "reserved" characters set in this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_RESERVED_CHARS

public static final String BASE_RESERVED_CHARS
The set of general delims (gen-delims) in RFC 3986.

See Also:
Constant Field Values
Constructor Detail

PercentCodex

public PercentCodex()
Construct a default codex that will encode spaces and the "gen-delims" from RFC 3986


PercentCodex

public PercentCodex(String additionalReservedChars)
Construct a codex that will encode spaces, the "gen-delims" from RFC 3986, plus any additional characters passed.

Parameters:
additionalReservedChars - Additional characters that must be percent-encoded.

PercentCodex

public PercentCodex(String additionalReservedChars,
                    String removedReservedChars)
Construct a codex that will encode spaces, the "gen-delims" from RFC 3986, plus any additional characters passed, minus any specified characters.

Parameters:
additionalReservedChars - Additional characters that must be percent-encoded.
removedReservedChars - Characters to remove from the "gen-delims" set.
Method Detail

encode

public String encode(CharSequence string)
Encode spaces and any "reserved" characters set in this instance.

Parameters:
string - The characters to encode.
Returns:
The encoded string.

decodeStrict

public static String decodeStrict(CharSequence string)
                           throws ParseException
Decode the passed percent-encoded string, throwing an exception if an illegal percent-encoded sequence is found.

Parameters:
string - The characters to decode.
Returns:
The decoded string.
Throws:
ParseException - if an illegal sequence is found.

decode

public static String decode(CharSequence string)
Decode the passed percent-encoded string. If any illegal percent encoded sequence is found, return it as-is.

Parameters:
string - The characters to decode.
Returns:
The decoded string.

_decode

protected static String _decode(CharSequence string,
                                boolean strict)
                         throws ParseException
Decode the passed character sequence.

Parameters:
string - The characters to decode.
strict - If true, throw an exception if an illegal percent-encoded sequence is found, otherwise, just return the illegal sequence as-is.
Returns:
The decoded string.
Throws:
ParseException - If strict is true, and an illegal sequence is found.