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/cli/src/java/org/apache/commons/cli2/impl ArgumentImpl.java
Date Wed, 25 Feb 2004 00:36:30 GMT
roxspring    2004/02/24 16:36:30

  Modified:    cli/src/java/org/apache/commons/cli2/commandline Tag:
                        RESEARCH_CLI_2_ROXSPRING DefaultingCommandLine.java
                        CommandLineImpl.java WriteableCommandLineImpl.java
               cli/src/test/org/apache/commons/cli2/impl Tag:
                        RESEARCH_CLI_2_ROXSPRING ArgumentTest.java
               cli/src/java/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING CommandLine.java
               cli/src/java/org/apache/commons/cli2/impl Tag:
                        RESEARCH_CLI_2_ROXSPRING ArgumentImpl.java
  Removed:     cli/src/test/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING
                        CommandLineDefaultsTest.java
  Log:
  CommandLine now has no notion of built in defaults
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +0 -54     jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/DefaultingCommandLine.java
  
  Index: DefaultingCommandLine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/DefaultingCommandLine.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DefaultingCommandLine.java	25 Feb 2004 00:01:14 -0000	1.1.2.2
  +++ DefaultingCommandLine.java	25 Feb 2004 00:36:30 -0000	1.1.2.3
  @@ -213,58 +213,4 @@
           }
           return Collections.unmodifiableSet(all);
       }
  -
  -    //Remaining methods to be removed
  -
  -    /*
  -     * (non-Javadoc)
  -     * 
  -     * @see org.apache.commons.cli2.CommandLine#setDefaultValues(org.apache.commons.cli2.Option,
  -     *      java.util.List)
  -     */
  -    public void setDefaultValues(Option option, List values) {
  -        // TODO Auto-generated method stub
  -
  -    }
  -
  -    /*
  -     * (non-Javadoc)
  -     * 
  -     * @see org.apache.commons.cli2.CommandLine#getDefaultCommandLine()
  -     */
  -    public CommandLine getDefaultCommandLine() {
  -        // TODO Auto-generated method stub
  -        return null;
  -    }
  -
  -    /*
  -     * (non-Javadoc)
  -     * 
  -     * @see org.apache.commons.cli2.CommandLine#setDefaultCommandLine(org.apache.commons.cli2.CommandLine)
  -     */
  -    public void setDefaultCommandLine(CommandLine newCommandLine) {
  -        // TODO Auto-generated method stub
  -
  -    }
  -
  -    /*
  -     * (non-Javadoc)
  -     * 
  -     * @see org.apache.commons.cli2.CommandLine#addDefaultCommandLine(org.apache.commons.cli2.CommandLine)
  -     */
  -    public void addDefaultCommandLine(CommandLine added) {
  -        // TODO Auto-generated method stub
  -
  -    }
  -
  -    /*
  -     * (non-Javadoc)
  -     * 
  -     * @see org.apache.commons.cli2.CommandLine#pushDefaultCommandLine(org.apache.commons.cli2.CommandLine)
  -     */
  -    public void pushDefaultCommandLine(CommandLine pushed) {
  -        // TODO Auto-generated method stub
  -
  -    }
  -
   }
  
  
  
  1.1.2.6   +1 -1      jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java
  
  Index: CommandLineImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- CommandLineImpl.java	17 Feb 2004 22:07:41 -0000	1.1.2.5
  +++ CommandLineImpl.java	25 Feb 2004 00:36:30 -0000	1.1.2.6
  @@ -73,7 +73,7 @@
           }
   
           if (values.isEmpty()) {
  -            return null;
  +            return defaultValue;
           }
   
           return values.get(0);
  
  
  
  1.1.2.4   +1 -41     jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/WriteableCommandLineImpl.java
  
  Index: WriteableCommandLineImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/WriteableCommandLineImpl.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- WriteableCommandLineImpl.java	25 Feb 2004 00:00:24 -0000	1.1.2.3
  +++ WriteableCommandLineImpl.java	25 Feb 2004 00:36:30 -0000	1.1.2.4
  @@ -57,6 +57,7 @@
       }
   
       public void addValue(final Option option, final Object value) {
  +    	System.out.println("addValue("+option+","+value+")");
           if (option instanceof Argument) {
               addOption(option);
           }
  @@ -204,46 +205,5 @@
   
       public Set getOptionTriggers() {
           return Collections.unmodifiableSet(nameToOption.keySet());
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.commons.cli2.CommandLine#setDefaultValues(org.apache.commons.cli2.Option,
java.util.List)
  -     */
  -    public void setDefaultValues(final Option option, final List values) {
  -        this.defaults.put(option, values);
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.commons.cli2.CommandLine#getDefaultCommandLine()
  -     */
  -    public CommandLine getDefaultCommandLine() {
  -        return defaultCommandLine;
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.commons.cli2.CommandLine#setDefaultCommandLine(org.apache.commons.cli2.CommandLine)
  -     */
  -    public void setDefaultCommandLine(final CommandLine newCommandLine) {
  -        this.defaultCommandLine = newCommandLine;
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.commons.cli2.CommandLine#addDefaultCommandLine(org.apache.commons.cli2.CommandLine)
  -     */
  -    public void addDefaultCommandLine(final CommandLine added) {
  -        if (defaultCommandLine == null) {
  -            defaultCommandLine = added;
  -        }
  -        else {
  -            defaultCommandLine.addDefaultCommandLine(added);
  -        }
  -    }
  -
  -    /* (non-Javadoc)
  -     * @see org.apache.commons.cli2.CommandLine#pushDefaultCommandLine(org.apache.commons.cli2.CommandLine)
  -     */
  -    public void pushDefaultCommandLine(final CommandLine pushed) {
  -        pushed.addDefaultCommandLine(defaultCommandLine);
  -        defaultCommandLine = pushed;
       }
   }
  
  
  
  No                   revision
  No                   revision
  1.1.2.8   +31 -26    jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java
  
  Index: ArgumentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/impl/Attic/ArgumentTest.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- ArgumentTest.java	24 Feb 2004 02:01:40 -0000	1.1.2.7
  +++ ArgumentTest.java	25 Feb 2004 00:36:30 -0000	1.1.2.8
  @@ -107,6 +107,11 @@
               null,
               0);
       }
  +    
  +    public void setUp(){
  +    	System.out.println("==========================");
  +    	System.out.println(getName());
  +    }
   
       public void testNew() {
           try {
  @@ -492,34 +497,34 @@
           assertFalse(iterator.hasNext());
       }
   
  -    public void testProcess_DefinedDefaultValue() throws OptionException {
  -        final Option size = buildSizeArgument();
  -        final List args = list("-size");
  -        final WriteableCommandLine commandLine = commandLine(size, args);
  -        final ListIterator iterator = args.listIterator();
  -
  -        size.process(commandLine, iterator);
  -
  -        assertEquals("10", commandLine.getValue(size));
  -    }
  -
  -    public void testProcess_DefinedDefaultValues() throws OptionException {
  -        final Option bounds = buildBoundsArgument();
  -        final List args = list("-bounds");
  -        final WriteableCommandLine commandLine = commandLine(bounds, args);
  -        final ListIterator iterator = args.listIterator();
  -
  -        bounds.process(commandLine, iterator);
  -
  -        List values = new ArrayList();
  -        values.add("5");
  -        values.add("10");
  -        assertEquals(values, commandLine.getValues(bounds));
  -    }
  +//    public void testProcess_DefinedDefaultValue() throws OptionException {
  +//        final Option size = buildSizeArgument();
  +//        final List args = list();
  +//        final WriteableCommandLine commandLine = commandLine(size, args);
  +//        final ListIterator iterator = args.listIterator();
  +//
  +//        size.process(commandLine, iterator);
  +//
  +//        assertEquals("10", commandLine.getValue(size));
  +//    }
  +//
  +//    public void testProcess_DefinedDefaultValues() throws OptionException {
  +//        final Option bounds = buildBoundsArgument();
  +//        final List args = list();
  +//        final WriteableCommandLine commandLine = commandLine(bounds, args);
  +//        final ListIterator iterator = args.listIterator();
  +//
  +//        bounds.process(commandLine, iterator);
  +//
  +//        List values = new ArrayList();
  +//        values.add("5");
  +//        values.add("10");
  +//        assertEquals(values, commandLine.getValues(bounds));
  +//    }
   
       public void testProcess_InterrogatedDefaultValue() throws OptionException {
           final Option size = buildSizeArgument();
  -        final List args = list("-size");
  +        final List args = list();
           final WriteableCommandLine commandLine = commandLine(size, args);
           final ListIterator iterator = args.listIterator();
   
  @@ -533,7 +538,7 @@
       public void testProcess_InterrogatedDefaultValues()
           throws OptionException {
           final Option bounds = buildBoundsArgument();
  -        final List args = list("-bounds");
  +        final List args = list();
           final WriteableCommandLine commandLine = commandLine(bounds, args);
           final ListIterator iterator = args.listIterator();
   
  
  
  
  No                   revision
  No                   revision
  1.1.2.9   +0 -5      jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/CommandLine.java
  
  Index: CommandLine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/CommandLine.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- CommandLine.java	17 Feb 2004 21:36:39 -0000	1.1.2.8
  +++ CommandLine.java	25 Feb 2004 00:36:30 -0000	1.1.2.9
  @@ -45,11 +45,6 @@
       Set getProperties();
       int getOptionCount(final String trigger);
       int getOptionCount(final Option option);
  -    void setDefaultValues(final Option option, final List values);
       List getOptions();
       Set getOptionTriggers();
  -    CommandLine getDefaultCommandLine();
  -    void setDefaultCommandLine(final CommandLine newCommandLine);
  -    void addDefaultCommandLine(final CommandLine added);
  -    void pushDefaultCommandLine(final CommandLine pushed);
   }
  
  
  
  No                   revision
  No                   revision
  1.1.2.8   +8 -4      jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java
  
  Index: ArgumentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/impl/Attic/ArgumentImpl.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- ArgumentImpl.java	24 Feb 2004 02:01:40 -0000	1.1.2.7
  +++ ArgumentImpl.java	25 Feb 2004 00:36:30 -0000	1.1.2.8
  @@ -165,17 +165,21 @@
   
               final String allValues =
                   stripBoundaryQuotes((String)arguments.next());
  -
  +            
  +            // should we ignore things that look like options?
               if (allValues.equals(consumeRemaining)) {
                   while (arguments.hasNext() && argumentCount < maximum) {
                       ++argumentCount;
  +                    System.out.println("location 1");
                       commandLine.addValue(option, arguments.next());
                   }
               }
  +            // does it look like an option?
               else if (commandLine.looksLikeOption(allValues)) {
                   arguments.previous();
                   break;
               }
  +            // should we split the string up?
               else if (subsequentSplit) {
                   final StringTokenizer values =
                       new StringTokenizer(
  @@ -187,6 +191,7 @@
                   while (values.hasMoreTokens() && argumentCount < maximum) {
                       ++argumentCount;
                       final String token = values.nextToken();
  +                    System.out.println("location 2");
                       commandLine.addValue(option, token);
                       arguments.add(token);
                   }
  @@ -198,8 +203,10 @@
                           values.nextToken());
                   }
               }
  +            // it must be a value as it is
               else {
                   ++argumentCount;
  +                System.out.println("location 3");
                   commandLine.addValue(option, allValues);
               }
           }
  @@ -236,9 +243,6 @@
        */
       public void process(WriteableCommandLine commandLine, ListIterator args)
           throws OptionException {
  -        if (this.defaultValues != null) {
  -            commandLine.setDefaultValues(this, this.defaultValues);
  -        }
           processValues(commandLine, args, this);
       }
   
  
  
  

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