java/sql-dk/src/info/globalcode/sql/dk/formatting/Formatter.java
author František Kučera <franta-hg@frantovo.cz>
Mon, 30 Dec 2013 00:01:39 +0100
branchv_0
changeset 101 97b0d9069133
parent 91 43e8d52091d5
child 142 da1e38386d84
permissions -rw-r--r--
Formatter is now AutoCloseable – so have chance to do some clean up and close the stream, if some error occurs (e.g. lost connection during result set reading)
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@22
    25
 *
franta-hg@22
    26
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@22
    27
 */
franta-hg@101
    28
public interface Formatter extends AutoCloseable {
franta-hg@22
    29
franta-hg@91
    30
	void writeStartBatch();
franta-hg@101
    31
franta-hg@29
    32
	void writeStartDatabase(DatabaseDefinition databaseDefinition);
franta-hg@22
    33
franta-hg@22
    34
	void writeEndDatabase();
franta-hg@22
    35
franta-hg@22
    36
	void writeStartResultSet();
franta-hg@22
    37
franta-hg@22
    38
	void writeEndResultSet();
franta-hg@22
    39
franta-hg@22
    40
	void writeQuery(String sql);
franta-hg@22
    41
franta-hg@34
    42
	void writeParameters(List<? extends Parameter> parameters);
franta-hg@22
    43
franta-hg@22
    44
	void writeColumnsHeader(ColumnsHeader header);
franta-hg@22
    45
franta-hg@22
    46
	void writeStartRow();
franta-hg@22
    47
franta-hg@22
    48
	void writeColumnValue(Object value);
franta-hg@22
    49
franta-hg@22
    50
	void writeEndRow();
franta-hg@22
    51
franta-hg@22
    52
	void writeStartUpdatesResult();
franta-hg@22
    53
franta-hg@22
    54
	void writeUpdatedRowsCount(int updatedRowsCount);
franta-hg@22
    55
franta-hg@22
    56
	void writeEndUpdatesResult();
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
}