author | František Kučera <franta-hg@frantovo.cz> |
Sun, 24 May 2015 19:10:25 +0200 | |
branch | v_0 |
changeset 200 | 2e351d7c26c4 |
parent 162 | 7863d8a423d4 |
child 209 | 8dfe037b3274 |
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 |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
8 |
* (at your option) any later version. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
9 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
10 |
* 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
|
11 |
* 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
|
12 |
* 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
|
13 |
* GNU General Public License for more details. |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
14 |
* |
5b8fcd35d4d6
license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
15 |
* 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
|
16 |
* 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
|
17 |
*/ |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
package info.globalcode.sql.dk; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
import static info.globalcode.sql.dk.Functions.isNotEmpty; |
14 | 21 |
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
|
22 |
import info.globalcode.sql.dk.InfoLister.InfoType; |
104
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
23 |
import info.globalcode.sql.dk.configuration.Properties; |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
24 |
import info.globalcode.sql.dk.configuration.Property; |
146
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
25 |
import java.io.InputStream; |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
26 |
import java.io.OutputStream; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
import java.util.ArrayList; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
import java.util.Collection; |
14 | 29 |
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
|
30 |
import java.util.LinkedHashSet; |
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; |
200
2e351d7c26c4
InfoLister: new listings: --list-java-properties and --list-environment-variables
František Kučera <franta-hg@frantovo.cz>
parents:
162
diff
changeset
|
48 |
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
|
49 |
private final Set<String> databaseNamesToListProperties = new LinkedHashSet<>(); |
3 | 50 |
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
|
51 |
private String nameSuffix = DEFAULT_NAME_SUFFIX; |
14 | 52 |
private String formatterName; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
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
|
54 |
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
|
55 |
private final Properties databaseProperties = new Properties(); |
2 | 56 |
|
57 |
public enum MODE { |
|
58 |
||
59 |
QUERY_NOW, |
|
60 |
PREPARE_BATCH, |
|
14 | 61 |
EXECUTE_BATCH, |
62 |
JUST_SHOW_INFO |
|
63 |
} |
|
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
public void validate() throws InvalidOptionsException { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
InvalidOptionsException e = new InvalidOptionsException(); |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
|
14 | 71 |
MODE mode = getMode(); |
72 |
if (mode == null) { |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
e.addProblem(new InvalidOptionsException.OptionProblem("Invalid combination of DB, SQL and BATCH – please specify just 2 of this 3 options")); |
14 | 74 |
} else if (mode == MODE.JUST_SHOW_INFO) { |
75 |
if (!namedParameters.isEmpty()) { |
|
76 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not use named parameters if just showing info.")); |
|
77 |
} |
|
78 |
if (!numberedParameters.isEmpty()) { |
|
79 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not use numbered parameters if just showing info.")); |
|
80 |
} |
|
81 |
if (isNotEmpty(sql, false)) { |
|
82 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify SQL if just showing info.")); |
|
83 |
} |
|
84 |
if (isNotEmpty(databaseName, false)) { |
|
85 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify database if just showing info.")); |
|
86 |
} |
|
87 |
if (batch) { |
|
88 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify batch if just showing info.")); |
|
89 |
} |
|
90 |
if (!equalz(namePrefix, DEFAULT_NAME_PREFIX)) { |
|
91 |
e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name prefix if just showing info.")); |
|
92 |
} |
|
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
93 |
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
|
94 |
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
|
95 |
} |
155 | 96 |
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
|
97 |
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
|
98 |
} |
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
|
99 |
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
|
100 |
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
|
101 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
102 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
103 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
104 |
if (!namedParameters.isEmpty() && !numberedParameters.isEmpty()) { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
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
|
106 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
107 |
|
63
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
108 |
try { |
3b9ec9c23a37
validation: test if prefix/suffix are valid regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
54
diff
changeset
|
109 |
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
|
110 |
} 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
|
111 |
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
|
112 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
113 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
114 |
if (e.hasProblems()) { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
throw e; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
|
2 | 119 |
private boolean hasSql() { |
120 |
return isNotEmpty(getSql(), true); |
|
121 |
} |
|
122 |
||
123 |
private boolean hasDb() { |
|
124 |
return isNotEmpty(getDatabaseName(), true); |
|
125 |
} |
|
126 |
||
127 |
/** |
|
128 |
* Depends on options: DB, BATCH, SQL |
|
129 |
* |
|
130 |
* @return mode | or null if options are not yet initialized or combination of options is |
|
131 |
* invalid |
|
132 |
*/ |
|
133 |
public MODE getMode() { |
|
134 |
if (hasDb() && !batch && hasSql()) { |
|
135 |
return MODE.QUERY_NOW; |
|
136 |
} else if (!hasDb() && batch && hasSql()) { |
|
137 |
return MODE.PREPARE_BATCH; |
|
138 |
} else if (hasDb() && batch && !hasSql()) { |
|
139 |
return MODE.EXECUTE_BATCH; |
|
140 |
} else { |
|
14 | 141 |
return showInfo.isEmpty() ? null : MODE.JUST_SHOW_INFO; |
2 | 142 |
} |
143 |
} |
|
144 |
||
145 |
public String getSql() { |
|
146 |
return sql; |
|
147 |
} |
|
148 |
||
149 |
public void setSql(String sql) { |
|
150 |
this.sql = sql; |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
151 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
152 |
|
2 | 153 |
public String getDatabaseName() { |
154 |
return databaseName; |
|
155 |
} |
|
156 |
||
157 |
public void setDatabaseName(String databaseName) { |
|
158 |
this.databaseName = databaseName; |
|
159 |
} |
|
160 |
||
161 |
public void setBatch(boolean batch) { |
|
162 |
this.batch = batch; |
|
163 |
} |
|
164 |
||
165 |
public Collection<NamedParameter> getNamedParameters() { |
|
166 |
return namedParameters; |
|
167 |
} |
|
168 |
||
169 |
public List<Parameter> getNumberedParameters() { |
|
170 |
return numberedParameters; |
|
171 |
} |
|
172 |
||
173 |
public void addNumberedParameter(Parameter p) { |
|
174 |
numberedParameters.add(p); |
|
175 |
} |
|
176 |
||
177 |
public void addNamedParameter(NamedParameter p) { |
|
178 |
namedParameters.add(p); |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
179 |
} |
3 | 180 |
|
104
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
181 |
public Properties getDatabaseProperties() { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
182 |
return databaseProperties; |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
183 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
184 |
|
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
185 |
public Properties getFormatterProperties() { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
186 |
return formatterProperties; |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
187 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
188 |
|
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
189 |
public void addDatabaseProperty(Property p) { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
190 |
databaseProperties.add(p); |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
191 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
192 |
|
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
193 |
public void addFormatterProperty(Property p) { |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
194 |
formatterProperties.add(p); |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
195 |
} |
245f1b88a3e6
formatter/database properties
František Kučera <franta-hg@frantovo.cz>
parents:
74
diff
changeset
|
196 |
|
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
197 |
/** |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
198 |
* @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
|
199 |
*/ |
3 | 200 |
public String getNamePrefix() { |
201 |
return namePrefix; |
|
202 |
} |
|
203 |
||
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
204 |
/** |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
205 |
* @see #getNamePrefix() |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
206 |
*/ |
3 | 207 |
public void setNamePrefix(String namePrefix) { |
208 |
this.namePrefix = namePrefix; |
|
209 |
} |
|
14 | 210 |
|
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
211 |
/** |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
212 |
* @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
|
213 |
*/ |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
214 |
public String getNameSuffix() { |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
215 |
return nameSuffix; |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
216 |
} |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
217 |
|
54
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
218 |
/** |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
219 |
* @see #getNameSuffix() |
53020d0bd2e4
named parameters: prefix/suffix are now regular expressions
František Kučera <franta-hg@frantovo.cz>
parents:
47
diff
changeset
|
220 |
*/ |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
221 |
public void setNameSuffix(String nameSuffix) { |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
222 |
this.nameSuffix = nameSuffix; |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
223 |
} |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
224 |
|
14 | 225 |
public String getFormatterName() { |
226 |
return formatterName; |
|
227 |
} |
|
228 |
||
229 |
public void setFormatterName(String formatterName) { |
|
230 |
this.formatterName = formatterName; |
|
231 |
} |
|
232 |
||
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
63
diff
changeset
|
233 |
public void addShowInfo(InfoType info) { |
14 | 234 |
showInfo.add(info); |
235 |
} |
|
236 |
||
69
0befec5034c2
InfoLister, InfoType: switch → enum
František Kučera <franta-hg@frantovo.cz>
parents:
63
diff
changeset
|
237 |
public EnumSet<InfoType> getShowInfo() { |
14 | 238 |
return showInfo; |
239 |
} |
|
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
240 |
|
155 | 241 |
public Set<String> getDatabaseNamesToTest() { |
242 |
return databaseNamesToTest; |
|
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
243 |
} |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
244 |
|
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
|
245 |
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
|
246 |
databaseNamesToTest.add(name); |
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
247 |
} |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
248 |
|
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
|
249 |
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
|
250 |
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
|
251 |
} |
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
|
252 |
|
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
|
253 |
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
|
254 |
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
|
255 |
} |
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
|
256 |
|
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
257 |
public SQLCommand getSQLCommand() { |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
258 |
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
|
259 |
return new SQLCommandNumbered(sql, numberedParameters); |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
260 |
} else { |
47 | 261 |
return new SQLCommandNamed(sql, namedParameters, namePrefix, nameSuffix); |
34
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
262 |
} |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
263 |
} |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
264 |
|
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
265 |
public OutputStream getOutputStream() { |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
266 |
return System.out; |
9335cf31c0f2
first working version
František Kučera <franta-hg@frantovo.cz>
parents:
29
diff
changeset
|
267 |
} |
146
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
268 |
|
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
269 |
public InputStream getInputStream() { |
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
270 |
return System.in; |
4f4f515df807
BatchDecoder: basic decoder
František Kučera <franta-hg@frantovo.cz>
parents:
104
diff
changeset
|
271 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
272 |
} |