commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 26041] New: - [Patch][CLI] OptionBuilder implemented like ToStringBuilder from commons-lang
Date Sun, 11 Jan 2004 03:07:58 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26041>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26041

[Patch][CLI] OptionBuilder implemented like ToStringBuilder from commons-lang

           Summary: [Patch][CLI] OptionBuilder implemented like
                    ToStringBuilder from commons-lang
           Product: Commons
           Version: 1.0 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: CLI
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: ludovic_claude@hotmail.com


OptionBuilder uses only static methods instead of a very common java-idiom, the
chain of calls, that is used in many jakarta projects (see ECS or commons-lang
with the implementations of ToStringBuilder, HashCodeBuilder...)

This patch fixes OptionBuilder but as it breaks the current API, it might be
best applied on a 2.0 release.

Ludovic.

Index: src/java/org/apache/commons/cli/OptionBuilder.java
===================================================================
retrieving revision 1.16
diff -u -r1.16 OptionBuilder.java
--- src/java/org/apache/commons/cli/OptionBuilder.java	9 Oct 2003 20:57:01
-0000	1.16
+++ src/java/org/apache/commons/cli/OptionBuilder.java	11 Jan 2004 02:32:24 -0000
@@ -73,55 +73,34 @@
 public class OptionBuilder {
 
     /** long option */
-    private static String longopt;
+    private String longopt;
 
     /** option description */
-    private static String description;
+    private String description;
 
     /** argument name */
-    private static String argName;
+    private String argName;
 
     /** is required? */
-    private static boolean required;
+    private boolean required;
 
     /** the number of arguments */
-    private static int numberOfArgs = Option.UNINITIALIZED;
+    private int numberOfArgs = Option.UNINITIALIZED;
 
     /** option type */
-    private static Object type;
+    private Object type;
 
     /** option can have an optional argument value */
-    private static boolean optionalArg;
+    private boolean optionalArg;
 
     /** value separator for argument value */
-    private static char valuesep;
-
-    /** option builder instance */
-    private static OptionBuilder instance = new OptionBuilder();
-
-    /**
-     * private constructor to prevent instances being created
-     */
-    private OptionBuilder()
-    {
-    }
+    private char valuesep;
 
     /**
-     * <p>Resets the member variables to their default values.</p>
+     * Constructor for OptionBuilder
      */
-    private static void reset()
+    public OptionBuilder()
     {
-        description = null;
-        argName = "arg";
-        longopt = null;
-        type = null;
-        required = false;
-        numberOfArgs = Option.UNINITIALIZED;
-
-
-        // PMM 9/6/02 - these were missing
-        optionalArg = false;
-        valuesep = (char) 0;
     }
 
     /**
@@ -130,11 +109,11 @@
      * @param longopt the long option value
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder withLongOpt(String longopt)
+    public OptionBuilder withLongOpt(String longopt)
     {
-        instance.longopt = longopt;
+        this.longopt = longopt;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -142,11 +121,11 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasArg()
+    public OptionBuilder hasArg()
     {
-        instance.numberOfArgs = 1;
+        this.numberOfArgs = 1;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -156,11 +135,11 @@
      * @param hasArg if true then the Option has an argument value
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasArg(boolean hasArg)
+    public OptionBuilder hasArg(boolean hasArg)
     {
-        instance.numberOfArgs = (hasArg == true) ? 1 : Option.UNINITIALIZED;
+        this.numberOfArgs = (hasArg == true) ? 1 : Option.UNINITIALIZED;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -170,11 +149,11 @@
      * @param name the name for the argument value
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder withArgName(String name)
+    public OptionBuilder withArgName(String name)
     {
-        instance.argName = name;
+        this.argName = name;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -182,11 +161,11 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder isRequired()
+    public OptionBuilder isRequired()
     {
-        instance.required = true;
+        this.required = true;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -207,11 +186,11 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder withValueSeparator(char sep)
+    public OptionBuilder withValueSeparator(char sep)
     {
-        instance.valuesep = sep;
+        this.valuesep = sep;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -230,11 +209,11 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder withValueSeparator()
+    public OptionBuilder withValueSeparator()
     {
-        instance.valuesep = '=';
+        this.valuesep = '=';
 
-        return instance;
+        return this;
     }
 
     /**
@@ -244,11 +223,11 @@
      * @param required if true then the Option is required
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder isRequired(boolean required)
+    public OptionBuilder isRequired(boolean required)
     {
-        instance.required = required;
+        this.required = required;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -256,11 +235,11 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasArgs()
+    public OptionBuilder hasArgs()
     {
-        instance.numberOfArgs = Option.UNLIMITED_VALUES;
+        this.numberOfArgs = Option.UNLIMITED_VALUES;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -270,11 +249,11 @@
      * @param num the number of args that the option can have
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasArgs(int num)
+    public OptionBuilder hasArgs(int num)
     {
-        instance.numberOfArgs = num;
+        this.numberOfArgs = num;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -282,12 +261,12 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasOptionalArg()
+    public OptionBuilder hasOptionalArg()
     {
-        instance.numberOfArgs = 1;
-        instance.optionalArg = true;
+        this.numberOfArgs = 1;
+        this.optionalArg = true;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -296,12 +275,12 @@
      *
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasOptionalArgs()
+    public OptionBuilder hasOptionalArgs()
     {
-        instance.numberOfArgs = Option.UNLIMITED_VALUES;
-        instance.optionalArg = true;
+        this.numberOfArgs = Option.UNLIMITED_VALUES;
+        this.optionalArg = true;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -312,12 +291,12 @@
      * the next Option created can have.
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder hasOptionalArgs(int numArgs)
+    public OptionBuilder hasOptionalArgs(int numArgs)
     {
-        instance.numberOfArgs = numArgs;
-        instance.optionalArg = true;
+        this.numberOfArgs = numArgs;
+        this.optionalArg = true;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -327,11 +306,11 @@
      * @param type the type of the Options argument value
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder withType(Object type)
+    public OptionBuilder withType(Object type)
     {
-        instance.type = type;
+        this.type = type;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -340,11 +319,11 @@
      * @param description a description of the Option's purpose
      * @return the OptionBuilder instance
      */
-    public static OptionBuilder withDescription(String description)
+    public OptionBuilder withDescription(String description)
     {
-        instance.description = description;
+        this.description = description;
 
-        return instance;
+        return this;
     }
 
     /**
@@ -356,7 +335,7 @@
      * @throws IllegalArgumentException if <code>opt</code> is not
      * a valid character.  See Option.
      */
-    public static Option create(char opt)
+    public Option create(char opt)
                          throws IllegalArgumentException
     {
         return create(String.valueOf(opt));
@@ -369,7 +348,7 @@
      * @throws IllegalArgumentException if <code>longOpt</code> has
      * not been set.  
      */
-    public static Option create()
+    public Option create()
                          throws IllegalArgumentException
     {
         if (longopt == null)
@@ -390,7 +369,7 @@
      * @throws IllegalArgumentException if <code>opt</code> is not
      * a valid character.  See Option.
      */
-    public static Option create(String opt)
+    public Option create(String opt)
                          throws IllegalArgumentException
     {
         // create the option
@@ -405,10 +384,6 @@
         option.setType(type);
         option.setValueSeparator(valuesep);
         option.setArgName(argName);
-
-
-        // reset the OptionBuilder properties
-        instance.reset();
 
         // return the Option instance
         return option;
Index: src/java/org/apache/commons/cli/PatternOptionBuilder.java
===================================================================
retrieving revision 1.6
diff -u -r1.6 PatternOptionBuilder.java
--- src/java/org/apache/commons/cli/PatternOptionBuilder.java	9 Oct 2003
20:57:02 -0000	1.6
+++ src/java/org/apache/commons/cli/PatternOptionBuilder.java	11 Jan 2004
02:32:25 -0000
@@ -200,7 +200,7 @@
                 {
                     // we have a previous one to deal with
                     options.addOption(
-                            OptionBuilder.hasArg(type != null)
+                            new OptionBuilder().hasArg(type != null)
                                          .isRequired(required).withType(type)
                                          .create(opt));
                     required = false;
@@ -224,7 +224,7 @@
         {
             // we have a final one to deal with
             options.addOption(
-                    OptionBuilder.hasArg(type != null).isRequired(required)
+                    new OptionBuilder().hasArg(type != null).isRequired(required)
                                  .withType(type).create(opt));
         }
 
Index: src/test/org/apache/commons/cli/ApplicationTest.java
===================================================================
retrieving revision 1.9
diff -u -r1.9 ApplicationTest.java
--- src/test/org/apache/commons/cli/ApplicationTest.java	19 Sep 2002 22:59:44
-0000	1.9
+++ src/test/org/apache/commons/cli/ApplicationTest.java	11 Jan 2004 02:32:30 -0000
@@ -40,7 +40,7 @@
         options.addOption( "a", "all", false, "do not hide entries starting
with ." );
         options.addOption( "A", "almost-all", false, "do not list implied . and
.." );
         options.addOption( "b", "escape", false, "print octal escapes for
nongraphic characters" );
-        options.addOption( OptionBuilder.withLongOpt( "block-size" )
+        options.addOption( new OptionBuilder().withLongOpt( "block-size" )
                                         .withDescription( "use SIZE-byte blocks" )
                                         .withValueSeparator( '=' )
                                         .hasArg()
@@ -79,7 +79,7 @@
         options.addOption( "logger", true, "the class which is to perform the
logging" );
         options.addOption( "listener", true, "add an instance of a class as a
project listener" );
         options.addOption( "buildfile", true, "use given buildfile" );
-        options.addOption( OptionBuilder.withDescription( "use value for given
property" )
+        options.addOption( new OptionBuilder().withDescription( "use value for
given property" )
                                         .hasArgs()
                                         .withValueSeparator()
                                         .create( 'D' ) );
Index: src/test/org/apache/commons/cli/BugsTest.java
===================================================================
retrieving revision 1.16
diff -u -r1.16 BugsTest.java
--- src/test/org/apache/commons/cli/BugsTest.java	17 Jan 2003 20:00:14 -0000	1.16
+++ src/test/org/apache/commons/cli/BugsTest.java	11 Jan 2004 02:32:30 -0000
@@ -39,7 +39,7 @@
 
     public void test11457() {
         Options options = new Options();
-        options.addOption( OptionBuilder.withLongOpt( "verbose" )
+        options.addOption( new OptionBuilder().withLongOpt( "verbose" )
                            .create() );
         String[] args = new String[] { "--verbose" };
 
@@ -58,10 +58,10 @@
     public void test11458()
     {
         Options options = new Options();
-        options.addOption( OptionBuilder.withValueSeparator( '=' )
+        options.addOption( new OptionBuilder().withValueSeparator( '=' )
                            .hasArgs()
                            .create( 'D' ) );
-        options.addOption( OptionBuilder.withValueSeparator( ':' )
+        options.addOption( new OptionBuilder().withValueSeparator( ':' )
                            .hasArgs()
                            .create( 'p' ) );
         String[] args = new String[] { "-DJAVA_HOME=/opt/java" ,
@@ -136,9 +136,9 @@
     {
         // Posix 
         Options options = new Options();
-        options.addOption( OptionBuilder.hasOptionalArg()
+        options.addOption( new OptionBuilder().hasOptionalArg()
                            .create( 'a' ) );
-        options.addOption( OptionBuilder.hasArg()
+        options.addOption( new OptionBuilder().hasArg()
                            .create( 'b' ) );
         String[] args = new String[] { "-a", "-bvalue" };
 
@@ -154,9 +154,9 @@
 
         // GNU
         options = new Options();
-        options.addOption( OptionBuilder.hasOptionalArg()
+        options.addOption( new OptionBuilder().hasOptionalArg()
                            .create( 'a' ) );
-        options.addOption( OptionBuilder.hasArg()
+        options.addOption( new OptionBuilder().hasArg()
                            .create( 'b' ) );
         args = new String[] { "-a", "-b", "value" };
 
@@ -232,11 +232,11 @@
 
     public void test13425() {
         Options options = new Options();
-        Option oldpass = OptionBuilder.withLongOpt( "old-password" )
+        Option oldpass = new OptionBuilder().withLongOpt( "old-password" )
             .withDescription( "Use this option to specify the old password" )
             .hasArg()
             .create( 'o' );
-        Option newpass = OptionBuilder.withLongOpt( "new-password" )
+        Option newpass = new OptionBuilder().withLongOpt( "new-password" )
             .withDescription( "Use this option to specify the new password" )
             .hasArg()
             .create( 'n' );
@@ -265,7 +265,7 @@
 
     public void test13666() {
         Options options = new Options();
-        Option dir = OptionBuilder.withDescription( "dir" )
+        Option dir = new OptionBuilder().withDescription( "dir" )
                                        .hasArg()
                                        .create( 'd' );
         options.addOption( dir );
@@ -345,7 +345,7 @@
     }
 
     public void test14786() throws Exception {
-        Option o =
OptionBuilder.isRequired().withDescription("test").create("test");
+        Option o = new
OptionBuilder().isRequired().withDescription("test").create("test");
         Options opts = new Options();
         opts.addOption(o);
         opts.addOption(o);
@@ -377,7 +377,7 @@
     public void test15648() throws Exception {
         CommandLineParser parser = new PosixParser();
         final String[] args = new String[] { "-m", "\"Two Words\"" };
-        Option m = OptionBuilder.hasArgs().create("m");
+        Option m = new OptionBuilder().hasArgs().create("m");
         Options options = new Options();
         options.addOption( m );
         CommandLine line = parser.parse( options, args );
Index: src/test/org/apache/commons/cli/OptionBuilderTest.java
===================================================================
retrieving revision 1.3
diff -u -r1.3 OptionBuilderTest.java
--- src/test/org/apache/commons/cli/OptionBuilderTest.java	18 Nov 2002
08:41:26 -0000	1.3
+++ src/test/org/apache/commons/cli/OptionBuilderTest.java	11 Jan 2004 02:32:34
-0000
@@ -21,7 +21,7 @@
     }
 
     public void testCompleteOption( ) {
-        Option simple = OptionBuilder.withLongOpt( "simple option")
+        Option simple = new OptionBuilder().withLongOpt( "simple option")
                                      .hasArg( )
                                      .isRequired( )
                                      .hasArgs( )
@@ -39,7 +39,7 @@
     }
 
     public void testTwoCompleteOptions( ) {
-        Option simple = OptionBuilder.withLongOpt( "simple option")
+        Option simple = new OptionBuilder().withLongOpt( "simple option")
                                      .hasArg( )
                                      .isRequired( )
                                      .hasArgs( )
@@ -55,7 +55,7 @@
         assertTrue( simple.isRequired() );
         assertTrue( simple.hasArgs() );
 
-        simple = OptionBuilder.withLongOpt( "dimple option")
+        simple = new OptionBuilder().withLongOpt( "dimple option")
                               .hasArg( )
                               .withDescription( "this is a dimple option" )
                               .create( 'd' );
@@ -70,7 +70,7 @@
     }
 
     public void testBaseOptionCharOpt() {
-        Option base = OptionBuilder.withDescription( "option description")
+        Option base = new OptionBuilder().withDescription( "option description")
                                    .create( 'o' );
 
         assertEquals( "o", base.getOpt() );
@@ -79,7 +79,7 @@
     }
 
     public void testBaseOptionStringOpt() {
-        Option base = OptionBuilder.withDescription( "option description")
+        Option base = new OptionBuilder().withDescription( "option description")
                                    .create( "o" );
 
         assertEquals( "o", base.getOpt() );
@@ -91,7 +91,7 @@
 
         // '?'
         try {
-            Option opt = OptionBuilder.withDescription( "help options" )
+            Option opt = new OptionBuilder().withDescription( "help options" )
                                       .create( '?' );
             assertEquals( "?", opt.getOpt() );
         }
@@ -101,7 +101,7 @@
 
         // '@'
         try {
-            Option opt = OptionBuilder.withDescription( "read from stdin" )
+            Option opt = new OptionBuilder().withDescription( "read from stdin" )
                                       .create( '@' );
             assertEquals( "@", opt.getOpt() );
         }
@@ -111,7 +111,7 @@
     }
 
     public void testOptionArgNumbers() {
-        Option opt = OptionBuilder.withDescription( "option description" )
+        Option opt = new OptionBuilder().withDescription( "option description" )
                                   .hasArgs( 2 )
                                   .create( 'o' );
         assertEquals( 2, opt.getArgs() );
@@ -120,7 +120,7 @@
     public void testIllegalOptions() {
         // bad single character option
         try {
-            Option opt = OptionBuilder.withDescription( "option description" )
+            Option opt = new OptionBuilder().withDescription( "option
description" )
                                       .create( '"' );
             fail( "IllegalArgumentException not caught" );
         }
@@ -130,7 +130,7 @@
 
         // bad character in option string
         try {
-            Option opt = OptionBuilder.create( "opt`" );
+            Option opt = new OptionBuilder().create( "opt`" );
             fail( "IllegalArgumentException not caught" );
         }
         catch( IllegalArgumentException exp ) {
@@ -139,7 +139,7 @@
 
         // valid option 
         try {
-            Option opt = OptionBuilder.create( "opt" );
+            Option opt = new OptionBuilder().create( "opt" );
             // success
         }
         catch( IllegalArgumentException exp ) {
Index: src/test/org/apache/commons/cli/OptionsTest.java
===================================================================
retrieving revision 1.2
diff -u -r1.2 OptionsTest.java
--- src/test/org/apache/commons/cli/OptionsTest.java	9 Oct 2003 20:57:20 -0000	1.2
+++ src/test/org/apache/commons/cli/OptionsTest.java	11 Jan 2004 02:32:35 -0000
@@ -94,25 +94,25 @@
     
     public void testHelpOptions(){
         
-        Option longOnly1 = OptionBuilder
+        Option longOnly1 = new OptionBuilder()
             .withLongOpt("long-only1")
             .create();
         
-        Option longOnly2 = OptionBuilder
+        Option longOnly2 = new OptionBuilder()
             .withLongOpt("long-only2")
             .create();
                 
-        Option shortOnly1 = OptionBuilder
+        Option shortOnly1 = new OptionBuilder()
             .create("1");
                 
-        Option shortOnly2 = OptionBuilder
+        Option shortOnly2 = new OptionBuilder()
             .create("2");
                 
-        Option bothA = OptionBuilder
+        Option bothA = new OptionBuilder()
             .withLongOpt("bothA")
             .create("a");
                 
-        Option bothB = OptionBuilder
+        Option bothB = new OptionBuilder()
             .withLongOpt("bothB")
             .create("b");
         
Index: src/test/org/apache/commons/cli/ParseRequiredTest.java
===================================================================
retrieving revision 1.5
diff -u -r1.5 ParseRequiredTest.java
--- src/test/org/apache/commons/cli/ParseRequiredTest.java	19 Sep 2002
22:59:44 -0000	1.5
+++ src/test/org/apache/commons/cli/ParseRequiredTest.java	11 Jan 2004 02:32:36
-0000
@@ -40,7 +40,7 @@
                        "enable-a",
                        false,
                        "turn [a] on or off")
-            .addOption( OptionBuilder.withLongOpt( "bfile" )
+            .addOption( new OptionBuilder().withLongOpt( "bfile" )
                                      .hasArg()
                                      .isRequired()
                                      .withDescription( "set the value of [b]" )
Index: src/test/org/apache/commons/cli/PatternOptionBuilderTest.java
===================================================================
retrieving revision 1.6
diff -u -r1.6 PatternOptionBuilderTest.java
--- src/test/org/apache/commons/cli/PatternOptionBuilderTest.java	19 Sep 2002
22:59:44 -0000	1.6
+++ src/test/org/apache/commons/cli/PatternOptionBuilderTest.java	11 Jan 2004
02:32:40 -0000
@@ -12,9 +12,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import java.io.StringWriter;
-import java.io.PrintWriter;
-
 /** 
  * Test case for the PatternOptionBuilder class 
  *
Index: src/test/org/apache/commons/cli/TestHelpFormatter.java
===================================================================
retrieving revision 1.6
diff -u -r1.6 TestHelpFormatter.java
--- src/test/org/apache/commons/cli/TestHelpFormatter.java	9 Dec 2002 23:47:26
-0000	1.6
+++ src/test/org/apache/commons/cli/TestHelpFormatter.java	11 Jan 2004 02:32:41
-0000
@@ -14,7 +14,6 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
-import java.io.StringWriter;
 
 /** 
  * Test case for the HelpFormatter class 
Index: src/test/org/apache/commons/cli/ValueTest.java
===================================================================
retrieving revision 1.7
diff -u -r1.7 ValueTest.java
--- src/test/org/apache/commons/cli/ValueTest.java	27 Nov 2002 23:24:38 -0000	1.7
+++ src/test/org/apache/commons/cli/ValueTest.java	11 Jan 2004 02:32:45 -0000
@@ -53,28 +53,28 @@
                        true,
                        "set -d");
 
-        opts.addOption( OptionBuilder.hasOptionalArg()
+        opts.addOption( new OptionBuilder().hasOptionalArg()
                         .create( 'e') );
 
-        opts.addOption( OptionBuilder.hasOptionalArg()
+        opts.addOption( new OptionBuilder().hasOptionalArg()
                         .withLongOpt( "fish" )
                         .create( ) );
 
-        opts.addOption( OptionBuilder.hasOptionalArgs()
+        opts.addOption( new OptionBuilder().hasOptionalArgs()
                         .withLongOpt( "gravy" )
                         .create( ) );
 
-        opts.addOption( OptionBuilder.hasOptionalArgs( 2 )
+        opts.addOption( new OptionBuilder().hasOptionalArgs( 2 )
                         .withLongOpt( "hide" )
                         .create( ) );
 
-        opts.addOption( OptionBuilder.hasOptionalArgs( 2 )
+        opts.addOption( new OptionBuilder().hasOptionalArgs( 2 )
                         .create( 'i' ) );
 
-        opts.addOption( OptionBuilder.hasOptionalArgs( )
+        opts.addOption( new OptionBuilder().hasOptionalArgs( )
                         .create( 'j' ) );
 
-        opts.addOption( OptionBuilder.hasArgs( ).withValueSeparator( ',' )
+        opts.addOption( new OptionBuilder().hasArgs( ).withValueSeparator( ',' )
                         .create( 'k' ) );
 
         String[] args = new String[] { "-a",
Index: src/test/org/apache/commons/cli/ValuesTest.java
===================================================================
retrieving revision 1.9
diff -u -r1.9 ValuesTest.java
--- src/test/org/apache/commons/cli/ValuesTest.java	25 Nov 2002 23:43:41 -0000	1.9
+++ src/test/org/apache/commons/cli/ValuesTest.java	11 Jan 2004 02:32:47 -0000
@@ -53,7 +53,7 @@
                        true,
                        "set -d");
         
-        opts.addOption( OptionBuilder.withLongOpt( "e" )
+        opts.addOption( new OptionBuilder().withLongOpt( "e" )
                                      .hasArgs()
                                      .withDescription( "set -e ")
                                      .create( 'e' ) );
@@ -63,33 +63,33 @@
                        false,
                        "jk");
         
-        opts.addOption( OptionBuilder.withLongOpt( "g" )
+        opts.addOption( new OptionBuilder().withLongOpt( "g" )
                         .hasArgs( 2 )
                         .withDescription( "set -g")
                         .create( 'g' ) );
 
-        opts.addOption( OptionBuilder.withLongOpt( "h" )
+        opts.addOption( new OptionBuilder().withLongOpt( "h" )
                         .hasArgs( 2 )
                         .withDescription( "set -h")
                         .create( 'h' ) );
 
-        opts.addOption( OptionBuilder.withLongOpt( "i" )
+        opts.addOption( new OptionBuilder().withLongOpt( "i" )
                         .withDescription( "set -i")
                         .create( 'i' ) );
 
-        opts.addOption( OptionBuilder.withLongOpt( "j" )
+        opts.addOption( new OptionBuilder().withLongOpt( "j" )
                         .hasArgs( )
                         .withDescription( "set -j")
                         .withValueSeparator( '=' )
                         .create( 'j' ) );
 
-        opts.addOption( OptionBuilder.withLongOpt( "k" )
+        opts.addOption( new OptionBuilder().withLongOpt( "k" )
                         .hasArgs( )
                         .withDescription( "set -k")
                         .withValueSeparator( '=' )
                         .create( 'k' ) );
 
-        _option = OptionBuilder.withLongOpt( "m" )
+        _option = new OptionBuilder().withLongOpt( "m" )
                         .hasArgs( )
                         .withDescription( "set -m")
                         .withValueSeparator( )
Index: xdocs/usage.xml
===================================================================
retrieving revision 1.4
diff -u -r1.4 usage.xml
--- xdocs/usage.xml	13 Nov 2002 00:04:13 -0000	1.4
+++ xdocs/usage.xml	11 Jan 2004 02:32:53 -0000
@@ -146,29 +146,29 @@
         <p> 
           The argument options are created using the OptionBuilder.
         </p>
-        <source>Option logfile   = OptionBuilder.withArgName( "file" )
+        <source>Option logfile   = new OptionBuilder().withArgName( "file" )
                                 .hasArg()
                                 .withDescription(  "use given file for log" )
                                 .create( "file" );
 
-Option logger    = OptionBuilder.withArgName( "classname" )
+Option logger    = new OptionBuilder().withArgName( "classname" )
                                 .hasArg()
                                 .withDescription( "the class which it to perform "
                                                   + "logging" )
                                 .create( "logger" );
 
-Option listener  = OptionBuilder.withArgName( "classname" )
+Option listener  = new OptionBuilder().withArgName( "classname" )
                                 .hasArg()
                                 .withDescription( "add an instance of class as "
                                                   + "a project listener" )
                                 .create( "listener"); 
 
-Option buildfile = OptionBuilder.withArgName( "file" )
+Option buildfile = new OptionBuilder().withArgName( "file" )
                                 .hasArg()
                                 .withDescription(  "use given buildfile" )
                                 .create( "buildfile");
 
-Option find      = OptionBuilder.withArgName( "file" )
+Option find      = new OptionBuilder().withArgName( "file" )
                                 .hasArg()
                                 .withDescription( "search for buildfile towards
the "
                                   + "root of the filesystem and use it" )
@@ -179,7 +179,7 @@
           The last option to create is the Java property and it too is created
           using the OptionBuilder.
         </p>
-        <source>Option property  = OptionBuilder.withArgName( "property=value" )
+        <source>Option property  = new OptionBuilder().withArgName(
"property=value" )
                                 .hasArg()
                                 .withValueSeparator()
                                 .withDescription( "use value for given property" )
@@ -318,7 +318,7 @@
 options.addOption( "A", "almost-all", false, "do not list implied . and .." );
 options.addOption( "b", "escape", false, "print octal escapes for nongraphic "
                                          + "characters" );
-options.addOption( OptionBuilder.withLongOpt( "block-size" )
+options.addOption( new OptionBuilder().withLongOpt( "block-size" )
                                 .withDescription( "use SIZE-byte blocks" )
                                 .withValueSeparator( '=' )
                                 .hasArg()

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