org.deri.iris.builtins.string
Class PercentEncoder

java.lang.Object
  extended by org.deri.iris.builtins.string.PercentEncoder

public class PercentEncoder
extends Object

A helper class for percent-encoding. Only those characters are encoded, that are not in the set of unreserved characters. Per default the set of unreserved characters consists of the characters defined in RFC 3986 section 2.3.


Constructor Summary
PercentEncoder()
          Creates a new instance of PercentEncoder.
 
Method Summary
 String encode(String string)
          Percent-encodes the given string according to the sets of reserved and unreserved characters.
 void reserve(char character)
          Puts the given character in the set of reserved characters.
 void reserve(char[] characters)
          Puts all character in the given array of characters in the set of reserved characters.
 void reserve(int codePoint)
          Puts the given code point in the set of reserved characters.
 void reserveAll()
          Puts all characters in the set of reserved character.
 void unreserve(char character)
          Puts the given character in the set of unreserved characters.
 void unreserve(char[] characters)
          Puts all character in the given array of characters in the set of unreserved characters.
 void unreserve(int codePoint)
          Puts the given code point in the set of unreserved characters.
 void unreserveAll()
          Puts all characters in the set of unreserved character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PercentEncoder

public PercentEncoder()
Creates a new instance of PercentEncoder.

Method Detail

reserve

public void reserve(int codePoint)
Puts the given code point in the set of reserved characters.

Parameters:
codePoint - The code point to be put in the set of reserved characters.

reserve

public void reserve(char character)
Puts the given character in the set of reserved characters.

Parameters:
character - The character to be put in the set of reserved characters.

reserve

public void reserve(char[] characters)
Puts all character in the given array of characters in the set of reserved characters.

Parameters:
characters - The array of characters to be put in the set of reserved characters.

reserveAll

public void reserveAll()
Puts all characters in the set of reserved character. After this method has been called, all characters are percent encoded.


unreserve

public void unreserve(int codePoint)
Puts the given code point in the set of unreserved characters.

Parameters:
codePoint - The code point to be put in the set of unreserved characters.

unreserve

public void unreserve(char character)
Puts the given character in the set of unreserved characters.

Parameters:
codePoint - The character to be put in the set of unreserved characters.

unreserve

public void unreserve(char[] characters)
Puts all character in the given array of characters in the set of unreserved characters.

Parameters:
characters - The array of characters to be put in the set of unreserved characters.

unreserveAll

public void unreserveAll()
Puts all characters in the set of unreserved character. After this method has been called, no characters are percent encoded.


encode

public String encode(String string)
Percent-encodes the given string according to the sets of reserved and unreserved characters.

Parameters:
string - The String to be percent-encoded.
Returns:
The percent-encoded String.