summaryrefslogtreecommitdiffstats
path: root/sqlite-jdbc/src/main/java/SQLite/TableResult.java
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-02-26 18:13:57 -0800
committerElliott Hughes <enh@google.com>2010-02-26 18:13:57 -0800
commitb721f937760de5299f8daf02bfeceda3d9fe7d0a (patch)
tree09b5a1f385647283078f81ff1762c1e4af2ef9c7 /sqlite-jdbc/src/main/java/SQLite/TableResult.java
parentb9cf9cb6d681614fe3aa282511a99c3ed3329fce (diff)
downloadlibcore-b721f937760de5299f8daf02bfeceda3d9fe7d0a.zip
libcore-b721f937760de5299f8daf02bfeceda3d9fe7d0a.tar.gz
libcore-b721f937760de5299f8daf02bfeceda3d9fe7d0a.tar.bz2
Upgrade our sqlite JDBC driver to version 20100131.
This fixes a bunch of KnownFailures, and adds a bunch of new features. I've updated the tests correspondingly (though doubtless we could add a lot more tests now, if we wanted to). I regenerated Constants.java manually, and explained how in its javadoc. I've added the upstream VERSION file so it's easier to see what upstream version we're at. (Constants now contains the version number too, but that's less obvious.) All our changes now have android-changed markers. I'll see about getting them pushed upstream next week. (This change best reviewed with "ignore whitespace". It looks like we made a bunch of whitespace "corrections" when we imported this source, which just makes it harder to stay in sync. I've taken the upstream copies of files that only had whitespace differences.)
Diffstat (limited to 'sqlite-jdbc/src/main/java/SQLite/TableResult.java')
-rw-r--r--sqlite-jdbc/src/main/java/SQLite/TableResult.java86
1 files changed, 56 insertions, 30 deletions
diff --git a/sqlite-jdbc/src/main/java/SQLite/TableResult.java b/sqlite-jdbc/src/main/java/SQLite/TableResult.java
index 1a7fb57..14337aa 100644
--- a/sqlite-jdbc/src/main/java/SQLite/TableResult.java
+++ b/sqlite-jdbc/src/main/java/SQLite/TableResult.java
@@ -60,11 +60,32 @@ public class TableResult implements Callback {
public Vector rows;
/**
+ * Maximum number of rows to hold in the table.
+ */
+
+ public int maxrows = 0;
+
+ /**
+ * Flag to indicate Maximum number of rows condition.
+ */
+
+ public boolean atmaxrows;
+
+ /**
* Create an empty result set.
*/
public TableResult() {
- clear();
+ clear();
+ }
+
+ /**
+ * Create an empty result set with maximum number of rows.
+ */
+
+ public TableResult(int maxrows) {
+ this.maxrows = maxrows;
+ clear();
}
/**
@@ -72,10 +93,11 @@ public class TableResult implements Callback {
*/
public void clear() {
- column = new String[0];
- types = null;
- rows = new Vector();
- ncolumns = nrows = 0;
+ column = new String[0];
+ types = null;
+ rows = new Vector();
+ ncolumns = nrows = 0;
+ atmaxrows = false;
}
/**
@@ -83,8 +105,8 @@ public class TableResult implements Callback {
*/
public void columns(String coldata[]) {
- column = coldata;
- ncolumns = column.length;
+ column = coldata;
+ ncolumns = column.length;
}
/**
@@ -92,7 +114,7 @@ public class TableResult implements Callback {
*/
public void types(String types[]) {
- this.types = types;
+ this.types = types;
}
/**
@@ -100,11 +122,15 @@ public class TableResult implements Callback {
*/
public boolean newrow(String rowdata[]) {
- if (rowdata != null) {
- rows.addElement(rowdata);
- nrows++;
- }
- return false;
+ if (rowdata != null) {
+ if (maxrows > 0 && nrows >= maxrows) {
+ atmaxrows = true;
+ return true;
+ }
+ rows.addElement(rowdata);
+ nrows++;
+ }
+ return false;
}
/**
@@ -112,22 +138,22 @@ public class TableResult implements Callback {
*/
public String toString() {
- StringBuffer sb = new StringBuffer();
- int i;
- for (i = 0; i < ncolumns; i++) {
- sb.append(column[i] == null ? "NULL" : column[i]);
- sb.append('|');
- }
- sb.append('\n');
- for (i = 0; i < nrows; i++) {
- int k;
- String row[] = (String[]) rows.elementAt(i);
- for (k = 0; k < ncolumns; k++) {
- sb.append(row[k] == null ? "NULL" : row[k]);
- sb.append('|');
- }
- sb.append('\n');
- }
- return sb.toString();
+ StringBuffer sb = new StringBuffer();
+ int i;
+ for (i = 0; i < ncolumns; i++) {
+ sb.append(column[i] == null ? "NULL" : column[i]);
+ sb.append('|');
+ }
+ sb.append('\n');
+ for (i = 0; i < nrows; i++) {
+ int k;
+ String row[] = (String[]) rows.elementAt(i);
+ for (k = 0; k < ncolumns; k++) {
+ sb.append(row[k] == null ? "NULL" : row[k]);
+ sb.append('|');
+ }
+ sb.append('\n');
+ }
+ return sb.toString();
}
}