• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package SQLite;
2 
3 /**
4  * Callback interface for SQLite's user defined functions.
5  * Each callback method receives a
6  * <A HREF="FunctionContext.html">FunctionContext</A> object
7  * which is used to set the function result or error code.
8  * <BR><BR>
9  * Example:<BR>
10  *
11  * <PRE>
12  *   class SinFunc implements SQLite.Function {
13  *     public void function(SQLite.FunctionContext fc, String args[]) {
14  *       try {
15  *         Double d = new Double(args[0]);
16  *         fc.set_result(Math.sin(d.doubleValue()));
17  *       } catch (Exception e) {
18  *         fc.set_error("sin(" + args[0] + "):" + e);
19  *       }
20  *     }
21  *     ...
22  *   }
23  *   SQLite.Database db = new SQLite.Database();
24  *   db.open("db", 0);
25  *   db.create_function("sin", 1, SinFunc);
26  *   ...
27  *   db.exec("select sin(1.0) from test", null);
28  * </PRE>
29  */
30 
31 public interface Function {
32 
33     /**
34      * Callback for regular function.
35      *
36      * @param fc function's context for reporting result
37      * @param args String array of arguments
38      */
39 
function(FunctionContext fc, String args[])40     public void function(FunctionContext fc, String args[]);
41 
42     /**
43      * Callback for one step in aggregate function.
44      *
45      * @param fc function's context for reporting result
46      * @param args String array of arguments
47      */
48 
step(FunctionContext fc, String args[])49     public void step(FunctionContext fc, String args[]);
50 
51     /**
52      * Callback for final step in aggregate function.
53      *
54      * @param fc function's context for reporting result
55      */
56 
last_step(FunctionContext fc)57     public void last_step(FunctionContext fc);
58 
59 }
60