author | František Kučera <franta-hg@frantovo.cz> |
Wed, 09 Nov 2016 00:18:01 +0100 | |
branch | v_0 |
changeset 229 | 7699133f5a01 |
parent 155 | eb3676c6929b |
permissions | -rw-r--r-- |
franta-hg@22 | 1 |
/** |
franta-hg@22 | 2 |
* SQL-DK |
franta-hg@22 | 3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
franta-hg@22 | 4 |
* |
franta-hg@22 | 5 |
* This program is free software: you can redistribute it and/or modify |
franta-hg@22 | 6 |
* it under the terms of the GNU General Public License as published by |
franta-hg@22 | 7 |
* the Free Software Foundation, either version 3 of the License, or |
franta-hg@22 | 8 |
* (at your option) any later version. |
franta-hg@22 | 9 |
* |
franta-hg@22 | 10 |
* This program is distributed in the hope that it will be useful, |
franta-hg@22 | 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
franta-hg@22 | 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
franta-hg@22 | 13 |
* GNU General Public License for more details. |
franta-hg@22 | 14 |
* |
franta-hg@22 | 15 |
* You should have received a copy of the GNU General Public License |
franta-hg@22 | 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
franta-hg@22 | 17 |
*/ |
franta-hg@22 | 18 |
package info.globalcode.sql.dk.formatting; |
franta-hg@22 | 19 |
|
franta-hg@22 | 20 |
import info.globalcode.sql.dk.Parameter; |
franta-hg@29 | 21 |
import info.globalcode.sql.dk.configuration.DatabaseDefinition; |
franta-hg@22 | 22 |
import java.util.List; |
franta-hg@22 | 23 |
|
franta-hg@22 | 24 |
/** |
franta-hg@155 | 25 |
* The formatter is responsible for printing the result sets and/or updates result (count of |
franta-hg@155 | 26 |
* inserted/updated rows). The formatter can produce output in arbitrary format – text, some markup |
franta-hg@155 | 27 |
* or even binary data. |
franta-hg@22 | 28 |
* |
franta-hg@22 | 29 |
* @author Ing. František Kučera (frantovo.cz) |
franta-hg@22 | 30 |
*/ |
franta-hg@101 | 31 |
public interface Formatter extends AutoCloseable { |
franta-hg@22 | 32 |
|
franta-hg@91 | 33 |
void writeStartBatch(); |
franta-hg@101 | 34 |
|
franta-hg@29 | 35 |
void writeStartDatabase(DatabaseDefinition databaseDefinition); |
franta-hg@22 | 36 |
|
franta-hg@22 | 37 |
void writeEndDatabase(); |
franta-hg@22 | 38 |
|
franta-hg@142 | 39 |
void writeStartStatement(); |
franta-hg@22 | 40 |
|
franta-hg@142 | 41 |
void writeEndStatement(); |
franta-hg@22 | 42 |
|
franta-hg@22 | 43 |
void writeQuery(String sql); |
franta-hg@22 | 44 |
|
franta-hg@34 | 45 |
void writeParameters(List<? extends Parameter> parameters); |
franta-hg@22 | 46 |
|
franta-hg@142 | 47 |
void writeStartResultSet(ColumnsHeader header); |
franta-hg@142 | 48 |
|
franta-hg@142 | 49 |
void writeEndResultSet(); |
franta-hg@22 | 50 |
|
franta-hg@22 | 51 |
void writeStartRow(); |
franta-hg@22 | 52 |
|
franta-hg@22 | 53 |
void writeColumnValue(Object value); |
franta-hg@22 | 54 |
|
franta-hg@22 | 55 |
void writeEndRow(); |
franta-hg@22 | 56 |
|
franta-hg@142 | 57 |
void writeUpdatesResult(int updatedRowsCount); |
franta-hg@101 | 58 |
|
franta-hg@91 | 59 |
void writeEndBatch(); |
franta-hg@101 | 60 |
|
franta-hg@101 | 61 |
/** |
franta-hg@101 | 62 |
* If an error occurs (e.g. lost connection during result set reading) this method will be |
franta-hg@101 | 63 |
* called even if there was no {@linkplain #writeEndBach()}. |
franta-hg@101 | 64 |
*/ |
franta-hg@101 | 65 |
@Override |
franta-hg@101 | 66 |
void close() throws FormatterException; |
franta-hg@22 | 67 |
} |