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