com.sibvisions.util.type
Class CodecUtil

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

public final class CodecUtil
extends java.lang.Object

The CodecUtil contains methods for encode and decode operations.


Method Summary
static java.lang.String decodeHex(java.lang.String pHex)
          Decodes a hex, utf-8 encoded text to a string.
static byte[] decodeHexAsBytes(java.lang.String pHex)
          Decodes a hex, utf-8 encoded text to a string.
static java.lang.String decodeHtml(java.lang.String pHtml)
          Encodes raw html to text.
static java.lang.String decodeURLParameter(java.lang.String pValue)
          Decodes an encoded value from an URL query parameter with ISO-8859-1.
static java.lang.String decodeURLParameter(java.lang.String pValue, java.lang.String pEncoding)
          Decodes an encoded value from an URL query parameter with a specific charset.
static java.lang.String decodeURLPart(java.lang.String pURL)
          Decodes the part of an URL with UTF-8.
static java.lang.String encodeHex(byte[] pContent)
          Encodes a list of bytes to a hex encoded string.
static java.lang.String encodeHex(java.io.InputStream pStream)
          Encodes a stream to a hex encoded string.
static java.lang.String encodeHex(java.lang.String pText)
          Encodes a text to a hex encoded string.
static java.lang.String encodeHtml(java.lang.String pText)
          Encodes a text to raw html.
static java.lang.String encodeURLParameter(java.lang.String pValue)
          Encodes a plain value for an URL query parameter with ISO-8859-1.
static java.lang.String encodeURLParameter(java.lang.String pValue, java.lang.String pEncoding)
          Encodes a plain value for an URL query parameter with a specific charset.
static java.lang.String encodeURLPart(java.lang.String pPart)
          Encodes the part for an URL with UTF-8 encoding.
static java.lang.String encodeURLPart(java.lang.String pPart, java.lang.String pEncoding)
          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 java.lang.String encodeURLPart(java.lang.String pPart)
Encodes the part for an URL with UTF-8 encoding.

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

encodeURLPart

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

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

encodeURLParameter

public static java.lang.String encodeURLParameter(java.lang.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 java.lang.String encodeURLParameter(java.lang.String pValue,
                                                  java.lang.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 java.lang.String decodeURLPart(java.lang.String pURL)
Decodes the part of an URL with UTF-8.

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

decodeURLParameter

public static java.lang.String decodeURLParameter(java.lang.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 java.lang.String decodeURLParameter(java.lang.String pValue,
                                                  java.lang.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 java.lang.String encodeHtml(java.lang.String pText)
Encodes a text to raw html.

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

decodeHtml

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

Parameters:
pHtml - the html code
Returns:
the text

encodeHex

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

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

encodeHex

public static java.lang.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 java.lang.String encodeHex(java.io.InputStream pStream)
                                  throws java.io.IOException
Encodes a stream to a hex encoded string.

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

decodeHex

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

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

decodeHexAsBytes

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

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


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.