author | František Kučera <franta-hg@frantovo.cz> |
Thu, 26 Dec 2013 11:58:14 +0100 | |
branch | v_0 |
changeset 68 | 574cd7fbb5b2 |
parent 62 | 7a88ac6ba40c |
child 69 | 0befec5034c2 |
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 |
|
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
20 |
import java.util.ArrayList; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
21 |
import java.util.HashMap; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
22 |
import java.util.List; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
23 |
import java.util.Map; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
24 |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
/** |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
* |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
* @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
|
28 |
*/ |
5 | 29 |
public class CLIParser { |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
31 |
public static final String TYPE_NAME_SEPARATOR = ":"; |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
32 |
|
9 | 33 |
public CLIOptions parseOptions(String[] args) throws CLIParserException { |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
CLIOptions options = new CLIOptions(); |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
68
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
36 |
List<SQLType> numberedTypes = new ArrayList<>(); |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
37 |
Map<String, SQLType> namedTypes = new HashMap<>(); |
2 | 38 |
|
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
for (int i = 0; i < args.length; i++) { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
String arg = args[i]; |
2 | 41 |
switch (arg) { |
42 |
case Tokens.TYPES: |
|
8 | 43 |
String typesString = fetchNext(args, ++i); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
44 |
|
10 | 45 |
for (String oneType : typesString.split(",")) { |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
46 |
int sepatratorIndex = oneType.indexOf(TYPE_NAME_SEPARATOR); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
47 |
if (sepatratorIndex == -1) { |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
48 |
numberedTypes.add(getType(oneType)); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
49 |
} else { |
12
2dcb67d90fd2
unit-test: names, types, prefix
František Kučera <franta-hg@frantovo.cz>
parents:
10
diff
changeset
|
50 |
String namePart = oneType.substring(0, sepatratorIndex).trim(); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
51 |
String typePart = oneType.substring(sepatratorIndex + TYPE_NAME_SEPARATOR.length(), oneType.length()); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
52 |
namedTypes.put(namePart, getType(typePart)); |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
53 |
} |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
54 |
} |
2 | 55 |
break; |
56 |
case Tokens.NAME_PREFIX: |
|
8 | 57 |
options.setNamePrefix(fetchNext(args, ++i)); |
2 | 58 |
break; |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
59 |
case Tokens.NAME_SUFFIX: |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
60 |
options.setNameSuffix(fetchNext(args, ++i)); |
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
61 |
break; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
case Tokens.DB: |
8 | 63 |
options.setDatabaseName(fetchNext(args, ++i)); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
break; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
case Tokens.SQL: |
8 | 66 |
options.setSql(fetchNext(args, ++i)); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
break; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
case Tokens.BATCH: |
2 | 69 |
options.setBatch(true); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
break; |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
71 |
case Tokens.DATA: // --data is the last option |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
72 |
for (i++; i < args.length; i++) { |
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
73 |
arg = args[i]; |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
74 |
Parameter parameter; |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
75 |
if (numberedTypes.isEmpty()) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
76 |
parameter = new Parameter(arg, null); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
77 |
} else { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
78 |
int paramIndex = options.getNumberedParameters().size(); |
68
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
79 |
SQLType paramType; |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
80 |
try { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
81 |
paramType = numberedTypes.get(paramIndex); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
82 |
} catch (IndexOutOfBoundsException e) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
83 |
throw new CLIParserException("Missing type for parameter #" + paramIndex, e); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
84 |
} catch (NullPointerException e) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
85 |
throw new CLIParserException("Invalid type definition for parameter #" + paramIndex, e); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
86 |
} |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
87 |
parameter = new Parameter(arg, paramType); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
88 |
} |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
89 |
options.addNumberedParameter(parameter); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
90 |
} |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
91 |
break; |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
92 |
case Tokens.DATA_NAMED: |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
93 |
for (i++; i < args.length; i++) { |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
94 |
String paramName = args[i]; |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
95 |
String paramValue = fetchNext(args, ++i); |
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
96 |
options.addNamedParameter(new NamedParameter(paramName, paramValue, namedTypes.get(paramName))); |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
97 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
break; |
14 | 99 |
case Tokens.FORMATTER: |
100 |
options.setFormatterName(fetchNext(args, ++i)); |
|
101 |
break; |
|
102 |
case Tokens.INFO_HELP: |
|
103 |
options.addShowInfo(CLIOptions.INFO_TYPE.HELP); |
|
104 |
break; |
|
105 |
case Tokens.INFO_FORMATTERS: |
|
106 |
options.addShowInfo(CLIOptions.INFO_TYPE.FORMATTERS); |
|
107 |
break; |
|
108 |
case Tokens.INFO_LICENSE: |
|
109 |
options.addShowInfo(CLIOptions.INFO_TYPE.LICENSE); |
|
110 |
break; |
|
111 |
case Tokens.INFO_TYPES: |
|
112 |
options.addShowInfo(CLIOptions.INFO_TYPE.TYPES); |
|
113 |
break; |
|
114 |
case Tokens.INFO_VERSION: |
|
115 |
options.addShowInfo(CLIOptions.INFO_TYPE.VERSION); |
|
116 |
break; |
|
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
117 |
case Tokens.INFO_DATABASES: |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
118 |
options.addShowInfo(CLIOptions.INFO_TYPE.DATABASES); |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
119 |
break; |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
120 |
case Tokens.INFO_CONNECTION: |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
121 |
options.addShowInfo(CLIOptions.INFO_TYPE.CONNECTION); |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
122 |
options.setDatabaseNameToTest(fetchNext(args, ++i)); |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
123 |
break; |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
124 |
default: |
9 | 125 |
throw new CLIParserException("Unknown option: " + arg); |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
126 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
} |
8 | 128 |
return options; |
129 |
} |
|
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
130 |
|
9 | 131 |
private String fetchNext(String[] args, int index) throws CLIParserException { |
8 | 132 |
if (index < args.length) { |
133 |
return args[index]; |
|
134 |
} else { |
|
9 | 135 |
throw new CLIParserException("Expecting value for option: " + args[index - 1]); |
8 | 136 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
137 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
138 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
139 |
public static class Tokens { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
140 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
141 |
public static final String DB = "--db"; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
142 |
public static final String SQL = "--sql"; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
143 |
public static final String BATCH = "--batch"; |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
144 |
public static final String DATA = "--data"; |
52
e2ba2af0ef40
new option --data-named (then follows name/value pairs without prefix/suffix)
František Kučera <franta-hg@frantovo.cz>
parents:
49
diff
changeset
|
145 |
public static final String DATA_NAMED = "--data-named"; |
2 | 146 |
public static final String NAME_PREFIX = "--name-prefix"; |
44
67581ec4396e
named parameters: suffix (default is empty)
František Kučera <franta-hg@frantovo.cz>
parents:
37
diff
changeset
|
147 |
public static final String NAME_SUFFIX = "--name-suffix"; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
148 |
public static final String TYPES = "--types"; |
14 | 149 |
public static final String FORMATTER = "--formatter"; |
150 |
public static final String INFO_HELP = "--help"; |
|
151 |
public static final String INFO_VERSION = "--version"; |
|
152 |
public static final String INFO_LICENSE = "--license"; |
|
153 |
public static final String INFO_FORMATTERS = "--list-formatters"; |
|
154 |
public static final String INFO_TYPES = "--list-types"; |
|
15
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
155 |
public static final String INFO_DATABASES = "--list-databases"; |
bbd335b5410c
show info basics: list databases + test connection
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
156 |
public static final String INFO_CONNECTION = "--test-connection"; |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
157 |
|
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
158 |
private Tokens() { |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
159 |
} |
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
160 |
} |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
161 |
|
68
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
162 |
private SQLType getType(String typeString) throws CLIParserException { |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
163 |
try { |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
164 |
return SQLType.valueOf(typeString.trim()); |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
165 |
} catch (IllegalArgumentException e) { |
574cd7fbb5b2
SQLType enum wrapper for java.sql.Types
František Kučera <franta-hg@frantovo.cz>
parents:
62
diff
changeset
|
166 |
throw new CLIParserException("Unsupported type: " + typeString, e); |
8 | 167 |
} |
4
f5c3350f3d78
data/types CLI options parsing
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
168 |
} |
1
f32dac78d13a
WOW some classes LOL; TODO: refactor
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
169 |
} |