1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java Thu Jul 03 00:18:35 2014 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +/**
1.5 + * Alt2XML
1.6 + * Copyright © 2014 František Kučera (frantovo.cz)
1.7 + *
1.8 + * This program is free software: you can redistribute it and/or modify
1.9 + * it under the terms of the GNU General Public License as published by
1.10 + * the Free Software Foundation, either version 3 of the License, or
1.11 + * (at your option) any later version.
1.12 + *
1.13 + * This program is distributed in the hope that it will be useful,
1.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.16 + * GNU General Public License for more details.
1.17 + *
1.18 + * You should have received a copy of the GNU General Public License
1.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.20 + */
1.21 +package cz.frantovo.alt2xml.cli;
1.22 +
1.23 +import java.io.File;
1.24 +import java.io.InputStream;
1.25 +import java.io.OutputStream;
1.26 +import java.util.ArrayList;
1.27 +import java.util.List;
1.28 +import java.util.Properties;
1.29 +
1.30 +/**
1.31 + * Holds options from command line, validates them, combines with configuration and provides derived
1.32 + * objects.
1.33 + *
1.34 + * @author Ing. František Kučera (frantovo.cz)
1.35 + */
1.36 +public class CLIOptions {
1.37 +
1.38 + private File inputFile;
1.39 + private InputStream inputStream;
1.40 + private String inputUrl;
1.41 +
1.42 + private String systemId;
1.43 + private final Properties readerProperties = new Properties();
1.44 +
1.45 + private OutputStream outputStream;
1.46 + private String action;
1.47 + private final Properties actionProperties = new Properties();
1.48 + private final List<String> actionData = new ArrayList<>();
1.49 +
1.50 + public void validate() throws InvalidOptionsException {
1.51 + InvalidOptionsException e = new InvalidOptionsException();
1.52 +
1.53 + /**
1.54 + * TODO: validace
1.55 + */
1.56 + if (e.hasProblems()) {
1.57 + throw e;
1.58 + }
1.59 + }
1.60 +
1.61 + public void setInputFile(File inputFile) {
1.62 + this.inputFile = inputFile;
1.63 + }
1.64 +
1.65 + public void setInputStream(InputStream inputStream) {
1.66 + this.inputStream = inputStream;
1.67 + }
1.68 +
1.69 + public void setInputUrl(String inputUrl) {
1.70 + this.inputUrl = inputUrl;
1.71 + }
1.72 +
1.73 + public void setSystemId(String systemId) {
1.74 + this.systemId = systemId;
1.75 + }
1.76 +
1.77 + public void setOutputStream(OutputStream outputStream) {
1.78 + this.outputStream = outputStream;
1.79 + }
1.80 +
1.81 + public void setAction(String action) {
1.82 + this.action = action;
1.83 + }
1.84 +
1.85 + public void addReaderProperty(String name, String value) {
1.86 + readerProperties.put(name, value);
1.87 + }
1.88 +
1.89 + public void addActionProperty(String name, String value) {
1.90 + actionProperties.put(name, value);
1.91 + }
1.92 +
1.93 + public void addActionData(String value) {
1.94 + actionData.add(value);
1.95 + }
1.96 +
1.97 +}