|
21 | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22 | 22 | * SOFTWARE.
|
23 | 23 | */
|
| 24 | + |
24 | 25 | package org.edmcouncil.rdf_toolkit.runner;
|
25 | 26 |
|
26 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.BASE_IRI; |
27 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.INDENT; |
28 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.INFER_BASE_IRI; |
29 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.INLINE_BLANK_NODES; |
30 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.LEADING_COMMENT; |
31 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.LINE_END; |
32 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.OMIT_XMLNS_NAMESPACE; |
33 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.OVERRIDE_STRING_LANGUAGE; |
34 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.SHORT_IRI_PRIORITY; |
35 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.SOURCE; |
36 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.SOURCE_DIRECTORY; |
37 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.SOURCE_DIRECTORY_PATTERN; |
38 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.SOURCE_FORMAT; |
39 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.STRING_DATA_TYPING; |
40 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.TARGET; |
41 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.TARGET_DIRECTORY; |
42 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.TARGET_DIRECTORY_PATTERN; |
43 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.TARGET_FORMAT; |
44 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.TRAILING_COMMENT; |
45 |
| -import static org.edmcouncil.rdf_toolkit.runner.CommandLineOption.USE_DTD_SUBSET; |
46 |
| -import static org.edmcouncil.rdf_toolkit.runner.RunningMode.PRINT_USAGE_AND_EXIT; |
47 |
| -import static org.edmcouncil.rdf_toolkit.runner.RunningMode.RUN_ON_DIRECTORY; |
| 27 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.BASE_IRI; |
| 28 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.INDENT; |
| 29 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.INFER_BASE_IRI; |
| 30 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.INLINE_BLANK_NODES; |
| 31 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.LEADING_COMMENT; |
| 32 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.LINE_END; |
| 33 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.OMIT_XMLNS_NAMESPACE; |
| 34 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.OVERRIDE_STRING_LANGUAGE; |
| 35 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.SHORT_IRI_PRIORITY; |
| 36 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.SOURCE; |
| 37 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.SOURCE_DIRECTORY; |
| 38 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.SOURCE_DIRECTORY_PATTERN; |
| 39 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.SOURCE_FORMAT; |
| 40 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.STRING_DATA_TYPING; |
| 41 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.SUPPRESS_NAMED_INDIVIDUALS; |
| 42 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.TARGET; |
| 43 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.TARGET_DIRECTORY; |
| 44 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.TARGET_DIRECTORY_PATTERN; |
| 45 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.TARGET_FORMAT; |
| 46 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.TRAILING_COMMENT; |
| 47 | +import static org.edmcouncil.rdf_toolkit.runner.constant.CommandLineOption.USE_DTD_SUBSET; |
| 48 | +import static org.edmcouncil.rdf_toolkit.runner.constant.RunningMode.PRINT_USAGE_AND_EXIT; |
| 49 | +import static org.edmcouncil.rdf_toolkit.runner.constant.RunningMode.RUN_ON_DIRECTORY; |
48 | 50 | import org.apache.commons.cli.CommandLine;
|
49 | 51 | import org.eclipse.rdf4j.model.IRI;
|
50 | 52 | import org.eclipse.rdf4j.model.ValueFactory;
|
|
60 | 62 | import java.io.File;
|
61 | 63 | import java.io.FileInputStream;
|
62 | 64 | import java.io.FileNotFoundException;
|
63 |
| -import java.io.FileOutputStream; |
64 | 65 | import java.io.InputStream;
|
65 |
| -import java.io.OutputStream; |
66 | 66 |
|
67 | 67 | public class OptionHandler {
|
68 | 68 |
|
@@ -159,29 +159,29 @@ public File handleSourceFile() throws RdfToolkitOptionHandlingException, FileNot
|
159 | 159 |
|
160 | 160 | public void handleRunningOnDirectory(CommandLine commandLine, RdfToolkitOptions rdfToolkitOptions) {
|
161 | 161 | // Check if the command-line options suggest that a directory of files is to be formatted
|
162 |
| - if (commandLine.hasOption(SOURCE_DIRECTORY.getShortOpt()) || |
163 |
| - commandLine.hasOption(SOURCE_DIRECTORY_PATTERN.getShortOpt()) || |
164 |
| - commandLine.hasOption(TARGET_DIRECTORY.getShortOpt()) || |
165 |
| - commandLine.hasOption(TARGET_DIRECTORY_PATTERN.getShortOpt())) { |
| 162 | + if (commandLine.hasOption(SOURCE_DIRECTORY.getShortOpt()) |
| 163 | + || commandLine.hasOption(SOURCE_DIRECTORY_PATTERN.getShortOpt()) |
| 164 | + || commandLine.hasOption(TARGET_DIRECTORY.getShortOpt()) |
| 165 | + || commandLine.hasOption(TARGET_DIRECTORY_PATTERN.getShortOpt())) { |
166 | 166 | // Assume user wants to process a directory of files.
|
167 |
| - if (!commandLine.hasOption(SOURCE_DIRECTORY.getShortOpt()) || |
168 |
| - !commandLine.hasOption(SOURCE_DIRECTORY_PATTERN.getShortOpt()) || |
169 |
| - !commandLine.hasOption(TARGET_DIRECTORY.getShortOpt()) || |
170 |
| - !commandLine.hasOption(TARGET_DIRECTORY_PATTERN.getShortOpt())) { |
171 |
| - LOGGER.error("Directory processing options must all be used together: -sd (--source-directory), " + |
172 |
| - "-sdp (--source-directory-pattern), -td (--target-directory), -tdp (--target-directory-pattern)"); |
| 167 | + if (!commandLine.hasOption(SOURCE_DIRECTORY.getShortOpt()) |
| 168 | + || !commandLine.hasOption(SOURCE_DIRECTORY_PATTERN.getShortOpt()) |
| 169 | + || !commandLine.hasOption(TARGET_DIRECTORY.getShortOpt()) |
| 170 | + || !commandLine.hasOption(TARGET_DIRECTORY_PATTERN.getShortOpt())) { |
| 171 | + LOGGER.error("Directory processing options must all be used together: -sd (--source-directory), " |
| 172 | + + "-sdp (--source-directory-pattern), -td (--target-directory), -tdp (--target-directory-pattern)"); |
173 | 173 | rdfToolkitOptions.setRunningMode(PRINT_USAGE_AND_EXIT);
|
174 | 174 | }
|
175 |
| - if (commandLine.hasOption(SOURCE.getShortOpt()) || |
176 |
| - commandLine.hasOption(TARGET.getShortOpt())) { |
177 |
| - LOGGER.error("Source (-s or --source) and target (-t or --target) options cannot be used together with " + |
178 |
| - "directory processing options."); |
| 175 | + if (commandLine.hasOption(SOURCE.getShortOpt()) |
| 176 | + || commandLine.hasOption(TARGET.getShortOpt())) { |
| 177 | + LOGGER.error("Source (-s or --source) and target (-t or --target) options cannot be used together with " |
| 178 | + + "directory processing options."); |
179 | 179 | rdfToolkitOptions.setRunningMode(PRINT_USAGE_AND_EXIT);
|
180 | 180 | }
|
181 |
| - if (!commandLine.hasOption(SOURCE_FORMAT.getShortOpt()) || |
182 |
| - !commandLine.hasOption(TARGET_FORMAT.getShortOpt())) { |
183 |
| - LOGGER.error("Source format (-sfmt or --source-format) and target format (-tfmt or --target-format) options " + |
184 |
| - "must be provided when using directory processing options."); |
| 181 | + if (!commandLine.hasOption(SOURCE_FORMAT.getShortOpt()) |
| 182 | + || !commandLine.hasOption(TARGET_FORMAT.getShortOpt())) { |
| 183 | + LOGGER.error("Source format (-sfmt or --source-format) and target format (-tfmt or --target-format) options " |
| 184 | + + "must be provided when using directory processing options."); |
185 | 185 | rdfToolkitOptions.setRunningMode(PRINT_USAGE_AND_EXIT);
|
186 | 186 | }
|
187 | 187 |
|
@@ -386,4 +386,9 @@ public void handleOmitXmlnsNamespace() {
|
386 | 386 | boolean omitXmlnsNamespace = commandLine.hasOption(OMIT_XMLNS_NAMESPACE.getShortOpt());
|
387 | 387 | rdfToolkitOptions.setOmitXmlnsNamespace(omitXmlnsNamespace);
|
388 | 388 | }
|
| 389 | + |
| 390 | + public void handleSuppressNamedIndividuals() { |
| 391 | + boolean suppressNamedIndividuals = commandLine.hasOption(SUPPRESS_NAMED_INDIVIDUALS.getShortOpt()); |
| 392 | + rdfToolkitOptions.setSuppressNamedIndividuals(suppressNamedIndividuals); |
| 393 | + } |
389 | 394 | }
|
0 commit comments