summaryrefslogtreecommitdiffstats
path: root/tdejava/koala/org/trinitydesktop/koala/KCodecs.java
blob: 4a622d8ffb7ce6baa64e12d274f674bfddb7f29c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
//Auto-generated by kalyptus. DO NOT EDIT.
package org.trinitydesktop.koala;

import org.trinitydesktop.qt.Qt;
import org.trinitydesktop.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.
 <b></b>sage:
 <pre>
 String input = "Aladdin:open sesame";
 String result = KCodecs.base64Encode(input);
 cout << "Result: " << result.data() << endl;
 </pre>
 <pre>
 Output should be
 Result: TQWxhZGRpbjpvcGVuIHNlc2FtZQ==
 </pre>
 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 <rik@kde.org>

		@short A collection of commonly used encoding and decoding algorithms.

*/
public class KCodecs implements QtSupport {
	private long _qt;
	private boolean _allocatedInJavaWorld = true;
	protected KCodecs(Class dummy){}

	/**
		 Encodes the given data using the quoted-printable algorithm.
			@param in data to be encoded.
			@param useCRLF if true the input data is expected to have
		                CRLF line breaks and the output will have CRLF line
		                breaks, too.
				@return quoted-printable encoded string.

		@short    Encodes the given data using the quoted-printable algorithm.
	*/
	public static native String quotedPrintableEncode(byte[] in, boolean useCRLF);
	public static native String quotedPrintableEncode(byte[] in);
	/**
		 @overload
			 Same as above except it accepts a null terminated
		 string instead an array.
			@param str string to be encoded.
			@param useCRLF if true the input data is expected to have
		                CRLF line breaks and the output will have CRLF line
		                breaks, too.
				@return quoted-printable encoded string.

		@short    @overload
	*/
	public static native String quotedPrintableEncode(String str, boolean useCRLF);
	public static native String quotedPrintableEncode(String str);
	/**
		 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.
			@param in data to be encoded.
			@param out encoded data.
			@param useCRLF if true the input data is expected to have
		                CRLF line breaks and the output will have CRLF line
		                breaks, too.
		   		@short    Encodes the given data using the quoted-printable algorithm.
	*/
	public static native void quotedPrintableEncode(byte[] in, byte[] out, boolean useCRLF);
	/**
		 Decodes a quoted-printable encoded data.
			 Accepts data with CRLF or standard unix line breaks.
			@param in data to be decoded.
				@return decoded string.

		@short    Decodes a quoted-printable encoded data.
	*/
	public static native String quotedPrintableDecode(byte[] in);
	/**
		 @overload
			 Same as above except it accepts a null terminated
		 string instead an array.
			@param str string to be decoded.
				@return decoded string.

		@short    @overload
	*/
	public static native String quotedPrintableDecode(String str);
	/**
		 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.
			@param in data to be decoded.
			@param out decoded data.
		   		@short    Decodes a quoted-printable encoded data.
	*/
	public static native void quotedPrintableDecode(byte[] in, byte[] out);
	/**
		 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.
			@param in data to be uuencoded
				@return uuencoded string.

		@short    Encodes the given data using the uuencode algorithm.
	*/
	public static native String uuencode(byte[] in);
	/**
		 @overload
			 Same as the above functions except it accepts
		 a null terminated string instead an array.
			@param str string to be uuencoded.
				@return encoded string.

		@short    @overload
	*/
	public static native String uuencode(String str);
	/**
		 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.
			@param in data to be uuencoded.
			@param out uudecoded data.
		   		@short    Encodes the given data using the uuencode algorithm.
	*/
	public static native void uuencode(byte[] in, byte[] out);
	/**
		 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.
			@param in data to be decoded.
				@return decoded string.

		@short    Decodes the given data using the uudecode algorithm.
	*/
	public static native String uudecode(byte[] in);
	/**
		 @overload
			 Same as the above functions except it accepts
		 a null terminated string instead an array.
			@param str string to be decoded.
				@return uudecoded string.

		@short    @overload
	*/
	public static native String uudecode(String str);
	/**
		 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.
			@param in data to be decoded.
			@param out uudecoded data.
		   		@short    Decodes the given data using the uudecode algorithm.
	*/
	public static native void uudecode(byte[] in, byte[] out);
	/**
		 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 <code>insertLFs</code> is true, then
		 there will be 76 characters or less per line.
			@param in data to be encoded.
			@param insertLFs limit the number of characters per line.
				@return base64 encoded string.

		@short    Encodes the given data using the base64 algorithm.
	*/
	public static native String base64Encode(byte[] in, boolean insertLFs);
	public static native String base64Encode(byte[] in);
	/**
		 @overload
			 Same as the above functions except it accepts
		 a null terminated string instead an array.
			@param str string to be encoded.
			@param insertLFs limit the number of characters per line.
				@return decoded string.

		@short    @overload
	*/
	public static native String base64Encode(String str, boolean insertLFs);
	public static native String base64Encode(String str);
	/**
		 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 <code>insertLFs</code> 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.
			@param in data to be encoded.
			@param out encoded data.
			@param insertLFs limit the number of characters per line.
		   		@short    Encodes the given data using the base64 algorithm.
	*/
	public static native void base64Encode(byte[] in, byte[] out, boolean insertLFs);
	public static native void base64Encode(byte[] in, byte[] out);
	/**
		 Decodes the given data that was encoded using the
		 base64 algorithm.
			@param in data to be decoded.
				@return decoded string.

		@short    Decodes the given data that was encoded using the  base64 algorithm.
	*/
	public static native String base64Decode(byte[] in);
	/**
		 @overload
			 Same as the above functions except it accepts
		 a null terminated string instead an array.
			@param str string to be decoded.
				@return decoded string.

		@short    @overload
	*/
	public static native String base64Decode(String str);
	/**
		 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.
			@param in data to be decoded.
			@param out decoded data.
		   		@short    Decodes the given data that was encoded with the base64  algorithm.
	*/
	public static native void base64Decode(byte[] in, byte[] out);
}