org.kde.koala
Class KCodecs

java.lang.Object
  extended by org.kde.koala.KCodecs
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KCodecs
extends java.lang.Object
implements org.kde.qt.QtSupport

A wrapper class for the most commonly used encoding and decoding algorithms. Currently there is support for encoding and decoding input using base64, uu and the quoted-printable specifications. sage:

 String input = "Aladdin:open sesame";
 String result = KCodecs.base64Encode(input);
 cout << "Result: " << result.data() << endl;
 
 Output should be
 Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ==
 
The above example makes use of the convenience functions (ones that accept/return null-terminated strings) to encode/decode a string. If what you need is to encode or decode binary data, then it is highly recommended that you use the functions that take an input and output byte[] as arguments. These functions are specifically tailored for encoding and decoding binary data.

Author:
Rik Hemsley

Constructor Summary
protected KCodecs(java.lang.Class dummy)
           
 
Method Summary
static java.lang.String base64Decode(byte[] in)
          Decodes the given data that was encoded using the base64 algorithm.
static void base64Decode(byte[] in, byte[] out)
          Decodes the given data that was encoded with the base64 algorithm.
static java.lang.String base64Decode(java.lang.String str)
           
static java.lang.String base64Encode(byte[] in)
           
static java.lang.String base64Encode(byte[] in, boolean insertLFs)
          Encodes the given data using the base64 algorithm.
static void base64Encode(byte[] in, byte[] out)
           
static void base64Encode(byte[] in, byte[] out, boolean insertLFs)
          Encodes the given data using the base64 algorithm.
static java.lang.String base64Encode(java.lang.String str)
           
static java.lang.String base64Encode(java.lang.String str, boolean insertLFs)
           
static java.lang.String quotedPrintableDecode(byte[] in)
          Decodes a quoted-printable encoded data.
static void quotedPrintableDecode(byte[] in, byte[] out)
          Decodes a quoted-printable encoded data.
static java.lang.String quotedPrintableDecode(java.lang.String str)
           
static java.lang.String quotedPrintableEncode(byte[] in)
           
static java.lang.String quotedPrintableEncode(byte[] in, boolean useCRLF)
          Encodes the given data using the quoted-printable algorithm.
static void quotedPrintableEncode(byte[] in, byte[] out, boolean useCRLF)
          Encodes the given data using the quoted-printable algorithm.
static java.lang.String quotedPrintableEncode(java.lang.String str)
           
static java.lang.String quotedPrintableEncode(java.lang.String str, boolean useCRLF)
           
static java.lang.String uudecode(byte[] in)
          Decodes the given data using the uudecode algorithm.
static void uudecode(byte[] in, byte[] out)
          Decodes the given data using the uudecode algorithm.
static java.lang.String uudecode(java.lang.String str)
           
static java.lang.String uuencode(byte[] in)
          Encodes the given data using the uuencode algorithm.
static void uuencode(byte[] in, byte[] out)
          Encodes the given data using the uuencode algorithm.
