named parameters: suffix (default is empty) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 23 Dec 2013 20:15:23 +0100
branchv_0
changeset 4467581ec4396e
parent 43 2813d3409afd
child 45 ce33736066b1
named parameters: suffix (default is empty)
java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java
java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java	Mon Dec 23 18:27:57 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java	Mon Dec 23 20:15:23 2013 +0100
     1.3 @@ -33,10 +33,12 @@
     1.4  public class CLIOptions {
     1.5  
     1.6  	public static final String DEFAULT_NAME_PREFIX = ":";
     1.7 +	public static final String DEFAULT_NAME_SUFFIX = ":";
     1.8  	private String sql;
     1.9  	private String databaseName;
    1.10  	private String databaseNameToTest;
    1.11  	private String namePrefix = DEFAULT_NAME_PREFIX;
    1.12 +	private String nameSuffix = DEFAULT_NAME_SUFFIX;
    1.13  	private String formatterName;
    1.14  	private boolean batch;
    1.15  
    1.16 @@ -90,6 +92,9 @@
    1.17  			if (!equalz(namePrefix, DEFAULT_NAME_PREFIX)) {
    1.18  				e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name prefix if just showing info."));
    1.19  			}
    1.20 +			if (!equalz(nameSuffix, DEFAULT_NAME_SUFFIX)) {
    1.21 +				e.addProblem(new InvalidOptionsException.OptionProblem("Do not specify name suffix if just showing info."));
    1.22 +			}
    1.23  			if (showInfo.contains(INFO_TYPE.CONNECTION) && isEmpty(databaseNameToTest, false)) {
    1.24  				e.addProblem(new InvalidOptionsException.OptionProblem("Please specify which database should be tested."));
    1.25  			}
    1.26 @@ -175,6 +180,14 @@
    1.27  		this.namePrefix = namePrefix;
    1.28  	}
    1.29  
    1.30 +	public String getNameSuffix() {
    1.31 +		return nameSuffix;
    1.32 +	}
    1.33 +
    1.34 +	public void setNameSuffix(String nameSuffix) {
    1.35 +		this.nameSuffix = nameSuffix;
    1.36 +	}
    1.37 +
    1.38  	public String getFormatterName() {
    1.39  		return formatterName;
    1.40  	}
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java	Mon Dec 23 18:27:57 2013 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java	Mon Dec 23 20:15:23 2013 +0100
     2.3 @@ -70,6 +70,9 @@
     2.4  				case Tokens.NAME_PREFIX:
     2.5  					options.setNamePrefix(fetchNext(args, ++i));
     2.6  					break;
     2.7 +				case Tokens.NAME_SUFFIX:
     2.8 +					options.setNameSuffix(fetchNext(args, ++i));
     2.9 +					break;
    2.10  				case Tokens.DB:
    2.11  					options.setDatabaseName(fetchNext(args, ++i));
    2.12  					break;
    2.13 @@ -83,7 +86,7 @@
    2.14  					for (i++; i < args.length; i++) {
    2.15  						arg = args[i];
    2.16  
    2.17 -						if (arg.startsWith(options.getNamePrefix())) { // Named parameters:
    2.18 +						if (arg.startsWith(options.getNamePrefix()) && arg.endsWith(options.getNameSuffix())) { // Named parameters:
    2.19  							String paramName = arg.substring(options.getNamePrefix().length());
    2.20  							String paramValue = fetchNext(args, ++i);
    2.21  							options.addNamedParameter(new NamedParameter(paramName, paramValue, namedTypes.get(paramName)));
    2.22 @@ -154,6 +157,7 @@
    2.23  		public static final String BATCH = "--batch";
    2.24  		public static final String DATA = "--data";
    2.25  		public static final String NAME_PREFIX = "--name-prefix";
    2.26 +		public static final String NAME_SUFFIX = "--name-suffix";
    2.27  		public static final String TYPES = "--types";
    2.28  		public static final String FORMATTER = "--formatter";
    2.29  		public static final String INFO_HELP = "--help";