1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java Wed Dec 25 02:04:57 2013 +0100
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java Wed Dec 25 16:38:05 2013 +0100
1.3 @@ -20,6 +20,7 @@
1.4 import static info.globalcode.sql.dk.Xmlns.CONFIGURATION;
1.5 import static info.globalcode.sql.dk.Functions.findByName;
1.6 import info.globalcode.sql.dk.formatting.SilentFormatter;
1.7 +import info.globalcode.sql.dk.formatting.SingleValueFormatter;
1.8 import info.globalcode.sql.dk.formatting.TabularFormatter;
1.9 import info.globalcode.sql.dk.formatting.XmlFormatter;
1.10 import java.util.ArrayList;
1.11 @@ -51,6 +52,7 @@
1.12 static {
1.13 Collection<FormatterDefinition> l = new ArrayList<>();
1.14 l.add(new FormatterDefinition(SilentFormatter.NAME, SilentFormatter.class.getName()));
1.15 + l.add(new FormatterDefinition(SingleValueFormatter.NAME, SingleValueFormatter.class.getName()));
1.16 l.add(new FormatterDefinition(XmlFormatter.NAME, XmlFormatter.class.getName()));
1.17 l.add(new FormatterDefinition(TabularFormatter.NAME, TabularFormatter.class.getName()));
1.18 buildInFormatters = Collections.unmodifiableCollection(l);
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/SingleValueFormatter.java Wed Dec 25 16:38:05 2013 +0100
2.3 @@ -0,0 +1,52 @@
2.4 +/**
2.5 + * SQL-DK
2.6 + * Copyright © 2013 František Kučera (frantovo.cz)
2.7 + *
2.8 + * This program is free software: you can redistribute it and/or modify
2.9 + * it under the terms of the GNU General Public License as published by
2.10 + * the Free Software Foundation, either version 3 of the License, or
2.11 + * (at your option) any later version.
2.12 + *
2.13 + * This program is distributed in the hope that it will be useful,
2.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.16 + * GNU General Public License for more details.
2.17 + *
2.18 + * You should have received a copy of the GNU General Public License
2.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
2.20 + */
2.21 +package info.globalcode.sql.dk.formatting;
2.22 +
2.23 +import java.io.PrintWriter;
2.24 +
2.25 +/**
2.26 + * Prints just the value without any formatting. If the result set contains multiple records or
2.27 + * columns, the values are simply concatenate without any separators. If updates result is returned,
2.28 + * the updated records count is printed.
2.29 + *
2.30 + * @author Ing. František Kučera (frantovo.cz)
2.31 + */
2.32 +public class SingleValueFormatter extends AbstractFormatter {
2.33 +
2.34 + public static final String NAME = "single";
2.35 + private PrintWriter out;
2.36 +
2.37 + public SingleValueFormatter(FormatterContext formatterContext) {
2.38 + super(formatterContext);
2.39 + this.out = new PrintWriter(formatterContext.getOutputStream());
2.40 + }
2.41 +
2.42 + @Override
2.43 + public void writeColumnValue(Object value) {
2.44 + super.writeColumnValue(value);
2.45 + out.print(String.valueOf(value));
2.46 + out.flush();
2.47 + }
2.48 +
2.49 + @Override
2.50 + public void writeUpdatedRowsCount(int updatedRowsCount) {
2.51 + super.writeUpdatedRowsCount(updatedRowsCount);
2.52 + out.print(updatedRowsCount);
2.53 + out.flush();
2.54 + }
2.55 +}