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 Options.java
Date Tue, 09 Jul 2002 22:07:27 GMT
jkeyes      2002/07/09 15:07:27

  Modified:    cli/src/java/org/apache/commons/cli Options.java
  Log:
  removed use of options list, reduced concatenation
  
  Revision  Changes    Path
  1.7       +7 -12     jakarta-commons/cli/src/java/org/apache/commons/cli/Options.java
  
  Index: Options.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/Options.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Options.java	8 Jul 2002 20:22:00 -0000	1.6
  +++ Options.java	9 Jul 2002 22:07:27 -0000	1.7
  @@ -64,8 +64,6 @@
   import java.util.Collection;
   import java.util.Map;
   import java.util.HashMap;
  -import java.util.List;
  -import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.Collections;
   
  @@ -86,9 +84,6 @@
    */
   public class Options {
   
  -    /** the list of options */
  -    private List options      = new ArrayList();
  -
       /** a map of the options with the character key */
       private Map  shortOpts    = new HashMap();
   
  @@ -206,9 +201,10 @@
        * <p>Adds an option instance</p>
        *
        * @param opt the option that is to be added 
  +     * @return the resulting Options instance
        */
       public Options addOption(Option opt)  {
  -        String shortOptStr = "-" + opt.getOpt();
  +        String shortOpt = "-" + opt.getOpt();
           
           // add it to the long option list
           if ( opt.hasLongOpt() ) {
  @@ -217,21 +213,20 @@
           
           // if the option is required add it to the required list
           if ( opt.isRequired() ) {
  -            requiredOpts.put( "-" + opt.getOpt(), opt );
  +            requiredOpts.put( shortOpt, opt );
           }
   
  -        shortOpts.put( "-" + opt.getOpt(), opt );
  +        shortOpts.put( shortOpt, opt );
           
  -        options.add( opt );
           return this;
       }
       
       /** <p>Retrieve a read-only list of options in this set</p>
        *
  -     * @return read-only List of {@link Option} objects in this descriptor
  +     * @return read-only Collection of {@link Option} objects in this descriptor
        */
  -    public List getOptions() {
  -        return Collections.unmodifiableList(options);
  +    public Collection getOptions() {
  +        return Collections.unmodifiableCollection( shortOpts.values() );
       }
   
       /** <p>Returns the required options as a 
  
  
  

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


Mime
View raw message