15 * You should have received a copy of the GNU General Public License |
15 * You should have received a copy of the GNU General Public License |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 package info.globalcode.sql.dk.formatting; |
18 package info.globalcode.sql.dk.formatting; |
19 |
19 |
|
20 import info.globalcode.sql.dk.ColorfulPrintWriter; |
|
21 |
20 /** |
22 /** |
21 * |
23 * |
22 * @author Ing. František Kučera (frantovo.cz) |
24 * @author Ing. František Kučera (frantovo.cz) |
23 */ |
25 */ |
24 public class TabularFormatter extends AbstractFormatter { |
26 public class TabularFormatter extends AbstractFormatter { |
25 |
27 |
26 public static final String NAME = "tabular"; |
28 public static final String NAME = "tabular"; |
|
29 private ColorfulPrintWriter out; |
27 |
30 |
28 public TabularFormatter(FormatterContext formatterContext) { |
31 public TabularFormatter(FormatterContext formatterContext) { |
29 super(formatterContext); |
32 super(formatterContext); |
|
33 out = new ColorfulPrintWriter(formatterContext.getOutputStream()); |
|
34 } |
|
35 |
|
36 @Override |
|
37 public void writeColumnValue(Object value) { |
|
38 super.writeColumnValue(value); |
|
39 |
|
40 if (!isCurrentColumnFirst()) { |
|
41 out.print(ColorfulPrintWriter.TerminalColor.Green, " | "); |
|
42 } |
|
43 |
|
44 out.print(ColorfulPrintWriter.TerminalColor.Cyan, String.valueOf(value)); |
|
45 } |
|
46 |
|
47 @Override |
|
48 public void writeEndRow() { |
|
49 super.writeEndRow(); |
|
50 out.println(); |
|
51 out.flush(); |
30 } |
52 } |
31 } |
53 } |