3 * Copyright © 2014 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package cz.frantovo.alt2xml.cli;
21 import java.io.InputStream;
22 import java.io.OutputStream;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Properties;
28 * Holds options from command line, validates them, combines with configuration and provides derived
31 * @author Ing. František Kučera (frantovo.cz)
33 public class CLIOptions {
35 private File inputFile;
36 private InputStream inputStream;
37 private String inputUrl;
39 private String systemId;
40 private final Properties readerProperties = new Properties();
42 private OutputStream outputStream;
43 private String action;
44 private final Properties actionProperties = new Properties();
45 private final List<String> actionData = new ArrayList<>();
47 public void validate() throws InvalidOptionsException {
48 InvalidOptionsException e = new InvalidOptionsException();
53 if (e.hasProblems()) {
58 public void setInputFile(File inputFile) {
59 this.inputFile = inputFile;
62 public void setInputStream(InputStream inputStream) {
63 this.inputStream = inputStream;
66 public void setInputUrl(String inputUrl) {
67 this.inputUrl = inputUrl;
70 public void setSystemId(String systemId) {
71 this.systemId = systemId;
74 public void setOutputStream(OutputStream outputStream) {
75 this.outputStream = outputStream;
78 public void setAction(String action) {
82 public void addReaderProperty(String name, String value) {
83 readerProperties.put(name, value);
86 public void addActionProperty(String name, String value) {
87 actionProperties.put(name, value);
90 public void addActionData(String value) {
91 actionData.add(value);