1417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughespackage SQLite;
2417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
3417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes/**
4417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes * Callback interface for SQLite's query results.
5417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes * <BR><BR>
6417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes * Example:<BR>
7417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *
8417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes * <PRE>
9417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   class TableFmt implements SQLite.Callback {
10417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *     public void columns(String cols[]) {
11417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       System.out.println("&lt;TH&gt;&lt;TR&gt;");
12417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       for (int i = 0; i &lt; cols.length; i++) {
13417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *         System.out.println("&lt;TD&gt;" + cols[i] + "&lt;/TD&gt;");
14417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       }
15417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       System.out.println("&lt;/TR&gt;&lt;/TH&gt;");
16417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *     }
17417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *     public boolean newrow(String cols[]) {
18417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       System.out.println("&lt;TR&gt;");
19417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       for (int i = 0; i &lt; cols.length; i++) {
20417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *         System.out.println("&lt;TD&gt;" + cols[i] + "&lt;/TD&gt;");
21417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       }
22417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       System.out.println("&lt;/TR&gt;");
23417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *       return false;
24417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *     }
25417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   }
26417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   ...
27417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   SQLite.Database db = new SQLite.Database();
28417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   db.open("db", 0);
29417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   System.out.println("&lt;TABLE&gt;");
30417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   db.exec("select * from TEST", new TableFmt());
31417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   System.out.println("&lt;/TABLE&gt;");
32417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes *   ...
33417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes * </PRE>
34417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes */
35417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
36417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughespublic interface Callback {
37417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
38417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    /**
39417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * Reports column names of the query result.
40417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * This method is invoked first (and once) when
41417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * the SQLite engine returns the result set.<BR><BR>
42417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     *
43417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * @param coldata string array holding the column names
44417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     */
45417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
46417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void columns(String coldata[]);
47417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
48417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    /**
49417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * Reports type names of the columns of the query result.
50417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * This is available from SQLite 2.6.0 on and needs
51417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * the PRAGMA show_datatypes to be turned on.<BR><BR>
52417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     *
53417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * @param types string array holding column types
54417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     */
55417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
56417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public void types(String types[]);
57417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
58417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    /**
59417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * Reports row data of the query result.
60417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * This method is invoked for each row of the
61417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * result set. If true is returned the running
62417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * SQLite query is aborted.<BR><BR>
63417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     *
64417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     * @param rowdata string array holding the column values of the row
65417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes     */
66417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes
67417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes    public boolean newrow(String rowdata[]);
68417deb1db112103aff04231b6ca79772ff7d3a21Elliott Hughes}
69