jkeyes      2003/10/21 08:39:47

  Modified:    cli/src/test/org/apache/commons/cli2/apps LsTest.java
               cli/src/java/org/apache/commons/cli2/validation
                        StringValidator.java
  Log:
  - now a Set of permitted values rather than a List
  
  Revision  Changes    Path
  1.2       +6 -6      
jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/apps/LsTest.java
  
  Index: LsTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/apps/LsTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LsTest.java       20 Oct 2003 21:28:18 -0000      1.1
  +++ LsTest.java       21 Oct 2003 15:39:46 -0000      1.2
  @@ -60,8 +60,8 @@
    */
   package org.apache.commons.cli2.apps;
   
  -import java.util.ArrayList;
  -import java.util.List;
  +import java.util.HashSet;
  +import java.util.Set;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -308,7 +308,7 @@
                   .withDescription("with -lt: sort by, and show, ctime (time of last 
modification of file status information) with -l:show ctime and sort by name 
otherwise: sort by ctime")
                   .create();
   
  -            final List colors = new ArrayList();
  +            final Set colors = new HashSet();
               colors.add("never");
               colors.add("always");
               colors.add("auto");
  
  
  
  1.2       +12 -15    
jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/validation/StringValidator.java
  
  Index: StringValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/validation/StringValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringValidator.java      20 Oct 2003 21:26:56 -0000      1.1
  +++ StringValidator.java      21 Oct 2003 15:39:47 -0000      1.2
  @@ -62,7 +62,7 @@
   
   import java.util.Iterator;
   import java.util.List;
  -import java.util.ListIterator;
  +import java.util.Set;
   
   /**
    * A Validator for a list of known string values.
  @@ -72,7 +72,7 @@
   public class StringValidator implements Validator {
   
       /** List of permitted values */
  -    private List validValues;
  +    private Set validValues;
       
       /** Stringified version of values */
       private String valuesStr;
  @@ -83,7 +83,7 @@
        * @param values
        *     the list of permitted values
        */
  -    public StringValidator(final List values) {
  +    public StringValidator(final Set values) {
           this.validValues = values;
       }
       
  @@ -113,22 +113,19 @@
       private String getValuesAsString() {
           final StringBuffer buff = new StringBuffer();
   
  -        for (final ListIterator iter = this.validValues.listIterator();
  +        buff.append("[");
  +        
  +        for (final Iterator iter = this.validValues.iterator(); 
               iter.hasNext();) {
                   
               buff.append("'").append(iter.next()).append("'");
               
               if (iter.hasNext()) {
  -                iter.next();
  -                if (!iter.hasNext()) {
  -                    buff.append(" and ");
  -                }
  -                else {
  -                    buff.append(", ");
  -                }
  -                iter.previous();
  +                buff.append(", ");
               }
           }
  +        
  +        buff.append("]");
   
           return buff.toString();
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to