xref: /aosp_15_r20/external/javasqlite/src/main/java/SQLite/FunctionContext.java (revision fd76c71b147b98c03334ec0945352cee0b39aab1)
1*fd76c71bSTreehugger Robot package SQLite;
2*fd76c71bSTreehugger Robot 
3*fd76c71bSTreehugger Robot /**
4*fd76c71bSTreehugger Robot  * Context for execution of SQLite's user defined functions.
5*fd76c71bSTreehugger Robot  * A reference to an instance of this class is passed to
6*fd76c71bSTreehugger Robot  * user defined functions.
7*fd76c71bSTreehugger Robot  */
8*fd76c71bSTreehugger Robot 
9*fd76c71bSTreehugger Robot public class FunctionContext {
10*fd76c71bSTreehugger Robot 
11*fd76c71bSTreehugger Robot     /**
12*fd76c71bSTreehugger Robot      * Internal handle for the native SQLite API.
13*fd76c71bSTreehugger Robot      */
14*fd76c71bSTreehugger Robot 
15*fd76c71bSTreehugger Robot     private long handle = 0;
16*fd76c71bSTreehugger Robot 
17*fd76c71bSTreehugger Robot     /**
18*fd76c71bSTreehugger Robot      * Set function result from string.
19*fd76c71bSTreehugger Robot      *
20*fd76c71bSTreehugger Robot      * @param r result string
21*fd76c71bSTreehugger Robot      */
22*fd76c71bSTreehugger Robot 
set_result(String r)23*fd76c71bSTreehugger Robot     public native void set_result(String r);
24*fd76c71bSTreehugger Robot 
25*fd76c71bSTreehugger Robot     /**
26*fd76c71bSTreehugger Robot      * Set function result from integer.
27*fd76c71bSTreehugger Robot      *
28*fd76c71bSTreehugger Robot      * @param r result integer
29*fd76c71bSTreehugger Robot      */
30*fd76c71bSTreehugger Robot 
set_result(int r)31*fd76c71bSTreehugger Robot     public native void set_result(int r);
32*fd76c71bSTreehugger Robot 
33*fd76c71bSTreehugger Robot     /**
34*fd76c71bSTreehugger Robot      * Set function result from double.
35*fd76c71bSTreehugger Robot      *
36*fd76c71bSTreehugger Robot      * @param r result double
37*fd76c71bSTreehugger Robot      */
38*fd76c71bSTreehugger Robot 
set_result(double r)39*fd76c71bSTreehugger Robot     public native void set_result(double r);
40*fd76c71bSTreehugger Robot 
41*fd76c71bSTreehugger Robot     /**
42*fd76c71bSTreehugger Robot      * Set function result from error message.
43*fd76c71bSTreehugger Robot      *
44*fd76c71bSTreehugger Robot      * @param r result string (error message)
45*fd76c71bSTreehugger Robot      */
46*fd76c71bSTreehugger Robot 
set_error(String r)47*fd76c71bSTreehugger Robot     public native void set_error(String r);
48*fd76c71bSTreehugger Robot 
49*fd76c71bSTreehugger Robot     /**
50*fd76c71bSTreehugger Robot      * Set function result from byte array.
51*fd76c71bSTreehugger Robot      * Only provided by SQLite3 databases.
52*fd76c71bSTreehugger Robot      *
53*fd76c71bSTreehugger Robot      * @param r result byte array
54*fd76c71bSTreehugger Robot      */
55*fd76c71bSTreehugger Robot 
set_result(byte[] r)56*fd76c71bSTreehugger Robot     public native void set_result(byte[] r);
57*fd76c71bSTreehugger Robot 
58*fd76c71bSTreehugger Robot     /**
59*fd76c71bSTreehugger Robot      * Set function result as empty blob given size.
60*fd76c71bSTreehugger Robot      * Only provided by SQLite3 databases.
61*fd76c71bSTreehugger Robot      *
62*fd76c71bSTreehugger Robot      * @param n size for empty blob
63*fd76c71bSTreehugger Robot      */
64*fd76c71bSTreehugger Robot 
set_result_zeroblob(int n)65*fd76c71bSTreehugger Robot     public native void set_result_zeroblob(int n);
66*fd76c71bSTreehugger Robot 
67*fd76c71bSTreehugger Robot     /**
68*fd76c71bSTreehugger Robot      * Retrieve number of rows for aggregate function.
69*fd76c71bSTreehugger Robot      */
70*fd76c71bSTreehugger Robot 
count()71*fd76c71bSTreehugger Robot     public native int count();
72*fd76c71bSTreehugger Robot 
73*fd76c71bSTreehugger Robot     /**
74*fd76c71bSTreehugger Robot      * Internal native initializer.
75*fd76c71bSTreehugger Robot      */
76*fd76c71bSTreehugger Robot 
internal_init()77*fd76c71bSTreehugger Robot     private static native void internal_init();
78*fd76c71bSTreehugger Robot 
79*fd76c71bSTreehugger Robot     static {
internal_init()80*fd76c71bSTreehugger Robot 	internal_init();
81*fd76c71bSTreehugger Robot     }
82*fd76c71bSTreehugger Robot }
83