projects
/
squelch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
select queries now work, and print tabular output.
[squelch.git]
/
src
/
main
/
java
/
net
/
jaekl
/
squelch
/
stmt
/
Tabular.java
diff --git
a/src/main/java/net/jaekl/squelch/stmt/Tabular.java
b/src/main/java/net/jaekl/squelch/stmt/Tabular.java
index 03c403ef3f037684977376d14e3f3dd3d8b8472b..af3d5da360933f8c37e48c216187236fd047bdde 100644
(file)
--- a/
src/main/java/net/jaekl/squelch/stmt/Tabular.java
+++ b/
src/main/java/net/jaekl/squelch/stmt/Tabular.java
@@
-38,7
+38,7
@@
abstract public class Tabular {
}
abstract Column[] getCols() throws SQLException;
}
abstract Column[] getCols() throws SQLException;
- abstract Row getNext();
+ abstract Row getNext()
throws SQLException
;
// Returns the number of (data) rows that were output
public int printTable(PrintWriter pw) throws SQLException {
// Returns the number of (data) rows that were output
public int printTable(PrintWriter pw) throws SQLException {
@@
-66,6
+66,10
@@
abstract public class Tabular {
rowCount += pending;
}
rowCount += pending;
}
+ if (rowCount > 0) {
+ writeDivider(pw, colWidths);
+ }
+
// TODO: Implement a String table for i18n
pw.println("" + rowCount + " row(s) returned.");
pw.flush();
// TODO: Implement a String table for i18n
pw.println("" + rowCount + " row(s) returned.");
pw.flush();
@@
-119,7
+123,7
@@
abstract public class Tabular {
// Examine and buffer up to rowBuf.length rows.
// Returns the number of actual rows that were buffered (zero if no more rows are available).
// Examine and buffer up to rowBuf.length rows.
// Returns the number of actual rows that were buffered (zero if no more rows are available).
- RowBuffer bufferRows(int[] colWidths)
+ RowBuffer bufferRows(int[] colWidths)
throws SQLException
{
RowBuffer rowBuf = new RowBuffer();
{
RowBuffer rowBuf = new RowBuffer();
@@
-222,7
+226,7
@@
abstract public class Tabular {
void writeHeader(PrintWriter pw, Column[] cols, int[] colWidths) {
writeDivider(pw, colWidths);
void writeHeader(PrintWriter pw, Column[] cols, int[] colWidths) {
writeDivider(pw, colWidths);
- for (int idx =
1; idx <=
cols.length; ++idx) {
+ for (int idx =
0; idx <
cols.length; ++idx) {
Column col = cols[idx];
pw.print("|" + centrePad(col.getLabel(), colWidths[idx]));
}
Column col = cols[idx];
pw.print("|" + centrePad(col.getLabel(), colWidths[idx]));
}
@@
-236,7
+240,7
@@
abstract public class Tabular {
for (int rowIdx = 0; rowIdx < rowBuf.getPending(); ++rowIdx) {
Row row = rowBuf.getRow(rowIdx);
for (int colIdx = 0; colIdx < colWidths.length; ++colIdx) {
for (int rowIdx = 0; rowIdx < rowBuf.getPending(); ++rowIdx) {
Row row = rowBuf.getRow(rowIdx);
for (int colIdx = 0; colIdx < colWidths.length; ++colIdx) {
- String value = "" + row.getValue(colIdx);
+ String value = "" + row.getValue(colIdx
+ 1
);
String padding = repChar(' ', colWidths[colIdx] - value.length());
pw.print("|" + value + padding);
}
String padding = repChar(' ', colWidths[colIdx] - value.length());
pw.print("|" + value + padding);
}