Package helma.util
Class UrlEncoded
- java.lang.Object
-
- helma.util.UrlEncoded
-
public final class UrlEncoded extends java.lang.Object
A proxy to java.net.URLEncoder which only encodes when there is actual work to do. This is necessary because URLEncoder is quite inefficient (e.g. it preallocates buffers and stuff), and we call it often with short string that don't need encoding.
-
-
Constructor Summary
Constructors Constructor Description UrlEncoded()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
decode(java.lang.String str, java.lang.String encoding)
URL-decode a string using the given encoding, or return it unchanged if no encoding was necessary.static java.lang.String
encode(java.lang.String str, java.lang.String encoding)
URL-encodes a string using the given encoding, or return it unchanged if no encoding was necessary.
-
-
-
Method Detail
-
encode
public static java.lang.String encode(java.lang.String str, java.lang.String encoding) throws java.io.UnsupportedEncodingException
URL-encodes a string using the given encoding, or return it unchanged if no encoding was necessary.- Parameters:
str
- The string to be URL-encodedencoding
- the encoding to use- Returns:
- the URL-encoded string, or str if no encoding necessary
- Throws:
java.io.UnsupportedEncodingException
- encoding is not supported
-
decode
public static java.lang.String decode(java.lang.String str, java.lang.String encoding) throws java.io.UnsupportedEncodingException
URL-decode a string using the given encoding, or return it unchanged if no encoding was necessary.- Parameters:
str
- The string to be URL-decodedencoding
- the encoding to use- Returns:
- the URL-decoded string, or str if no decoding necessary
- Throws:
java.io.UnsupportedEncodingException
- encoding is not supported
-
-