static java.lang.String uuencode(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KCodecs

protected KCodecs(java.lang.Class dummy)
Method Detail

quotedPrintableEncode

public static java.lang.String quotedPrintableEncode(byte[] in,
                                                     boolean useCRLF)
Encodes the given data using the quoted-printable algorithm.

Parameters:
in - data to be encoded.
useCRLF - if true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too.
Returns:
quoted-printable encoded string.

quotedPrintableEncode

public static java.lang.String quotedPrintableEncode(byte[] in)

quotedPrintableEncode

public static java.lang.String quotedPrintableEncode(java.lang.String str,
                                                     boolean useCRLF)
Parameters:
str - string to be encoded.
useCRLF - if true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too.
Returns:
quoted-printable encoded string.

quotedPrintableEncode

public static java.lang.String quotedPrintableEncode(java.lang.String str)

quotedPrintableEncode

public static void quotedPrintableEncode(byte[] in,
                                         byte[] out,
                                         boolean useCRLF)
Encodes the given data using the quoted-printable algorithm. Use this function if you want the result of the encoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for encoding binary data. NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.

Parameters:
in - data to be encoded.
out - encoded data.
useCRLF - if true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too.

quotedPrintableDecode

public static java.lang.String quotedPrintableDecode(byte[] in)
Decodes a quoted-printable encoded data. Accepts data with CRLF or standard unix line breaks.

Parameters:
in - data to be decoded.
Returns:
decoded string.

quotedPrintableDecode

public static java.lang.String quotedPrintableDecode(java.lang.String str)
Parameters:
str - string to be decoded.
Returns:
decoded string.

quotedPrintableDecode

public static void quotedPrintableDecode(byte[] in,
                                         byte[] out)
Decodes a quoted-printable encoded data. Accepts data with CRLF or standard unix line breaks. Use this function if you want the result of the decoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for decoding an encoded binary data. NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.

Parameters:
in - data to be decoded.
out - decoded data.

uuencode

public static java.lang.String uuencode(byte[] in)
Encodes the given data using the uuencode algorithm. The output is split into lines starting with the number of encoded octets in the line and ending with a newline. No line is longer than 45 octets (60 characters), excluding the line terminator.

Parameters:
in - data to be uuencoded
Returns:
uuencoded string.

uuencode

public static java.lang.String uuencode(java.lang.String str)
Parameters:
str - string to be uuencoded.
Returns:
encoded string.

uuencode

public static void uuencode(byte[] in,
                            byte[] out)
Encodes the given data using the uuencode algorithm. Use this function if you want the result of the encoding to be placed in another array and cut down the number of copy operation that have to be performed in the process. This is the preffered method for encoding binary data. NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.

Parameters:
in - data to be uuencoded.
out - uudecoded data.

uudecode

public static java.lang.String uudecode(byte[] in)
Decodes the given data using the uudecode algorithm. Any 'begin' and 'end' lines like those generated by the utilities in unix and unix-like OS will be automatically ignored.

Parameters:
in - data to be decoded.
Returns:
decoded string.

uudecode

public static java.lang.String uudecode(java.lang.String str)
Parameters:
str - string to be decoded.
Returns:
uudecoded string.

uudecode

public static void uudecode(byte[] in,
                            byte[] out)
Decodes the given data using the uudecode algorithm. Use this function if you want the result of the decoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is the preferred method for decoding binary data. Any 'begin' and 'end' lines like those generated by the utilities in unix and unix-like OS will be automatically ignored. NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.

Parameters:
in - data to be decoded.
out - uudecoded data.

base64Encode

public static java.lang.String base64Encode(byte[] in,
                                            boolean insertLFs)
Encodes the given data using the base64 algorithm. The booleanean argument determines if the encoded data is going to be restricted to 76 characters or less per line as specified by RFC 2045. If insertLFs is true, then there will be 76 characters or less per line.

Parameters:
in - data to be encoded.
insertLFs - limit the number of characters per line.
Returns:
base64 encoded string.

base64Encode

public static java.lang.String base64Encode(byte[] in)

base64Encode

public static java.lang.String base64Encode(java.lang.String str,
                                            boolean insertLFs)
Parameters:
str - string to be encoded.
insertLFs - limit the number of characters per line.
Returns:
decoded string.

base64Encode

public static java.lang.String base64Encode(java.lang.String str)

base64Encode

public static void base64Encode(byte[] in,
                                byte[] out,
                                boolean insertLFs)
Encodes the given data using the base64 algorithm. Use this function if you want the result of the encoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for encoding binary data. The booleanean argument determines if the encoded data is going to be restricted to 76 characters or less per line as specified by RFC 2045. If insertLFs is true, then there will be 76 characters or less per line. NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.

Parameters:
in - data to be encoded.
out - encoded data.
insertLFs - limit the number of characters per line.

base64Encode

public static void base64Encode(byte[] in,
                                byte[] out)

base64Decode

public static java.lang.String base64Decode(byte[] in)
Decodes the given data that was encoded using the base64 algorithm.

Parameters:
in - data to be decoded.
Returns:
decoded string.

base64Decode

public static java.lang.String base64Decode(java.lang.String str)
Parameters:
str - string to be decoded.
Returns:
decoded string.

base64Decode

public static void base64Decode(byte[] in,
                                byte[] out)
Decodes the given data that was encoded with the base64 algorithm. Use this function if you want the result of the decoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for decoding an encoded binary data. NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.

Parameters:
in - data to be decoded.
out - decoded data.