Class Codec

java.lang.Object
de.uplanet.lucy.server.auxiliaries.Codec

@VelocityCallable("singleton") public final class Codec extends Object
Encoder/decoder utility class for use in the Velocity context.
  • Constructor Details

    • Codec

      public Codec()
      Construct the object.
  • Method Details

    • hexEncodeString

      public String hexEncodeString(String p_str)
      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

      public String hexDecodeString(String p_str)
      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

      public String hexDecodeString(String p_str, String p_strCharset)
      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

      public String base64EncodeString(String p_str)
      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

      public String base64DecodeString(String p_str)
      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

      public String quotedPrintableEncodeString(String p_str)
      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

      public String quotedPrintableDecodeString(String p_str)
      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

      public String encodeURIComponent(CharSequence p_chseq)
      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

      public String 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.
      Parameters:
      p_chseq - The characters to be encoded.
      p_strCharset - The character set to be used for encoding.
      Returns:
      The encoded characters.
    • urlEncodeString

      public String urlEncodeString(String p_str) throws UnsupportedEncodingException
      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

      public String urlDecodeString(String p_str) throws UnsupportedEncodingException
      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.