if (pending > 0) {
writeHeader(pw, cols, colWidths, suppressed);
writeRowBuffer(pw, rowBuf, colWidths, suppressed);
- rowCount = rowBuf.getPending();
+ rowCount = pending;
}
- if (driver.isSuppressNulls()) {
- // TODO: StringTable
- pw.println("Row limit for suppress_nulls has been reached; output may have been truncated.");
- writeDivider(pw, colWidths, suppressed);
- }
- else {
- while (pending > 0) {
- rowBuf = bufferRows(driver, colWidths);
- writeRowBuffer(pw, rowBuf, colWidths, suppressed);
- pending = rowBuf.getPending();
- rowCount += pending;
+ rowBuf = bufferRows(driver, colWidths);
+ pending = rowBuf.getPending();
+ while (pending > 0) {
+ if (driver.isSet(DbDriver.SUPPRESS_NULLS)) {
+ writeDivider(pw, colWidths, suppressed);
+ pw.println("Row limit for suppress_nulls has been reached; output may have been truncated.");
+ break;
}
+ writeRowBuffer(pw, rowBuf, colWidths, suppressed);
+ rowCount += pending;
+ rowBuf = bufferRows(driver, colWidths);
+ pending = rowBuf.getPending();
}
if (rowCount > 0) {
}
}
- if ((!allColsNull) || (!driver.isSuppressNulls()))
+ if ((!allColsNull) || (!driver.isSet(DbDriver.SUPPRESS_NULLS)))
{
rowBuf.addRow(row);
// Check whether all values in this row will fit in the current column widths
for (int colIdx = 0; colIdx < colWidths.length; ++colIdx) {
- int width = ("" + row.getValue(colIdx + 1)).length();
+ int width = stringify(row.getValue(colIdx + 1)).length();
if (width > colWidths[colIdx]) {
// Widen the column to fit this value
colWidths[colIdx] = width;
{
boolean[] result = new boolean[cols.length];
- if (rowBuf.getPending() < 1) {
- // No data rows, so do not suppress any columns.
+ if ( !(driver.isSet(DbDriver.SUPPRESS_NULLS))
+ || (rowBuf.getPending() < 1) )
+ {
+ // Null-suppression is turned off, or
+ // there are no data rows,
+ // so do not suppress any columns.
for (int colIdx = 0; colIdx < cols.length; ++colIdx) {
result[colIdx] = false;
}
writeDivider(pw, colWidths, suppressed);
for (int idx = 0; idx < cols.length; ++idx) {
- Column col = cols[idx];
- pw.print("| " + centrePad(col.getLabel(), colWidths[idx]) + " ");
+ if (!suppressed[idx]) {
+ Column col = cols[idx];
+ pw.print("| " + centrePad(col.getLabel(), colWidths[idx]) + " ");
+ }
}
pw.println("|");
if (!suppressed[colIdx]) {
Object obj = row.getValue(colIdx + 1);
String value = stringify(obj);
- int width = stringWidth(obj);
+ int width = stringWidth(value);
String padding = repChar(' ', colWidths[colIdx] - width);
pw.print("| " + value + padding + " ");
}