addressbuilder/src/main/java/org/ocpsoft/urlbuilder/util/Encoder.java
public static String query(CharSequence s) throws IllegalArgumentException
   {
      try {
         return URLEncoder.encode(s.toString(), UTF8.name());
      }
      catch (UnsupportedEncodingException e) {
         throw new IllegalArgumentException(e);
      }
   }
public static String query(CharSequence s) throws IllegalArgumentException
   {
      try {
         return URLEncoder.encode(s.toString(), UTF8.name());
      }
      catch (UnsupportedEncodingException e) {
         throw new IllegalArgumentException(e);
      }
   }
Encodes the given string using HTML form encoding as described in RFC 2396.

@throws IllegalArgumentException when illegal URI syntax is attempted.