1 package SQLite; 2 3 /** 4 * Callback interface for SQLite's query results. 5 * <BR><BR> 6 * Example:<BR> 7 * 8 * <PRE> 9 * class TableFmt implements SQLite.Callback { 10 * public void columns(String cols[]) { 11 * System.out.println("<TH><TR>"); 12 * for (int i = 0; i < cols.length; i++) { 13 * System.out.println("<TD>" + cols[i] + "</TD>"); 14 * } 15 * System.out.println("</TR></TH>"); 16 * } 17 * public boolean newrow(String cols[]) { 18 * System.out.println("<TR>"); 19 * for (int i = 0; i < cols.length; i++) { 20 * System.out.println("<TD>" + cols[i] + "</TD>"); 21 * } 22 * System.out.println("</TR>"); 23 * return false; 24 * } 25 * } 26 * ... 27 * SQLite.Database db = new SQLite.Database(); 28 * db.open("db", 0); 29 * System.out.println("<TABLE>"); 30 * db.exec("select * from TEST", new TableFmt()); 31 * System.out.println("</TABLE>"); 32 * ... 33 * </PRE> 34 */ 35 36 public interface Callback { 37 38 /** 39 * Reports column names of the query result. 40 * This method is invoked first (and once) when 41 * the SQLite engine returns the result set.<BR><BR> 42 * 43 * @param coldata string array holding the column names 44 */ 45 columns(String coldata[])46 public void columns(String coldata[]); 47 48 /** 49 * Reports type names of the columns of the query result. 50 * This is available from SQLite 2.6.0 on and needs 51 * the PRAGMA show_datatypes to be turned on.<BR><BR> 52 * 53 * @param types string array holding column types 54 */ 55 types(String types[])56 public void types(String types[]); 57 58 /** 59 * Reports row data of the query result. 60 * This method is invoked for each row of the 61 * result set. If true is returned the running 62 * SQLite query is aborted.<BR><BR> 63 * 64 * @param rowdata string array holding the column values of the row 65 */ 66 newrow(String rowdata[])67 public boolean newrow(String rowdata[]); 68 } 69