Database Reference
In-Depth Information
public class ResultReader {
private final PrintStream printer;
public ResultReader() {
this(System.out);
}
public ResultReader(PrintStream stream) {
this.printer = stream;
}
private <T extends Map<String, Object>>T fixup(T
parent,
Object obj) {
// Because of the cell recursion, we have to do
something slightly
// goofy: We turn the cell/row into a map, then
turn it back into a
// cell/row. This works around some Java type
inconsistencies
// between neted calls and outer ones.
@SuppressWarnings("unchecked")
Map<String, Object> valueMap = (Map<String,
Object>) obj;
parent.putAll(valueMap);
return parent;
}
private void printCellValue(TableFieldSchema field,
TableCell cell) {
if (Data.isNull(cell.getV())) {
printer.append("null");
return;
} else if
(field.getType().toLowerCase().equals("record")) {
TableRow tableRow = fixup(new TableRow(),
cell.getV());
printCells(field.getFields(), tableRow.getF());
} else {
// Everything that isn't a record can be printed
as a string.
Search WWH ::




Custom Search