push action data and action properties to action context
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 04 Sep 2014 16:07:10 +0200
changeset 64e2c691eedf4d
parent 63 89acb486bb52
child 65 5c4ae2ed5d97
push action data and action properties to action context
java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java
java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIStarter.java
java/alt2xml-lib-output/src/cz/frantovo/alt2xml/out/ActionContext.java
java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java
     1.1 --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java	Thu Sep 04 00:39:11 2014 +0200
     1.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIOptions.java	Thu Sep 04 16:07:10 2014 +0200
     1.3 @@ -46,7 +46,7 @@
     1.4  
     1.5  	public void validate() throws InvalidOptionsException {
     1.6  		InvalidOptionsException e = new InvalidOptionsException();
     1.7 -		
     1.8 +
     1.9  		if (inputFile == null && systemId == null) {
    1.10  			e.addProblem(new InvalidOptionsException.OptionProblem("Please specify also systemId when reading from a stream (like STDIN) instead of from a file."));
    1.11  		}
    1.12 @@ -109,12 +109,23 @@
    1.13  		readerProperties.put(name, value);
    1.14  	}
    1.15  
    1.16 +	public Properties getReaderProperties() {
    1.17 +		return readerProperties;
    1.18 +	}
    1.19 +
    1.20  	public void addActionProperty(String name, String value) {
    1.21  		actionProperties.put(name, value);
    1.22  	}
    1.23  
    1.24 +	public Properties getActionProperties() {
    1.25 +		return actionProperties;
    1.26 +	}
    1.27 +
    1.28  	public void addActionData(String value) {
    1.29  		actionData.add(value);
    1.30  	}
    1.31  
    1.32 +	public List<String> getActionData() {
    1.33 +		return actionData;
    1.34 +	}
    1.35  }
     2.1 --- a/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIStarter.java	Thu Sep 04 00:39:11 2014 +0200
     2.2 +++ b/java/alt2xml-cli/src/cz/frantovo/alt2xml/cli/CLIStarter.java	Thu Sep 04 16:07:10 2014 +0200
     2.3 @@ -79,6 +79,10 @@
     2.4  			} else {
     2.5  
     2.6  				ActionContext actionContext = new ActionContext(cliOptions.getOutputStream());
     2.7 +				
     2.8 +				actionContext.setActionProperties(cliOptions.getActionProperties());
     2.9 +				actionContext.setActionData(cliOptions.getActionData());
    2.10 +				
    2.11  				Action action = actionFactory.getAction(actionContext);
    2.12  
    2.13  				SAXParserFactory t = SAXParserFactory.newInstance();
     3.1 --- a/java/alt2xml-lib-output/src/cz/frantovo/alt2xml/out/ActionContext.java	Thu Sep 04 00:39:11 2014 +0200
     3.2 +++ b/java/alt2xml-lib-output/src/cz/frantovo/alt2xml/out/ActionContext.java	Thu Sep 04 16:07:10 2014 +0200
     3.3 @@ -18,6 +18,8 @@
     3.4  package cz.frantovo.alt2xml.out;
     3.5  
     3.6  import java.io.OutputStream;
     3.7 +import java.util.List;
     3.8 +import java.util.Properties;
     3.9  
    3.10  /**
    3.11   * Context for one action instance.
    3.12 @@ -26,7 +28,9 @@
    3.13   */
    3.14  public class ActionContext {
    3.15  
    3.16 -	private OutputStream outputStream;
    3.17 +	private final OutputStream outputStream;
    3.18 +	private Properties actionProperties;
    3.19 +	private List<String> actionData;
    3.20  
    3.21  	public ActionContext(OutputStream outputStream) {
    3.22  		this.outputStream = outputStream;
    3.23 @@ -36,4 +40,20 @@
    3.24  		return outputStream;
    3.25  	}
    3.26  
    3.27 +	public Properties getActionProperties() {
    3.28 +		return actionProperties;
    3.29 +	}
    3.30 +
    3.31 +	public void setActionProperties(Properties actionProperties) {
    3.32 +		this.actionProperties = actionProperties;
    3.33 +	}
    3.34 +
    3.35 +	public List<String> getActionData() {
    3.36 +		return actionData;
    3.37 +	}
    3.38 +
    3.39 +	public void setActionData(List<String> actionData) {
    3.40 +		this.actionData = actionData;
    3.41 +	}
    3.42 +
    3.43  }
     4.1 --- a/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java	Thu Sep 04 00:39:11 2014 +0200
     4.2 +++ b/java/alt2xml-out-xpath/src/cz/frantovo/alt2xml/out/xpath/XPathAction.java	Thu Sep 04 16:07:10 2014 +0200
     4.3 @@ -26,7 +26,6 @@
     4.4  import javax.xml.xpath.XPathExpression;
     4.5  import javax.xml.xpath.XPathExpressionException;
     4.6  import javax.xml.xpath.XPathFactory;
     4.7 -import org.w3c.dom.Node;
     4.8  
     4.9  /**
    4.10   *