3 * Copyright © 2013 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package info.globalcode.sql.dk.formatting;
19 import info.globalcode.sql.dk.Parameter;
20 import info.globalcode.sql.dk.configuration.DatabaseDefinition;
21 import java.util.List;
24 * The formatter is responsible for printing the result sets and/or updates result (count of
25 * inserted/updated rows). The formatter can produce output in arbitrary format – text, some markup
26 * or even binary data.
28 * @author Ing. František Kučera (frantovo.cz)
30 public interface Formatter extends AutoCloseable {
32 void writeStartBatch();
34 void writeStartDatabase(DatabaseDefinition databaseDefinition);
36 void writeEndDatabase();
38 void writeStartStatement();
40 void writeEndStatement();
42 void writeQuery(String sql);
44 void writeParameters(List<? extends Parameter> parameters);
46 void writeStartResultSet(ColumnsHeader header);
48 void writeEndResultSet();
52 void writeColumnValue(Object value);
56 void writeUpdatesResult(int updatedRowsCount);
61 * If an error occurs (e.g. lost connection during result set reading) this method will be
62 * called even if there was no {@linkplain #writeEndBach()}.
65 void close() throws FormatterException;