commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r539927 - /jakarta/commons/proper/cli/branches/avalon-implementation/src/java/org/apache/commons/cli/avalon/CLOption.java
Date Sun, 20 May 2007 19:54:55 GMT
Author: sebb
Date: Sun May 20 12:54:54 2007
New Revision: 539927

URL: http://svn.apache.org/viewvc?view=rev&rev=539927
Log:
Remove deprecated method (OK as code has not been released)
Improve toString() output
Add toShortString() method for testing

Modified:
    jakarta/commons/proper/cli/branches/avalon-implementation/src/java/org/apache/commons/cli/avalon/CLOption.java

Modified: jakarta/commons/proper/cli/branches/avalon-implementation/src/java/org/apache/commons/cli/avalon/CLOption.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/cli/branches/avalon-implementation/src/java/org/apache/commons/cli/avalon/CLOption.java?view=diff&rev=539927&r1=539926&r2=539927
==============================================================================
--- jakarta/commons/proper/cli/branches/avalon-implementation/src/java/org/apache/commons/cli/avalon/CLOption.java
(original)
+++ jakarta/commons/proper/cli/branches/avalon-implementation/src/java/org/apache/commons/cli/avalon/CLOption.java
Sun May 20 12:54:54 2007
@@ -71,19 +71,6 @@
         }
     }
 
-    /**
-     * Retrieve id of option.
-     *
-     * The id is eqivalent to character code if it can be a single letter option.
-     *
-     * @return the id
-     * @deprecated use <code>getDescriptor().getId()</code> instead
-     */
-    public final int getId()
-    {
-        return m_descriptor == null ? TEXT_ARGUMENT : m_descriptor.getId();
-    }
-
     public final CLOptionDescriptor getDescriptor()
     {
         return m_descriptor;
@@ -158,8 +145,14 @@
     public final String toString()
     {
         final StringBuffer sb = new StringBuffer();
-        sb.append( "[Option " );
-        sb.append( (char)m_descriptor.getId() );
+        sb.append("[");
+        final char id = (char) m_descriptor.getId();
+        if (id == TEXT_ARGUMENT) {
+            sb.append("Text ");
+        } else {
+            sb.append("Option ");
+            sb.append(id);            
+        }
 
         if( null != m_arguments )
         {
@@ -169,6 +162,28 @@
 
         sb.append( " ]" ); // $NON-NLS-1$
 
+        return sb.toString();
+    }
+
+    /*
+     * Convert to a shorter String for test purposes
+     * 
+     * @return the string value
+     */
+    final String toShortString() {
+        final StringBuffer sb = new StringBuffer();
+        final char id = (char) m_descriptor.getId();
+        if (id != TEXT_ARGUMENT) {
+            sb.append("-");
+            sb.append(id);            
+        }
+
+        if (null != m_arguments) {
+            if (id != TEXT_ARGUMENT) {
+                sb.append("=");
+            }
+            sb.append(Arrays.asList(m_arguments));
+        }
         return sb.toString();
     }
 }



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