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
     1 /**
     2  * SQL-DK
     3  * Copyright © 2013 František Kučera (frantovo.cz)
     4  *
     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.
     8  *
     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.
    13  *
    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/>.
    16  */
    17 package info.globalcode.sql.dk.formatting;
    18 
    19 import info.globalcode.sql.dk.Parameter;
    20 import info.globalcode.sql.dk.configuration.DatabaseDefinition;
    21 import java.util.List;
    22 
    23 /**
    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.
    27  *
    28  * @author Ing. František Kučera (frantovo.cz)
    29  */
    30 public interface Formatter extends AutoCloseable {
    31 
    32 	void writeStartBatch();
    33 
    34 	void writeStartDatabase(DatabaseDefinition databaseDefinition);
    35 
    36 	void writeEndDatabase();
    37 
    38 	void writeStartStatement();
    39 
    40 	void writeEndStatement();
    41 
    42 	void writeQuery(String sql);
    43 
    44 	void writeParameters(List<? extends Parameter> parameters);
    45 
    46 	void writeStartResultSet(ColumnsHeader header);
    47 
    48 	void writeEndResultSet();
    49 
    50 	void writeStartRow();
    51 
    52 	void writeColumnValue(Object value);
    53 
    54 	void writeEndRow();
    55 
    56 	void writeUpdatesResult(int updatedRowsCount);
    57 
    58 	void writeEndBatch();
    59 
    60 	/**
    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()}.
    63 	 */
    64 	@Override
    65 	void close() throws FormatterException;
    66 }