java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java
changeset 55 c703fb7f088f
parent 54 3d5cc308e268
child 56 5e79450a521e
     1.1 --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java	Thu Jul 03 00:18:35 2014 +0200
     1.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java	Thu Jul 03 00:37:38 2014 +0200
     1.3 @@ -23,6 +23,7 @@
     1.4  import java.util.ArrayList;
     1.5  import java.util.List;
     1.6  import java.util.Properties;
     1.7 +import org.xml.sax.InputSource;
     1.8  
     1.9  /**
    1.10   * Holds options from command line, validates them, combines with configuration and provides derived
    1.11 @@ -34,7 +35,6 @@
    1.12  
    1.13  	private File inputFile;
    1.14  	private InputStream inputStream;
    1.15 -	private String inputUrl;
    1.16  
    1.17  	private String systemId;
    1.18  	private final Properties readerProperties = new Properties();
    1.19 @@ -48,7 +48,7 @@
    1.20  		InvalidOptionsException e = new InvalidOptionsException();
    1.21  
    1.22  		/**
    1.23 -		 * TODO: validace
    1.24 +		 * TODO: validate
    1.25  		 */
    1.26  		if (e.hasProblems()) {
    1.27  			throw e;
    1.28 @@ -63,22 +63,41 @@
    1.29  		this.inputStream = inputStream;
    1.30  	}
    1.31  
    1.32 -	public void setInputUrl(String inputUrl) {
    1.33 -		this.inputUrl = inputUrl;
    1.34 -	}
    1.35 -
    1.36  	public void setSystemId(String systemId) {
    1.37  		this.systemId = systemId;
    1.38  	}
    1.39 - 
    1.40 +
    1.41 +	public InputSource getInputSource() {
    1.42 +		InputSource is = new InputSource();
    1.43 +
    1.44 +		if (inputFile != null) {
    1.45 +			is.setSystemId(inputFile.toURI().toASCIIString());
    1.46 +		}
    1.47 +
    1.48 +		if (inputStream != null) {
    1.49 +			is.setByteStream(inputStream);
    1.50 +			is.setSystemId(systemId);
    1.51 +		}
    1.52 +
    1.53 +		return is;
    1.54 +	}
    1.55 +
    1.56  	public void setOutputStream(OutputStream outputStream) {
    1.57  		this.outputStream = outputStream;
    1.58  	}
    1.59 -	
    1.60 +
    1.61 +	public OutputStream getOutputStream() {
    1.62 +		return outputStream;
    1.63 +	}
    1.64 +
    1.65  	public void setAction(String action) {
    1.66  		this.action = action;
    1.67  	}
    1.68  
    1.69 +	public String getAction() {
    1.70 +		return action;
    1.71 +	}
    1.72 +
    1.73  	public void addReaderProperty(String name, String value) {
    1.74  		readerProperties.put(name, value);
    1.75  	}