commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [35/40] commons-cli git commit: Remove deprecated method (OK as code has not been released) Improve toString() output Add toShortString() method for testing
Date Thu, 08 Jun 2017 17:38:24 GMT
Remove deprecated method (OK as code has not been released)
Improve toString() output
Add toShortString() method for testing

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/branches/avalon-implementation@539927
13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/commons-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-cli/commit/01de7d4e
Tree: http://git-wip-us.apache.org/repos/asf/commons-cli/tree/01de7d4e
Diff: http://git-wip-us.apache.org/repos/asf/commons-cli/diff/01de7d4e

Branch: refs/heads/avalon-implementation
Commit: 01de7d4e7e4b1df4b090916e5ef5148ce2152af5
Parents: 00aab5d
Author: Sebastian Bazley <sebb@apache.org>
Authored: Sun May 20 19:54:54 2007 +0000
Committer: Sebastian Bazley <sebb@apache.org>
Committed: Sun May 20 19:54:54 2007 +0000

----------------------------------------------------------------------
 .../org/apache/commons/cli/avalon/CLOption.java | 45 +++++++++++++-------
 1 file changed, 30 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-cli/blob/01de7d4e/src/java/org/apache/commons/cli/avalon/CLOption.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/cli/avalon/CLOption.java b/src/java/org/apache/commons/cli/avalon/CLOption.java
index d2fdd83..242ad1c 100644
--- a/src/java/org/apache/commons/cli/avalon/CLOption.java
+++ b/src/java/org/apache/commons/cli/avalon/CLOption.java
@@ -71,19 +71,6 @@ public final class CLOption
         }
     }
 
-    /**
-     * 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 class CLOption
     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 )
         {
@@ -171,4 +164,26 @@ public final class CLOption
 
         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();
+    }
 }


Mime
View raw message