commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r551815 - in /jakarta/commons/proper/cli/branches/cli-1.0.x/src: java/org/apache/commons/cli/Option.java java/org/apache/commons/cli/Parser.java test/org/apache/commons/cli/OptionTest.java
Date Fri, 29 Jun 2007 07:08:45 GMT
Author: bayard
Date: Fri Jun 29 00:08:44 2007
New Revision: 551815

URL: http://svn.apache.org/viewvc?view=rev&rev=551815
Log:
Applying the patch from CLI-135 to put the public addValue method back, even though it just
throws an exception. This maintains binary compatibility, for some level of compatibility.


Modified:
    jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Option.java
    jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Parser.java
    jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/OptionTest.java

Modified: jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Option.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Option.java?view=diff&rev=551815&r1=551814&r2=551815
==============================================================================
--- jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Option.java
(original)
+++ jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Option.java
Fri Jun 29 00:08:44 2007
@@ -401,7 +401,7 @@
      * 
      * @param value is a/the value of this Option
      */
-    void addValue(String value)
+    void addValueForProcessing(String value)
     {
         switch (numberOfArgs)
         {
@@ -647,6 +647,13 @@
      */
     void clearValues() {
         this.values.clear();
+    }
+
+    public boolean addValue(Object object) {
+        throw new UnsupportedOperationException(
+           "The addValue method is not intended for client use. " + 
+           "Subclasses should use the addValueForProcessing method instead. "
+           );
     }
 
 }

Modified: jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Parser.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Parser.java?view=diff&rev=551815&r1=551814&r2=551815
==============================================================================
--- jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Parser.java
(original)
+++ jakarta/commons/proper/cli/branches/cli-1.0.x/src/java/org/apache/commons/cli/Parser.java
Fri Jun 29 00:08:44 2007
@@ -258,7 +258,7 @@
                     {
                         try
                         {
-                            opt.addValue(value);
+                            opt.addValueForProcessing(value);
                         }
                         catch (RuntimeException exp)
                         {
@@ -340,7 +340,7 @@
             // found a value
             try
             {
-                opt.addValue( Util.stripLeadingAndTrailingQuotes(str) );
+                opt.addValueForProcessing( Util.stripLeadingAndTrailingQuotes(str) );
             }
             catch (RuntimeException exp)
             {

Modified: jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/OptionTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/OptionTest.java?view=diff&rev=551815&r1=551814&r2=551815
==============================================================================
--- jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/OptionTest.java
(original)
+++ jakarta/commons/proper/cli/branches/cli-1.0.x/src/test/org/apache/commons/cli/OptionTest.java
Fri Jun 29 00:08:44 2007
@@ -23,8 +23,18 @@
  */
 public class OptionTest extends TestCase {
 
+   private static class TestOption extends Option {
+        public TestOption(String opt, boolean hasArg, String description) throws IllegalArgumentException
{
+            super(opt, hasArg, description);
+        }
+        public boolean addValue(String value) {
+            addValueForProcessing(value);
+            return true;
+        }
+   }
+
    public void testClear() {
-       Option option = new Option("x", true, "");
+       TestOption option = new TestOption("x", true, "");
        assertEquals(0, option.getValuesList().size());
        option.addValue("a");
        assertEquals(1, option.getValuesList().size());
@@ -34,8 +44,8 @@
 
     // See http://issues.apache.org/jira/browse/CLI-21
     public void testClone() throws CloneNotSupportedException {
-        Option a = new Option("a", true, "");
-        Option b = (Option) a.clone();
+        TestOption a = new TestOption("a", true, "");
+        TestOption b = (TestOption) a.clone();
         assertEquals(a, b);
         assertNotSame(a, b);
         a.setDescription("a");



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