Class Codec
java.lang.Object
de.uplanet.lucy.server.auxiliaries.Codec
Encoder/decoder utility class for use in the Velocity context.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbase64DecodeString
(String p_str) Decode a Base64 encoded string, using the default character encoding, i.e,UTF-8
.base64DecodeString
(String p_str, String p_strCharset) Decode a Base64 encoded string, using the specified character encoding.base64EncodeString
(String p_str) Encode a string using Base64 encoding, using the default character encoding, i.e,UTF-8
.base64EncodeString
(String p_str, String p_strCharset) Encode a string using Base64 encoding.encodeURIComponent
(CharSequence p_chseq) Encode an URI component as described in the ECMAScript Language Specification, 5th edition, section 15.1.3.4.encodeURIComponent
(CharSequence p_chseq, String p_strCharset) Encode an URI component as described in the ECMAScript Language Specification, 5th edition, section 15.1.3.4.hexDecodeString
(String p_str) Decode a hex string to string, using the default character encoding, i.e,UTF-8
.hexDecodeString
(String p_str, String p_strCharset) Decode a hex string to string, using the specified character encoding.hexEncodeString
(String p_str) Encode a string to it's hex representation, using the default character encoding, i.e,UTF-8
.hexEncodeString
(String p_str, String p_strCharset) Encode a string to it's hex representation, using the specified character encoding.Decode a quoted printable encoded string, using the specified character encoding.quotedPrintableDecodeString
(String p_str, String p_strCharset) Decode a quoted printable encoded string, using the default character encoding, i.e,UTF-8
.Encode a string using quoted printable encoding, using the default character encoding, i.e,UTF-8
.quotedPrintableEncodeString
(String p_str, String p_strCharset) Encode a string using quoted printable encoding.urlDecodeString
(String p_str) URL-decode the given string, using UTF-8.urlDecodeString
(String p_str, String p_strCharset) URL-decode the given string, using the specified character encoding.urlEncodeString
(String p_str) URL-encode the given string, using UTF-8.urlEncodeString
(String p_str, String p_strCharset) URL-encode the given string, using the specified character encoding.
-
Constructor Details
-
Codec
public Codec()Construct the object.
-
-
Method Details
-
hexEncodeString
Encode a string to it's hex representation, using the default character encoding, i.e,UTF-8
.- Parameters:
p_str
- The string to encode.- Returns:
- The hex representation of the string.
-
hexEncodeString
public String hexEncodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException Encode a string to it's hex representation, using the specified character encoding.- Parameters:
p_str
- The string to encode.p_strCharset
- The charset to be used for encoding.- Returns:
- The hex representation of the string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
hexDecodeString
Decode a hex string to string, using the default character encoding, i.e,UTF-8
.- Parameters:
p_str
- The hex string to decode.- Returns:
- The decoded string.
-
hexDecodeString
Decode a hex string to string, using the specified character encoding.- Parameters:
p_str
- The hex string to decode.p_strCharset
- The charset to be used for decoding.- Returns:
- The decoded string, or
null
if the given string could not be hex-decoded (see error log for details).
-
base64EncodeString
Encode a string using Base64 encoding, using the default character encoding, i.e,UTF-8
.- Parameters:
p_str
- The string to encode.- Returns:
- The Base64 encoded string.
-
base64EncodeString
public String base64EncodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException Encode a string using Base64 encoding.- Parameters:
p_str
- The string to encode.p_strCharset
- The charset to be used for encoding.- Returns:
- The Base64 encoded string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
base64DecodeString
Decode a Base64 encoded string, using the default character encoding, i.e,UTF-8
.- Parameters:
p_str
- The Base64 encoded string.- Returns:
- The decoded string.
-
base64DecodeString
public String base64DecodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException Decode a Base64 encoded string, using the specified character encoding.- Parameters:
p_str
- The Base64 encoded string.p_strCharset
- The charset to be used for decoding.- Returns:
- The decoded string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
quotedPrintableEncodeString
Encode a string using quoted printable encoding, using the default character encoding, i.e,UTF-8
.- Parameters:
p_str
- The string to encode.- Returns:
- The quoted printable encoded string.
-
quotedPrintableEncodeString
public String quotedPrintableEncodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException Encode a string using quoted printable encoding.- Parameters:
p_str
- The string to encode.p_strCharset
- The charset to be used for encoding.- Returns:
- The quoted printable encoded string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
quotedPrintableDecodeString
Decode a quoted printable encoded string, using the specified character encoding.- Parameters:
p_str
- The quoted printable encoded string.- Returns:
- The decoded string.
-
quotedPrintableDecodeString
public String quotedPrintableDecodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException Decode a quoted printable encoded string, using the default character encoding, i.e,UTF-8
.- Parameters:
p_str
- The quoted printable encoded string.- Returns:
- The decoded string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
encodeURIComponent
Encode an URI component as described in the ECMAScript Language Specification, 5th edition, section 15.1.3.4.The charset used for encoding is UTF-8.
- Parameters:
p_chseq
- The characters to be encoded.- Returns:
- The encoded characters.
-
encodeURIComponent
Encode an URI component as described in the ECMAScript Language Specification, 5th edition, section 15.1.3.4.- Parameters:
p_chseq
- The characters to be encoded.p_strCharset
- The character set to be used for encoding.- Returns:
- The encoded characters.
-
urlEncodeString
URL-encode the given string, using UTF-8.See the application/x-www-form-urlencoded algorithm, and special characters in URI attribute values.
- Parameters:
p_str
- The string to be encoded.- Returns:
- The encoded string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
urlEncodeString
public String urlEncodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException URL-encode the given string, using the specified character encoding.See the application/x-www-form-urlencoded algorithm, and special characters in URI attribute values.
- Parameters:
p_str
- The string to be encoded.p_strCharset
- The charset to be used for encoding.- Returns:
- The encoded string.
- Throws:
UnsupportedEncodingException
- If the specified charset is not supported.
-
urlDecodeString
URL-decode the given string, using UTF-8.See the application/x-www-form-urlencoded algorithm, and special characters in URI attribute values.
- Parameters:
p_str
- The string to be decoded.- Returns:
- The decoded string.
- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
urlDecodeString
public String urlDecodeString(String p_str, String p_strCharset) throws UnsupportedEncodingException URL-decode the given string, using the specified character encoding.See the application/x-www-form-urlencoded algorithm, and special characters in URI attribute values.
- Parameters:
p_str
- The string to be decoded.p_strCharset
- The charset to be used for decoding.- Returns:
- The decoded string.
- Throws:
UnsupportedEncodingException
- If the specified charset is not supported.
-