author | František Kučera <franta-hg@frantovo.cz> |
Mon, 23 Dec 2013 12:16:22 +0100 | |
branch | v_0 |
changeset 39 | be8db46a38c3 |
parent 37 | 9e6f8e5d5f98 |
child 40 | a9db7fb3ce65 |
permissions | -rw-r--r-- |
32
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* SQL-DK |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
5e412dbd9362
TabularFormatter: basics
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 |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
*/ |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
package info.globalcode.sql.dk.formatting; |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
20 |
import info.globalcode.sql.dk.ColorfulPrintWriter; |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
21 |
import static info.globalcode.sql.dk.ColorfulPrintWriter.*; |
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
22 |
import static info.globalcode.sql.dk.Functions.lpad; |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
23 |
import static info.globalcode.sql.dk.Functions.rpad; |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
24 |
|
32
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
/** |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
* |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
* @author Ing. František Kučera (frantovo.cz) |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
*/ |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
public class TabularFormatter extends AbstractFormatter { |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
public static final String NAME = "tabular"; |
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
32 |
private static final String HEADER_TYPE_PREFIX = " ("; |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
33 |
private static final String HEADER_TYPE_SUFFIX = ")"; |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
34 |
private ColorfulPrintWriter out; |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
35 |
private boolean firstResult = true; |
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
36 |
private int[] columnWidth; |
32
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
|
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
public TabularFormatter(FormatterContext formatterContext) { |
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
super(formatterContext); |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
40 |
out = new ColorfulPrintWriter(formatterContext.getOutputStream()); |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
41 |
} |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
42 |
|
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
43 |
@Override |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
44 |
public void writeStartResultSet() { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
45 |
super.writeStartResultSet(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
46 |
printResultSeparator(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
47 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
48 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
49 |
@Override |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
50 |
public void writeColumnsHeader(ColumnsHeader header) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
51 |
super.writeColumnsHeader(header); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
52 |
|
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
53 |
columnWidth = new int[header.getColumnCount()]; |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
54 |
|
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
55 |
for (ColumnDescriptor cd : header.getColumnDescriptors()) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
56 |
out.print(TerminalStyle.Bright, cd.getLabel()); |
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
57 |
out.print(HEADER_TYPE_PREFIX); |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
58 |
out.print(cd.getTypeName()); |
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
59 |
out.print(HEADER_TYPE_SUFFIX); |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
60 |
if (!cd.isLastColumn()) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
61 |
out.print(TerminalColor.Green, " | "); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
62 |
} |
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
63 |
|
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
64 |
setColumnWidth(cd.getColumnNumber(), cd.getLabel().length() + cd.getTypeName().length() + HEADER_TYPE_PREFIX.length() + HEADER_TYPE_SUFFIX.length()); |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
65 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
66 |
out.println(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
67 |
out.flush(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
68 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
69 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
70 |
@Override |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
71 |
public void writeColumnValue(Object value) { |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
72 |
super.writeColumnValue(value); |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
73 |
|
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
74 |
if (!isCurrentColumnFirst()) { |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
75 |
out.print(TerminalColor.Green, " | "); |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
76 |
} |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
77 |
|
39
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
78 |
out.print(TerminalColor.Cyan, toString(value)); |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
79 |
} |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
80 |
|
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
81 |
private int getColumnWidth(int columnNumber) { |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
82 |
return columnWidth[columnNumber - 1]; |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
83 |
} |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
84 |
|
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
85 |
private void setColumnWidth(int columnNumber, int width) { |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
86 |
columnWidth[columnNumber - 1] = width; |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
87 |
} |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
88 |
|
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
89 |
private void updateColumnWidth(int columnNumber, int width) { |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
90 |
int oldWidth = getColumnWidth(columnNumber); |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
91 |
setColumnWidth(columnNumber, Math.max(width, oldWidth)); |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
92 |
|
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
93 |
} |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
94 |
|
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
95 |
@Override |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
96 |
protected String toString(Object value) { |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
97 |
final int width = getColumnWidth(getCurrentColumnsCount()); |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
98 |
if (value instanceof Number) { |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
99 |
return lpad(super.toString(value), width); |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
100 |
} else { |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
101 |
return rpad(super.toString(value), width); |
be8db46a38c3
TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
102 |
} |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
103 |
} |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
104 |
|
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
105 |
@Override |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
106 |
public void writeEndRow() { |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
107 |
super.writeEndRow(); |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
108 |
out.println(); |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
32
diff
changeset
|
109 |
out.flush(); |
32
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
110 |
} |
37
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
111 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
112 |
@Override |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
113 |
public void writeEndResultSet() { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
114 |
super.writeEndResultSet(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
115 |
out.print(TerminalColor.Yellow, "Record count: "); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
116 |
out.println(getCurrentRowCount()); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
117 |
out.flush(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
118 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
119 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
120 |
@Override |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
121 |
public void writeStartUpdatesResult() { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
122 |
super.writeStartUpdatesResult(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
123 |
printResultSeparator(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
124 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
125 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
126 |
@Override |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
127 |
public void writeUpdatedRowsCount(int updatedRowsCount) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
128 |
super.writeUpdatedRowsCount(updatedRowsCount); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
129 |
out.print(TerminalColor.Red, "Updated records: "); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
130 |
out.println(updatedRowsCount); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
131 |
out.flush(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
132 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
133 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
134 |
@Override |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
135 |
public void writeEndDatabase() { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
136 |
super.writeEndDatabase(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
137 |
out.flush(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
138 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
139 |
|
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
140 |
private void printResultSeparator() { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
141 |
if (firstResult) { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
142 |
firstResult = false; |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
143 |
} else { |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
144 |
out.println(); |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
145 |
} |
9e6f8e5d5f98
support SQL commands returning more ResultSets + remove COMMAND_TYPE (type is now derived from result returned from SQL – it is not needed to specify the type on CLI)
František Kučera <franta-hg@frantovo.cz>
parents:
34
diff
changeset
|
146 |
} |
32
5e412dbd9362
TabularFormatter: basics
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
147 |
} |