commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli BaseOptionGroup.java OptionGroup.java ExclusiveOptionGroup.java InclusiveOptionGroup.java
Date Thu, 05 Jun 2003 23:28:11 GMT
jkeyes      2003/06/05 16:28:11

  Modified:    cli/src/java/org/apache/commons/cli Tag: cli_1_x
                        OptionGroup.java ExclusiveOptionGroup.java
                        InclusiveOptionGroup.java
  Added:       cli/src/java/org/apache/commons/cli Tag: cli_1_x
                        BaseOptionGroup.java
  Log:
  . more work on OptionGroup interface
. abstract base class for Exclusive and Inclusive groups
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.4   +16 -0     jakarta-commons/cli/src/java/org/apache/commons/cli/OptionGroup.java
  
  Index: OptionGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/OptionGroup.java,v
  retrieving revision 1.8.2.3
  retrieving revision 1.8.2.4
  diff -u -r1.8.2.3 -r1.8.2.4
  --- OptionGroup.java	5 Jun 2003 23:02:24 -0000	1.8.2.3
  +++ OptionGroup.java	5 Jun 2003 23:28:10 -0000	1.8.2.4
  @@ -66,6 +66,22 @@
   public interface OptionGroup {
   
       /**
  +     * Add the specified Option to this OptionGroup.
  +     * 
  +     * @param option
  +     *     the Option to add to this instance
  +     */
  +    void add(Option option);
  +
  +    /**
  +     * Add the specified OptionGroup to this OptionGroup.
  +     * 
  +     * @param group
  +     *     the OptionGroup to add to this instance
  +     */
  +    void add(OptionGroup group);
  +
  +    /**
        * Returns whether the OptionGroup contains an Option with
        * the specified name.
        * 
  
  
  
  1.1.2.3   +4 -83     jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/ExclusiveOptionGroup.java
  
  Index: ExclusiveOptionGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/ExclusiveOptionGroup.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ExclusiveOptionGroup.java	4 Jun 2003 01:11:40 -0000	1.1.2.2
  +++ ExclusiveOptionGroup.java	5 Jun 2003 23:28:10 -0000	1.1.2.3
  @@ -60,91 +60,13 @@
    */
   package org.apache.commons.cli;
   
  -import java.util.HashSet;
   import java.util.Iterator;
  -import java.util.Set;
   
   /**
    * @author John Keyes
    */
  -public class ExclusiveOptionGroup implements OptionGroup {
  +public class ExclusiveOptionGroup extends BaseOptionGroup {
   
  -    private Set options = new HashSet();
  -    
  -    private Set optionGroups = new HashSet();
  -    
  -    public void add(Option option) {
  -        this.options.add(option);
  -    }
  -    
  -    public void add(OptionGroup group) {
  -        this.optionGroups.add(group);
  -    }
  -
  -    public boolean hasOption(String name) {
  -        
  -        if (name == null) {
  -            return false;
  -        }
  -        
  -        if (!options.isEmpty()) {
  -            for (Iterator iter = options.iterator(); iter.hasNext();) {
  -                Option option = (Option)iter.next();
  -                
  -                if (name.equals( "-" + option.getName())) {
  -                    return true;   
  -                }
  -                else if (name.equals( "--" + option.getLongName())) {
  -                    return true;
  -                }
  -            }
  -        }
  -        
  -        if (!optionGroups.isEmpty()) {
  -            for (Iterator iter = optionGroups.iterator(); iter.hasNext();) {
  -                OptionGroup group = (OptionGroup)iter.next();
  -                
  -                if (group.hasOption(name)) {
  -                   return true;                 
  -                }
  -            }
  -        }
  -        
  -        return false;
  -    }
  -  
  -    public Option getOption(String name) {
  -        
  -        if (name == null) {
  -            return null;
  -        }
  -        
  -        if (!options.isEmpty()) {
  -            for (Iterator iter = options.iterator(); iter.hasNext();) {
  -                Option option = (Option)iter.next();
  -                
  -                if (name.equals("-" + option.getName())) {
  -                    return option;   
  -                }
  -                else if (name.equals("--" + option.getLongName())) {
  -                    return option;
  -                }
  -            }
  -        }
  -        
  -        if (!optionGroups.isEmpty()) {
  -            for (Iterator iter = optionGroups.iterator(); iter.hasNext();) {
  -                OptionGroup group = (OptionGroup)iter.next();
  -                
  -                if (group.hasOption(name)) {
  -                   return group.getOption(name);                 
  -                }
  -            }
  -        }
  -        
  -        return null;
  -    }
  -  
       /** @task return a descriptive message for the case
        * when the group is not valid */    
       public void isValid(CommandLine cmdLine) 
  @@ -160,7 +82,6 @@
                   if (cmdLine.hasOption("-" + option.getName())) {
                       if (optionFound) {
                           throw new AlreadySelectedException("(5)");
  -    //                    return false;
                       }
                       optionFound = true;
                   }
  
  
  
  1.1.2.3   +4 -82     jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/InclusiveOptionGroup.java
  
  Index: InclusiveOptionGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/InclusiveOptionGroup.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- InclusiveOptionGroup.java	4 Jun 2003 01:11:41 -0000	1.1.2.2
  +++ InclusiveOptionGroup.java	5 Jun 2003 23:28:10 -0000	1.1.2.3
  @@ -60,90 +60,12 @@
    */
   package org.apache.commons.cli;
   
  -import java.util.HashSet;
   import java.util.Iterator;
  -import java.util.Set;
   
   /**
    * @author John Keyes
    */
  -public class InclusiveOptionGroup implements OptionGroup {
  -
  -    private Set options = new HashSet();
  -    
  -    private Set optionGroups = new HashSet();
  -    
  -    public void add(Option option) {
  -        this.options.add(option);
  -    }
  -    
  -    public void add(OptionGroup group) {
  -        this.optionGroups.add(group);
  -    }
  -
  -    public boolean hasOption(String name) {
  -        
  -        if (name == null) {
  -            return false;
  -        }
  -        
  -        if (!options.isEmpty()) {
  -            for (Iterator iter = options.iterator(); iter.hasNext();) {
  -                Option option = (Option)iter.next();
  -                
  -                if (name.equals("-" + option.getName())) {
  -                    return true;   
  -                }
  -                else if (name.equals("--" + option.getLongName())) {
  -                    return true;
  -                }
  -            }
  -        }
  -        
  -        if (!optionGroups.isEmpty()) {
  -            for (Iterator iter = options.iterator(); iter.hasNext();) {
  -                OptionGroup group = (OptionGroup)iter.next();
  -                
  -                if (group.hasOption(name)) {
  -                   return true;                 
  -                }
  -            }
  -        }
  -        
  -        return false;
  -    }
  -
  -    public Option getOption(String name) {
  -        
  -        if (name == null) {
  -            return null;
  -        }
  -        
  -        if (!options.isEmpty()) {
  -            for (Iterator iter = options.iterator(); iter.hasNext();) {
  -                Option option = (Option)iter.next();
  -                
  -                if (name.equals("-" + option.getName())) {
  -                    return option;   
  -                }
  -                else if (name.equals("--" + option.getLongName())) {
  -                    return option;
  -                }
  -            }
  -        }
  -        
  -        if (!optionGroups.isEmpty()) {
  -            for (Iterator iter = options.iterator(); iter.hasNext();) {
  -                OptionGroup group = (OptionGroup)iter.next();
  -                
  -                if (group.hasOption(name)) {
  -                   return group.getOption(name);                 
  -                }
  -            }
  -        }
  -        
  -        return null;
  -    }
  +public class InclusiveOptionGroup extends BaseOptionGroup {
   
       /** @task return a descriptive message for the case
        * when the group is not valid */    
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +160 -0    jakarta-commons/cli/src/java/org/apache/commons/cli/Attic/BaseOptionGroup.java
  
  
  
  

---------------------------------------------------------------------
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