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; |
20 import info.globalcode.sql.dk.ColorfulPrintWriter; |
|
21 import info.globalcode.sql.dk.configuration.PropertyDeclaration; |
|
22 import static info.globalcode.sql.dk.formatting.CommonProperties.COLORFUL; |
|
23 import static info.globalcode.sql.dk.formatting.CommonProperties.COLORFUL_DESCRIPTION; |
21 |
24 |
22 /** |
25 /** |
23 * Formatter intended for printing one record (or few records) with many columns. |
26 * Formatter intended for printing one record (or few records) with many columns. |
24 * Prints each colum name and its value on separate line. |
27 * Prints each colum name and its value on separate line. |
25 * |
28 * |
26 * @author Ing. František Kučera (frantovo.cz) |
29 * @author Ing. František Kučera (frantovo.cz) |
27 */ |
30 */ |
|
31 @PropertyDeclaration(name = COLORFUL, type = Boolean.class, description = COLORFUL_DESCRIPTION) |
28 public class SingleRecordFormatter extends AbstractFormatter { |
32 public class SingleRecordFormatter extends AbstractFormatter { |
29 |
33 |
30 public static final String NAME = "record"; // bash-completion:formatter |
34 public static final String NAME = "record"; // bash-completion:formatter |
31 public static final String PROPERTY_COLORFUL = "color"; |
|
32 private final ColorfulPrintWriter out; |
35 private final ColorfulPrintWriter out; |
33 private boolean firstResult = true; |
36 private boolean firstResult = true; |
34 |
37 |
35 public SingleRecordFormatter(FormatterContext formatterContext) { |
38 public SingleRecordFormatter(FormatterContext formatterContext) { |
36 super(formatterContext); |
39 super(formatterContext); |
37 out = new ColorfulPrintWriter(formatterContext.getOutputStream()); |
40 out = new ColorfulPrintWriter(formatterContext.getOutputStream()); |
38 out.setColorful(formatterContext.getProperties().getBoolean(PROPERTY_COLORFUL, true)); |
41 out.setColorful(formatterContext.getProperties().getBoolean(COLORFUL, true)); |
39 } |
42 } |
40 |
43 |
41 @Override |
44 @Override |
42 public void writeStartResultSet(ColumnsHeader header) { |
45 public void writeStartResultSet(ColumnsHeader header) { |
43 super.writeStartResultSet(header); |
46 super.writeStartResultSet(header); |