You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jk...@apache.org on 2002/09/09 21:46:26 UTC

cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli Options.java

jkeyes      2002/09/09 12:46:26

  Modified:    cli/src/java/org/apache/commons/cli Options.java
  Log:
  added Pete Maddocks patch for having options created only with a longOpt returned from getOptions
  
  Revision  Changes    Path
  1.12      +15 -1     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Options.java	1 Sep 2002 22:54:56 -0000	1.11
  +++ Options.java	9 Sep 2002 19:46:26 -0000	1.12
  @@ -68,6 +68,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.*;
   
   /** <p>Main entry-point into the library.</p>
    *
  @@ -178,7 +179,20 @@
        * @return read-only Collection of {@link Option} objects in this descriptor
        */
       public Collection getOptions() {
  -        return Collections.unmodifiableCollection( shortOpts.values() );
  +        List opts = new ArrayList( shortOpts.values() );
  +
  +        // now look through the long opts to see if there are any Long-opt
  +        // only options
  +        Iterator iter = longOpts.values().iterator();
  +        while (iter.hasNext())
  +        {
  +            Object item = iter.next();
  +            if (!opts.contains(item))
  +            {
  +                opts.add(item);
  +            }
  +        }
  +        return Collections.unmodifiableCollection( opts );
       }
   
       /** <p>Returns the required options as a 
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>