commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject cvs commit: jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2 ArgumentBuilder.java DefaultOptionBuilder.java ArgumentImpl.java DefaultOption.java SwitchBuilder.java Switch.java
Date Tue, 21 Oct 2003 19:28:14 GMT
roxspring    2003/10/21 12:28:14

  Modified:    cli/src/java/org/apache/commons/cli2 ArgumentBuilder.java
                        DefaultOptionBuilder.java ArgumentImpl.java
                        DefaultOption.java SwitchBuilder.java Switch.java
  Log:
  Moved constant deafults from Builder classes to corresponding Option implementation
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.3       +5 -8      jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/ArgumentBuilder.java
  
  Index: ArgumentBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/ArgumentBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArgumentBuilder.java	19 Oct 2003 13:54:59 -0000	1.2
  +++ ArgumentBuilder.java	21 Oct 2003 19:28:14 -0000	1.3
  @@ -68,9 +68,6 @@
    */
   public class ArgumentBuilder {
   
  -	private static final char DEFAULT_INITIAL_SEPARATOR = 0;
  -	private static final char DEFAULT_SUBSEQUENT_SEPARATOR = 0;
  -
   	public ArgumentBuilder() {
   		reset();
   	}
  @@ -125,8 +122,8 @@
   		description = null;
   		minimum = 0;
   		maximum = Integer.MAX_VALUE;
  -		initialSeparator = DEFAULT_INITIAL_SEPARATOR;
  -		subsequentSeparator = DEFAULT_SUBSEQUENT_SEPARATOR;
  +		initialSeparator = ArgumentImpl.DEFAULT_INITIAL_SEPARATOR;
  +		subsequentSeparator = ArgumentImpl.DEFAULT_SUBSEQUENT_SEPARATOR;
   	}
   
   	/**
  
  
  
  1.2       +4 -8      jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/DefaultOptionBuilder.java
  
  Index: DefaultOptionBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/DefaultOptionBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultOptionBuilder.java	18 Oct 2003 22:00:09 -0000	1.1
  +++ DefaultOptionBuilder.java	21 Oct 2003 19:28:14 -0000	1.2
  @@ -65,10 +65,6 @@
   
   public class DefaultOptionBuilder {
   
  -	private static final String DEFAULT_SHORT_PREFIX = "-";
  -	private static final String DEFAULT_LONG_PREFIX = "--";
  -	private static final boolean DEFAULT_BURST_ENABLED = true;
  -
   	private final String shortPrefix;
   	private final String longPrefix;
   	private final boolean burstEnabled;
  @@ -83,7 +79,7 @@
   	private Group children;
   
   	public DefaultOptionBuilder() {
  -		this(DEFAULT_SHORT_PREFIX, DEFAULT_LONG_PREFIX, DEFAULT_BURST_ENABLED);
  +		this(DefaultOption.DEFAULT_SHORT_PREFIX, DefaultOption.DEFAULT_LONG_PREFIX, DefaultOption.DEFAULT_BURST_ENABLED);
   	}
   
   	public DefaultOptionBuilder(
  
  
  
  1.2       +28 -5     jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/ArgumentImpl.java
  
  Index: ArgumentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/ArgumentImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArgumentImpl.java	18 Oct 2003 22:00:04 -0000	1.1
  +++ ArgumentImpl.java	21 Oct 2003 19:28:14 -0000	1.2
  @@ -86,6 +86,9 @@
   	private final Validator validator;
   
   	private static final char NUL = '\0';
  +    public static final char DEFAULT_INITIAL_SEPARATOR = NUL;
  +    public static final char DEFAULT_SUBSEQUENT_SEPARATOR = NUL;
  +
   
   	/**
   	 * Creates a new Argument instance.
  @@ -119,6 +122,11 @@
   		this.initialSplit = initialSeparator != NUL;
   		this.subsequentSplit = subsequentSeparator != NUL;
   		this.validator = validator;
  +        
  +        if(minimum>maximum){
  +            throw new IllegalArgumentException("minimum must not exceed maximum");
  +        }
  +        
   	}
   
   	/* (non-Javadoc)
  @@ -193,7 +201,7 @@
   		final ListIterator args,
   		final Option option)
   		throws OptionException {
  -
  +        
   		//commandLine.addOption(option);
   		int argumentCount;
   		final List argumentValues = commandLine.getValues(option);
  @@ -237,7 +245,7 @@
   				commandLine.addValue(option, argument);
   			}
   		}
  -
  +        
   		if (argumentCount < minimum) {
   			throw new MissingValueException(option);
   		}
  @@ -403,4 +411,19 @@
   		final HelpLine helpLine = new HelpLine(this, depth);
   		return Collections.singletonList(helpLine);
   	}
  +    
  +    /**
  +     * @return Returns the maximum.
  +     */
  +    public int getMaximum() {
  +        return maximum;
  +    }
  +
  +    /**
  +     * @return Returns the minimum.
  +     */
  +    public int getMinimum() {
  +        return minimum;
  +    }
  +
   }
  
  
  
  1.2       +7 -3      jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/DefaultOption.java
  
  Index: DefaultOption.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/DefaultOption.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultOption.java	18 Oct 2003 22:00:09 -0000	1.1
  +++ DefaultOption.java	21 Oct 2003 19:28:14 -0000	1.2
  @@ -71,6 +71,10 @@
   
   public class DefaultOption extends ParentImpl {
   
  +    public static final String DEFAULT_SHORT_PREFIX = "-";
  +    public static final String DEFAULT_LONG_PREFIX = "--";
  +    public static final boolean DEFAULT_BURST_ENABLED = true;
  +
   	private final String preferredName;
   	private final Set aliases;
   	private final Set burstAliases;
  
  
  
  1.2       +4 -7      jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/SwitchBuilder.java
  
  Index: SwitchBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/SwitchBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SwitchBuilder.java	18 Oct 2003 22:00:16 -0000	1.1
  +++ SwitchBuilder.java	21 Oct 2003 19:28:14 -0000	1.2
  @@ -65,9 +65,6 @@
   
   public class SwitchBuilder {
   
  -	private static final String DEFAULT_ENABLED_PREFIX = "+";
  -	private static final String DEFAULT_DISABLED_PREFIX = "-";
  -
   	private final String enabledPrefix;
   	private final String disabledPrefix;
   
  @@ -79,7 +76,7 @@
   	private Group children;
   
   	public SwitchBuilder() {
  -		this(DEFAULT_ENABLED_PREFIX, DEFAULT_DISABLED_PREFIX);
  +		this(Switch.DEFAULT_ENABLED_PREFIX, Switch.DEFAULT_DISABLED_PREFIX);
   	}
   
   	public SwitchBuilder(
  
  
  
  1.2       +6 -3      jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/Switch.java
  
  Index: Switch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/Switch.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Switch.java	18 Oct 2003 22:00:16 -0000	1.1
  +++ Switch.java	21 Oct 2003 19:28:14 -0000	1.2
  @@ -71,6 +71,9 @@
   
   public class Switch extends ParentImpl {
   
  +    public static final String DEFAULT_ENABLED_PREFIX = "+";
  +    public static final String DEFAULT_DISABLED_PREFIX = "-";
  +
   	private final String enabledPrefix;
   	private final String disabledPrefix;
   	private final boolean required;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message