author | František Kučera <franta-hg@frantovo.cz> |
Thu, 24 Oct 2019 21:43:08 +0200 | |
branch | v_0 |
changeset 250 | aae5009bd0af |
parent 246 | 277c18b48762 |
permissions | -rw-r--r-- |
16
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
1 |
/** |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
2 |
* SQL-DK |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
3 |
* Copyright © 2013 František Kučera (frantovo.cz) |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
4 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
250
aae5009bd0af
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
246
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
16
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
8 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
12 |
* GNU General Public License for more details. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
13 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
16 |
*/ |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
package info.globalcode.sql.dk; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
import static info.globalcode.sql.dk.Functions.isNotEmpty; |
14 | 20 |
import static info.globalcode.sql.dk.Functions.equalz; |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
63
diff
changeset
|
21 |
import info.globalcode.sql.dk.InfoLister.InfoType; |
104
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
22 |
import info.globalcode.sql.dk.configuration.Properties; |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
23 |
import info.globalcode.sql.dk.configuration.Property; |
146
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
24 |
import java.io.InputStream; |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
25 |
import java.io.OutputStream; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
import java.util.ArrayList; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
import java.util.Collection; |
14 | 28 |
import java.util.EnumSet; |
162
7863d8a423d4
InfoLister: preserve order of databases to test and to list driver properties
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
29 |
import java.util.LinkedHashSet; |
246
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
30 |
import java.util.LinkedList; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
import java.util.List; |
74
a8444f6a54f3
allow multiple databases connection test in --test-connection
František Kučera <franta-hg@frantovo.cz>
parents:
71
diff
changeset
|
32 |
import java.util.Set; |
63
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
33 |
import java.util.regex.Pattern; |
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
34 |
import java.util.regex.PatternSyntaxException; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
/** |
155 | 37 |
* Holds options from command line, validates them, combines with configuration and provides derived |
38 |
* objects. |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
* |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
* @author Ing. František Kučera (frantovo.cz) |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
*/ |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
public class CLIOptions { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
|
3 | 44 |
public static final String DEFAULT_NAME_PREFIX = ":"; |
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
45 |
public static final String DEFAULT_NAME_SUFFIX = "(?=([^\\w]|$))"; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
private String sql; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
private String databaseName; |
246
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
48 |
private final List<String> relationNames = new ArrayList<>(); |
200
2e351d7c26c4
InfoLister: new listings: --list-java-properties and --list-environment-variables
František Kučera <franta-hg@frantovo.cz>
parents:
162
diff
changeset
|
49 |
private final Set<String> databaseNamesToTest = new LinkedHashSet<>(); |
2e351d7c26c4
InfoLister: new listings: --list-java-properties and --list-environment-variables
František Kučera <franta-hg@frantovo.cz>
parents:
162
diff
changeset
|
50 |
private final Set<String> databaseNamesToListProperties = new LinkedHashSet<>(); |
209
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
51 |
private final Set<String> formatterNamesToListProperties = new LinkedHashSet<>(); |
3 | 52 |
private String namePrefix = DEFAULT_NAME_PREFIX; |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
53 |
private String nameSuffix = DEFAULT_NAME_SUFFIX; |
14 | 54 |
private String formatterName; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
private boolean batch; |
200
2e351d7c26c4
InfoLister: new listings: --list-java-properties and --list-environment-variables
František Kučera <franta-hg@frantovo.cz>
parents:
162
diff
changeset
|
56 |
private final Properties formatterProperties = new Properties(); |
2e351d7c26c4
InfoLister: new listings: --list-java-properties and --list-environment-variables
František Kučera <franta-hg@frantovo.cz>
parents:
162
diff
changeset
|
57 |
private final Properties databaseProperties = new Properties(); |
2 | 58 |
|
59 |
public enum MODE { |
|
60 |
||
61 |
QUERY_NOW, |
|
62 |
PREPARE_BATCH, |
|
14 | 63 |
EXECUTE_BATCH, |
64 |
JUST_SHOW_INFO |
|
65 |
} |
|
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
66 |
private final List<NamedParameter> namedParameters = new ArrayList<>(); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
private final List<Parameter> numberedParameters = new ArrayList<>(); |
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
63
diff
changeset
|
68 |
private final EnumSet<InfoType> showInfo = EnumSet.noneOf(InfoType.class); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
public void validate() throws InvalidOptionsException { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
InvalidOptionsException e = new InvalidOptionsException(); |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
|
14 | 73 |
MODE mode = getMode(); |
74 |
if (mode == null) { |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
e.addProblem(new InvalidOptionsException.OptionProblem("Invalid combination of DB, SQL and BATCH – please specify just 2 of this 3 options")); |
14 | 76 |
} else if (mode == MODE.JUST_SHOW_INFO) { |
77 |
if (!namedParameters.isEmpty()) { |
|
78 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not use named parameters if just showing info.")); |
|
79 |
} |
|
80 |
if (!numberedParameters.isEmpty()) { |
|
81 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not use numbered parameters if just showing info.")); |
|
82 |
} |
|
83 |
if (isNotEmpty(sql, false)) { |
|
84 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify SQL if just showing info.")); |
|
85 |
} |
|
86 |
if (isNotEmpty(databaseName, false)) { |
|
87 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify database if just showing info.")); |
|
88 |
} |
|
89 |
if (batch) { |
|
90 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify batch if just showing info.")); |
|
91 |
} |
|
92 |
if (!equalz(namePrefix, DEFAULT_NAME_PREFIX)) { |
|
93 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name prefix if just showing info.")); |
|
94 |
} |
|
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
95 |
if (!equalz(nameSuffix, DEFAULT_NAME_SUFFIX)) { |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
96 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name suffix if just showing info.")); |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
97 |
} |
155 | 98 |
if (showInfo.contains(InfoType.CONNECTION) && databaseNamesToTest.isEmpty()) { |
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
99 |
e.addProblem(new InvalidOptionsException.OptionProblem("Please specify which database should be tested.")); |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
100 |
} |
159
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
101 |
if (showInfo.contains(InfoType.JDBC_PROPERTIES) && databaseNamesToListProperties.isEmpty()) { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
102 |
e.addProblem(new InvalidOptionsException.OptionProblem("Please specify for which database the properties should be listed.")); |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
103 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
104 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
106 |
if (!namedParameters.isEmpty() && !numberedParameters.isEmpty()) { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
107 |
e.addProblem(new InvalidOptionsException.OptionProblem("Named and numbered parameters can not be used together in one command.")); |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
108 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
109 |
|
63
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
110 |
try { |
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
111 |
Pattern.compile(namePrefix + "test" + nameSuffix); |
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
112 |
} catch (PatternSyntaxException regexException) { |
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
113 |
e.addProblem(new InvalidOptionsException.OptionProblem("Ivalid regular expression in name prefix or suffix", regexException)); |
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
114 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
if (e.hasProblems()) { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
throw e; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
119 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
120 |
|
2 | 121 |
private boolean hasSql() { |
122 |
return isNotEmpty(getSql(), true); |
|
123 |
} |
|
124 |
||
125 |
private boolean hasDb() { |
|
126 |
return isNotEmpty(getDatabaseName(), true); |
|
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* Depends on options: DB, BATCH, SQL |
|
131 |
* |
|
132 |
* @return mode | or null if options are not yet initialized or combination of options is |
|
133 |
* invalid |
|
134 |
*/ |
|
135 |
public MODE getMode() { |
|
136 |
if (hasDb() && !batch && hasSql()) { |
|
137 |
return MODE.QUERY_NOW; |
|
138 |
} else if (!hasDb() && batch && hasSql()) { |
|
139 |
return MODE.PREPARE_BATCH; |
|
140 |
} else if (hasDb() && batch && !hasSql()) { |
|
141 |
return MODE.EXECUTE_BATCH; |
|
142 |
} else { |
|
14 | 143 |
return showInfo.isEmpty() ? null : MODE.JUST_SHOW_INFO; |
2 | 144 |
} |
145 |
} |
|
146 |
||
147 |
public String getSql() { |
|
148 |
return sql; |
|
149 |
} |
|
150 |
||
151 |
public void setSql(String sql) { |
|
152 |
this.sql = sql; |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
153 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
154 |
|
2 | 155 |
public String getDatabaseName() { |
156 |
return databaseName; |
|
157 |
} |
|
158 |
||
159 |
public void setDatabaseName(String databaseName) { |
|
160 |
this.databaseName = databaseName; |
|
161 |
} |
|
162 |
||
246
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
163 |
public List<String> getRelationNames() { |
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
164 |
return relationNames; |
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
165 |
} |
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
166 |
|
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
167 |
public void addRelationName(String name) { |
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
168 |
relationNames.add(name); |
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
169 |
} |
277c18b48762
support custom relation names in the XML formatter (added --relation CLI option)
František Kučera <franta-hg@frantovo.cz>
parents:
238
diff
changeset
|
170 |
|
2 | 171 |
public void setBatch(boolean batch) { |
172 |
this.batch = batch; |
|
173 |
} |
|
174 |
||
175 |
public Collection<NamedParameter> getNamedParameters() { |
|
176 |
return namedParameters; |
|
177 |
} |
|
178 |
||
179 |
public List<Parameter> getNumberedParameters() { |
|
180 |
return numberedParameters; |
|
181 |
} |
|
182 |
||
183 |
public void addNumberedParameter(Parameter p) { |
|
184 |
numberedParameters.add(p); |
|
185 |
} |
|
186 |
||
187 |
public void addNamedParameter(NamedParameter p) { |
|
188 |
namedParameters.add(p); |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
189 |
} |
3 | 190 |
|
104
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
191 |
public Properties getDatabaseProperties() { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
192 |
return databaseProperties; |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
193 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
194 |
|
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
195 |
public Properties getFormatterProperties() { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
196 |
return formatterProperties; |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
197 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
198 |
|
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
199 |
public void addDatabaseProperty(Property p) { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
200 |
databaseProperties.add(p); |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
201 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
202 |
|
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
203 |
public void addFormatterProperty(Property p) { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
204 |
formatterProperties.add(p); |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
205 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
206 |
|
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
207 |
/** |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
208 |
* @return regular expression describing the name prefix |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
209 |
*/ |
3 | 210 |
public String getNamePrefix() { |
211 |
return namePrefix; |
|
212 |
} |
|
213 |
||
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
214 |
/** |
209
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
215 |
* @param namePrefix |
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
216 |
* @see #getNamePrefix() |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
217 |
*/ |
3 | 218 |
public void setNamePrefix(String namePrefix) { |
219 |
this.namePrefix = namePrefix; |
|
220 |
} |
|
14 | 221 |
|
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
222 |
/** |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
223 |
* @return regular expression describing the name prefix |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
224 |
*/ |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
225 |
public String getNameSuffix() { |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
226 |
return nameSuffix; |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
227 |
} |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
228 |
|
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
229 |
/** |
209
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
230 |
* @param nameSuffix |
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
231 |
* @see #getNameSuffix() |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
232 |
*/ |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
233 |
public void setNameSuffix(String nameSuffix) { |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
234 |
this.nameSuffix = nameSuffix; |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
235 |
} |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
236 |
|
14 | 237 |
public String getFormatterName() { |
238 |
return formatterName; |
|
239 |
} |
|
240 |
||
241 |
public void setFormatterName(String formatterName) { |
|
242 |
this.formatterName = formatterName; |
|
243 |
} |
|
244 |
||
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
63
diff
changeset
|
245 |
public void addShowInfo(InfoType info) { |
14 | 246 |
showInfo.add(info); |
247 |
} |
|
248 |
||
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
63
diff
changeset
|
249 |
public EnumSet<InfoType> getShowInfo() { |
14 | 250 |
return showInfo; |
251 |
} |
|
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
252 |
|
155 | 253 |
public Set<String> getDatabaseNamesToTest() { |
254 |
return databaseNamesToTest; |
|
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
255 |
} |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
256 |
|
159
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
257 |
public void addDatabaseNameToTest(String name) { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
258 |
databaseNamesToTest.add(name); |
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
259 |
} |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
260 |
|
159
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
261 |
public Set<String> getDatabaseNamesToListProperties() { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
262 |
return databaseNamesToListProperties; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
263 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
264 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
265 |
public void addDatabaseNameToListProperties(String name) { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
266 |
databaseNamesToListProperties.add(name); |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
155
diff
changeset
|
267 |
} |
209
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
268 |
|
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
269 |
public Set<String> getFormatterNamesToListProperties() { |
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
270 |
return formatterNamesToListProperties; |
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
271 |
} |
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
272 |
|
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
273 |
public void addFormatterNameToListProperties(String name) { |
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
274 |
formatterNamesToListProperties.add(name); |
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
275 |
} |
8dfe037b3274
property annotations: grounds for --list-formatter-properties
František Kučera <franta-hg@frantovo.cz>
parents:
200
diff
changeset
|
276 |
|
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
277 |
public SQLCommand getSQLCommand() { |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
278 |
if (namedParameters.isEmpty()) { |
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
|
279 |
return new SQLCommandNumbered(sql, numberedParameters); |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
280 |
} else { |
47 | 281 |
return new SQLCommandNamed(sql, namedParameters, namePrefix, nameSuffix); |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
282 |
} |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
283 |
} |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
284 |
|
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
285 |
public OutputStream getOutputStream() { |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
286 |
return System.out; |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
287 |
} |
146
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
288 |
|
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
289 |
public InputStream getInputStream() { |
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
290 |
return System.in; |
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
291 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
292 |
} |