com.sibvisions.util.type
Class CodecUtil

java.lang.Object
  extended by com.sibvisions.util.type.CodecUtil

public final class CodecUtil
extends Object

The CodecUtil contains methods for encode and decode operations.


Method Summary
static String decodeHex(String pHex)
          Decodes a hex, utf-8 encoded text to a string.
static byte[] decodeHexAsBytes(String pHex)
          Decodes a hex, utf-8 encoded text to a string.
static String decodeHtml(String pHtml)
          Encodes raw html to text.
static String decodeURLParameter(String pValue)
          Decodes an encoded value from an URL query parameter with ISO-8859-1.
static String decodeURLParameter(String pValue, String pEncoding)
          Decodes an encoded value from an URL query parameter with a specific charset.
static String decodeURLPart(String pURL)
          Decodes the part of an URL with UTF-8.
static String encodeHex(byte[] pContent)
          Encodes a list of bytes to a hex encoded string.
static String encodeHex(InputStream pStream)
          Encodes a stream to a hex encoded string.
static String encodeHex(String pText)
          Encodes a text to a hex encoded string.
static String encodeHtml(String pText)
          Encodes a text to raw html.
static String encodeURLParameter(String pValue)
          Encodes a plain value for an URL query parameter with ISO-8859-1.
static String encodeURLParameter(String pValue, String pEncoding)
          Encodes a plain value for an URL query parameter with a specific charset.
static String encodeURLPart(String pPart)
          Encodes the part for an URL with UTF-8 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeURLPart

public static String encodeURLPart(String pPart)
Encodes the part for an URL with UTF-8 encoding.

Parameters:
pPart - the url part
Returns:
the encoded part

encodeURLParameter

public static String encodeURLParameter(String pValue)
Encodes a plain value for an URL query parameter with ISO-8859-1.

Parameters:
pValue - the plain query parameter value
Returns:
the encoded value or null if ISO-8859-1 is not supported

encodeURLParameter

public static String encodeURLParameter(String pValue,
                                        String pEncoding)
Encodes a plain value for an URL query parameter with a specific charset.

Parameters:
pValue - the plain query parameter value
pEncoding - the charset e.g. UTF-8
Returns:
the encoded value or null if pEncoding is not supported

decodeURLPart

public static String decodeURLPart(String pURL)
Decodes the part of an URL with UTF-8.

Parameters:
pURL - the url part
Returns:
the decoded part

decodeURLParameter

public static String decodeURLParameter(String pValue)
Decodes an encoded value from an URL query parameter with ISO-8859-1.

Parameters:
pValue - the encoded query parameter value
Returns:
the plain value or null if ISO-8859-1 is not supported

decodeURLParameter

public static String decodeURLParameter(String pValue,
                                        String pEncoding)
Decodes an encoded value from an URL query parameter with a specific charset.

Parameters:
pValue - the encoded query parameter value
pEncoding - the charset e.g. UTF-8
Returns:
the plain value or null if pEncoding is not supported

encodeHtml

public static String encodeHtml(String pText)
Encodes a text to raw html.

Parameters:
pText - the text
Returns:
the html encoded text

decodeHtml

public static String decodeHtml(String pHtml)
Encodes raw html to text.

Parameters:
pHtml - the html code
Returns:
the text

encodeHex

public static String encodeHex(String pText)
                        throws UnsupportedEncodingException
Encodes a text to a hex encoded string.

Parameters:
pText - the plain text
Returns:
the encoded text
Throws:
UnsupportedEncodingException - if utf-8 encoding is not supported

encodeHex

public static String encodeHex(byte[] pContent)
Encodes a list of bytes to a hex encoded string.

Parameters:
pContent - the list of bytes
Returns:
the encoded text

encodeHex

public static String encodeHex(InputStream pStream)
                        throws IOException
Encodes a stream to a hex encoded string.

Parameters:
pStream - the stream
Returns:
the encoded text
Throws:
IOException - if stream reading fails

decodeHex

public static String decodeHex(String pHex)
                        throws UnsupportedEncodingException
Decodes a hex, utf-8 encoded text to a string.

Parameters:
pHex - the decoded text
Returns:
the plain text
Throws:
UnsupportedEncodingException - if utf-8 encoding is not supported

decodeHexAsBytes

public static byte[] decodeHexAsBytes(String pHex)
                               throws UnsupportedEncodingException
Decodes a hex, utf-8 encoded text to a string.

Parameters:
pHex - the decoded text
Returns:
the plain text
Throws:
UnsupportedEncodingException - if utf-8 encoding is not supported


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.