Debian Codegraph @

lang/sql/jdbc/doc/SQLite/StringEncoder.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <!--NewPage-->
3 <HTML>
4 <HEAD>
5 <!-- Generated by javadoc (build 1.4.2_03) on Thu Feb 09 06:54:01 CET 2012 -->
6 <TITLE>
7 StringEncoder (SQLite Java Wrapper)
8 </TITLE>
9
10 <META NAME="keywords" CONTENT="SQLite.StringEncoder class">
11
12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../stylesheet.css" TITLE="Style">
13
14 <SCRIPT type="text/javascript">
15 function windowTitle()
16 {
17 parent.document.title="StringEncoder (SQLite Java Wrapper)";
18 }
19 </SCRIPT>
20
21 </HEAD>
22
23 <BODY BGCOLOR="white" onload="windowTitle();">
24
25
26 <!-- ========= START OF TOP NAVBAR ======= -->
27 <A NAME="navbar_top"><!-- --></A>
28 <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
29 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
30 <TR>
31 <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
32 <A NAME="navbar_top_firstrow"><!-- --></A>
33 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
34 <TR ALIGN="center" VALIGN="top">
35 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
36 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
37 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
38 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
39 </TR>
40 </TABLE>
41 </TD>
42 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
43 </EM>
44 </TD>
45 </TR>
46
47 <TR>
48 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
49 &nbsp;<A HREF="../SQLite/Stmt.html" title="class in SQLite"><B>PREV CLASS</B></A>&nbsp;
50 &nbsp;<A HREF="../SQLite/TableResult.html" title="class in SQLite"><B>NEXT CLASS</B></A></FONT></TD>
51 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
52 <A HREF="../index.html" target="_top"><B>FRAMES</B></A> &nbsp;
53 &nbsp;<A HREF="StringEncoder.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
54 &nbsp;<SCRIPT type="text/javascript">
55 <!--
56 if(window==top) {
57 document.writeln('<A HREF="../allclasses-noframe.html"><B>All Classes</B></A>');
58 }
59 //-->
60 </SCRIPT>
61 <NOSCRIPT>
62 <A HREF="../allclasses-noframe.html"><B>All Classes</B></A>
63 </NOSCRIPT>
64
65 </FONT></TD>
66 </TR>
67 <TR>
68 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
69 SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
70 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
71 DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
72 </TR>
73 </TABLE>
74 <A NAME="skip-navbar_top"></A>
75 <!-- ========= END OF TOP NAVBAR ========= -->
76
77 <HR>
78 <!-- ======== START OF CLASS DATA ======== -->
79 <H2>
80 <FONT SIZE="-1">
81 SQLite</FONT>
82 <BR>
83 Class StringEncoder</H2>
84 <PRE>
85 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>
86 <IMG SRC="../resources/inherit.gif" ALT="extended by"><B>SQLite.StringEncoder</B>
87 </PRE>
88 <HR>
89 <DL>
90 <DT>public class <B>StringEncoder</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></DL>
91
92 <P>
93 String encoder/decoder for SQLite.
94
95 This module was kindly donated by Eric van der Maarel of Nedap N.V.
96
97 This encoder was implemented based on an original idea from an anonymous
98 author in the source code of the SQLite distribution.
99 I feel obliged to provide a quote from the original C-source code:
100
101 "The author disclaims copyright to this source code. In place of
102 a legal notice, here is a blessing:
103
104 May you do good and not evil.
105 May you find forgiveness for yourself and forgive others.
106 May you share freely, never taking more than you give."
107 <P>
108
109 <P>
110 <HR>
111
112 <P>
113 <!-- ======== NESTED CLASS SUMMARY ======== -->
114
115
116 <!-- =========== FIELD SUMMARY =========== -->
117
118 <A NAME="field_summary"><!-- --></A>
119 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
120 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
121 <TD COLSPAN=2><FONT SIZE="+2">
122 <B>Field Summary</B></FONT></TD>
123 </TR>
124 <TR BGCOLOR="white" CLASS="TableRowColor">
125 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
126 <CODE>(package private) static&nbsp;char[]</CODE></FONT></TD>
127 <TD><CODE><B><A HREF="../SQLite/StringEncoder.html#xdigits">xdigits</A></B></CODE>
128
129 <BR>
130 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
131 </TR>
132 </TABLE>
133 &nbsp;
134 <!-- ======== CONSTRUCTOR SUMMARY ======== -->
135
136 <A NAME="constructor_summary"><!-- --></A>
137 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
138 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
139 <TD COLSPAN=2><FONT SIZE="+2">
140 <B>Constructor Summary</B></FONT></TD>
141 </TR>
142 <TR BGCOLOR="white" CLASS="TableRowColor">
143 <TD><CODE><B><A HREF="../SQLite/StringEncoder.html#StringEncoder()">StringEncoder</A></B>()</CODE>
144
145 <BR>
146 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
147 </TR>
148 </TABLE>
149 &nbsp;
150 <!-- ========== METHOD SUMMARY =========== -->
151
152 <A NAME="method_summary"><!-- --></A>
153 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
154 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
155 <TD COLSPAN=2><FONT SIZE="+2">
156 <B>Method Summary</B></FONT></TD>
157 </TR>
158 <TR BGCOLOR="white" CLASS="TableRowColor">
159 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
160 <CODE>private static&nbsp;byte[]</CODE></FONT></TD>
161 <TD><CODE><B><A HREF="../SQLite/StringEncoder.html#byteCopy(byte[], int, int, byte[])">byteCopy</A></B>(byte[]&nbsp;source,
162 int&nbsp;offset,
163 int&nbsp;count,
164 byte[]&nbsp;target)</CODE>
165
166 <BR>
167 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copies count elements from source, starting at element with
168 index offset, to the given target.</TD>
169 </TR>
170 <TR BGCOLOR="white" CLASS="TableRowColor">
171 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
172 <CODE>static&nbsp;byte[]</CODE></FONT></TD>
173 <TD><CODE><B><A HREF="../SQLite/StringEncoder.html#decode(java.lang.String)">decode</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;s)</CODE>
174
175 <BR>
176 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decodes the given string that is assumed to be a valid encoding
177 of a byte array.</TD>
178 </TR>
179 <TR BGCOLOR="white" CLASS="TableRowColor">
180 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
181 <CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD>
182 <TD><CODE><B><A HREF="../SQLite/StringEncoder.html#encode(byte[])">encode</A></B>(byte[]&nbsp;a)</CODE>
183
184 <BR>
185 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Encodes the given byte array into a string that can be used by
186 the SQLite database.</TD>
187 </TR>
188 <TR BGCOLOR="white" CLASS="TableRowColor">
189 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
190 <CODE>static&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD>
191 <TD><CODE><B><A HREF="../SQLite/StringEncoder.html#encodeX(byte[])">encodeX</A></B>(byte[]&nbsp;a)</CODE>
192
193 <BR>
194 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Encodes the given byte array into SQLite3 blob notation, ie X'..'</TD>
195 </TR>
196 </TABLE>
197 &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
198 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
199 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
200 <TD><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TD>
201 </TR>
202 <TR BGCOLOR="white" CLASS="TableRowColor">
203 <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
204 </TR>
205 </TABLE>
206 &nbsp;
207 <P>
208
209 <!-- ============ FIELD DETAIL =========== -->
210
211 <A NAME="field_detail"><!-- --></A>
212 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
213 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
214 <TD COLSPAN=1><FONT SIZE="+2">
215 <B>Field Detail</B></FONT></TD>
216 </TR>
217 </TABLE>
218
219 <A NAME="xdigits"><!-- --></A><H3>
220 xdigits</H3>
221 <PRE>
222 static final char[] <B>xdigits</B></PRE>
223 <DL>
224 <DL>
225 </DL>
226 </DL>
227
228 <!-- ========= CONSTRUCTOR DETAIL ======== -->
229
230 <A NAME="constructor_detail"><!-- --></A>
231 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
232 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
233 <TD COLSPAN=1><FONT SIZE="+2">
234 <B>Constructor Detail</B></FONT></TD>
235 </TR>
236 </TABLE>
237
238 <A NAME="StringEncoder()"><!-- --></A><H3>
239 StringEncoder</H3>
240 <PRE>
241 public <B>StringEncoder</B>()</PRE>
242 <DL>
243 </DL>
244
245 <!-- ============ METHOD DETAIL ========== -->
246
247 <A NAME="method_detail"><!-- --></A>
248 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
249 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
250 <TD COLSPAN=1><FONT SIZE="+2">
251 <B>Method Detail</B></FONT></TD>
252 </TR>
253 </TABLE>
254
255 <A NAME="byteCopy(byte[], int, int, byte[])"><!-- --></A><H3>
256 byteCopy</H3>
257 <PRE>
258 private static byte[] <B>byteCopy</B>(byte[]&nbsp;source,
259 int&nbsp;offset,
260 int&nbsp;count,
261 byte[]&nbsp;target)</PRE>
262 <DL>
263 <DD>Copies count elements from source, starting at element with
264 index offset, to the given target.
265 <P>
266 <DD><DL>
267 <DT><B>Parameters:</B><DD><CODE>source</CODE> - the source.<DD><CODE>offset</CODE> - the offset.<DD><CODE>count</CODE> - the number of elements to be copied.<DD><CODE>target</CODE> - the target to be returned.
268 <DT><B>Returns:</B><DD>the target being copied to.</DL>
269 </DD>
270 </DL>
271 <HR>
272
273 <A NAME="decode(java.lang.String)"><!-- --></A><H3>
274 decode</H3>
275 <PRE>
276 public static byte[] <B>decode</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;s)</PRE>
277 <DL>
278 <DD>Decodes the given string that is assumed to be a valid encoding
279 of a byte array. Typically the given string is generated by
280 this class' <code>encode</code> method.
281 <P>
282 <DD><DL>
283 <DT><B>Parameters:</B><DD><CODE>s</CODE> - the given string encoding.
284 <DT><B>Returns:</B><DD>the byte array obtained from the decoding.
285 <DT><B>Throws:</B>
286 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when the string given is not
287 a valid encoded string for this encoder.</DL>
288 </DD>
289 </DL>
290 <HR>
291
292 <A NAME="encode(byte[])"><!-- --></A><H3>
293 encode</H3>
294 <PRE>
295 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encode</B>(byte[]&nbsp;a)</PRE>
296 <DL>
297 <DD>Encodes the given byte array into a string that can be used by
298 the SQLite database. The database cannot handle null (0x00) and
299 the character '\'' (0x27). The encoding consists of escaping
300 these characters with a reserved character (0x01). The escaping
301 is applied after determining and applying a shift that minimizes
302 the number of escapes required.
303 With this encoding the data of original size n is increased to a
304 maximum of 1+(n*257)/254.
305 For sufficiently large n the overhead is thus less than 1.2%.
306 <P>
307 <DD><DL>
308 <DT><B>Parameters:</B><DD><CODE>a</CODE> - the byte array to be encoded. A null reference is handled as
309 an empty array.
310 <DT><B>Returns:</B><DD>the encoded bytes as a string. When an empty array is
311 provided a string of length 1 is returned, the value of
312 which is bogus.
313 When decoded with this class' <code>decode</code> method
314 a string of size 1 will return an empty byte array.</DL>
315 </DD>
316 </DL>
317 <HR>
318
319 <A NAME="encodeX(byte[])"><!-- --></A><H3>
320 encodeX</H3>
321 <PRE>
322 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encodeX</B>(byte[]&nbsp;a)</PRE>
323 <DL>
324 <DD>Encodes the given byte array into SQLite3 blob notation, ie X'..'
325 <P>
326 <DD><DL>
327 <DT><B>Parameters:</B><DD><CODE>a</CODE> - the byte array to be encoded. A null reference is handled as
328 an empty array.
329 <DT><B>Returns:</B><DD>the encoded bytes as a string.</DL>
330 </DD>
331 </DL>
332 <!-- ========= END OF CLASS DATA ========= -->
333 <HR>
334
335
336 <!-- ======= START OF BOTTOM NAVBAR ====== -->
337 <A NAME="navbar_bottom"><!-- --></A>
338 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
339 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
340 <TR>
341 <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
342 <A NAME="navbar_bottom_firstrow"><!-- --></A>
343 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
344 <TR ALIGN="center" VALIGN="top">
345 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
346 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
347 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
348 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
349 </TR>
350 </TABLE>
351 </TD>
352 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
353 </EM>
354 </TD>
355 </TR>
356
357 <TR>
358 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
359 &nbsp;<A HREF="../SQLite/Stmt.html" title="class in SQLite"><B>PREV CLASS</B></A>&nbsp;
360 &nbsp;<A HREF="../SQLite/TableResult.html" title="class in SQLite"><B>NEXT CLASS</B></A></FONT></TD>
361 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
362 <A HREF="../index.html" target="_top"><B>FRAMES</B></A> &nbsp;
363 &nbsp;<A HREF="StringEncoder.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
364 &nbsp;<SCRIPT type="text/javascript">
365 <!--
366 if(window==top) {
367 document.writeln('<A HREF="../allclasses-noframe.html"><B>All Classes</B></A>');
368 }
369 //-->
370 </SCRIPT>
371 <NOSCRIPT>
372 <A HREF="../allclasses-noframe.html"><B>All Classes</B></A>
373 </NOSCRIPT>
374
375 </FONT></TD>
376 </TR>
377 <TR>
378 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
379 SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
380 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
381 DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
382 </TR>
383 </TABLE>
384 <A NAME="skip-navbar_bottom"></A>
385 <!-- ======== END OF BOTTOM NAVBAR ======= -->
386
387 <HR>
388 <small>Contact: <a HREF="mailto:[email protected]">Christian Werner</a></small>
389 </BODY>
390 </HTML>