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