franta-hg@22: /** franta-hg@22: * SQL-DK franta-hg@22: * Copyright © 2013 František Kučera (frantovo.cz) franta-hg@22: * franta-hg@22: * This program is free software: you can redistribute it and/or modify franta-hg@22: * it under the terms of the GNU General Public License as published by franta-hg@250: * the Free Software Foundation, version 3 of the License. franta-hg@22: * franta-hg@22: * This program is distributed in the hope that it will be useful, franta-hg@22: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@22: * GNU General Public License for more details. franta-hg@22: * franta-hg@22: * You should have received a copy of the GNU General Public License franta-hg@22: * along with this program. If not, see . franta-hg@22: */ franta-hg@22: package info.globalcode.sql.dk.formatting; franta-hg@22: franta-hg@22: import info.globalcode.sql.dk.Parameter; franta-hg@29: import info.globalcode.sql.dk.configuration.DatabaseDefinition; franta-hg@22: import java.util.List; franta-hg@22: franta-hg@22: /** franta-hg@155: * The formatter is responsible for printing the result sets and/or updates result (count of franta-hg@155: * inserted/updated rows). The formatter can produce output in arbitrary format – text, some markup franta-hg@155: * or even binary data. franta-hg@22: * franta-hg@22: * @author Ing. František Kučera (frantovo.cz) franta-hg@22: */ franta-hg@101: public interface Formatter extends AutoCloseable { franta-hg@22: franta-hg@91: void writeStartBatch(); franta-hg@101: franta-hg@29: void writeStartDatabase(DatabaseDefinition databaseDefinition); franta-hg@22: franta-hg@22: void writeEndDatabase(); franta-hg@22: franta-hg@142: void writeStartStatement(); franta-hg@22: franta-hg@142: void writeEndStatement(); franta-hg@22: franta-hg@22: void writeQuery(String sql); franta-hg@22: franta-hg@34: void writeParameters(List parameters); franta-hg@22: franta-hg@142: void writeStartResultSet(ColumnsHeader header); franta-hg@142: franta-hg@142: void writeEndResultSet(); franta-hg@22: franta-hg@22: void writeStartRow(); franta-hg@22: franta-hg@22: void writeColumnValue(Object value); franta-hg@22: franta-hg@22: void writeEndRow(); franta-hg@22: franta-hg@142: void writeUpdatesResult(int updatedRowsCount); franta-hg@101: franta-hg@91: void writeEndBatch(); franta-hg@101: franta-hg@101: /** franta-hg@101: * If an error occurs (e.g. lost connection during result set reading) this method will be franta-hg@101: * called even if there was no {@linkplain #writeEndBach()}. franta-hg@101: */ franta-hg@101: @Override franta-hg@101: void close() throws FormatterException; franta-hg@22: }