Skip to content

Commit 01de7d4

Browse files
committed
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
1 parent 00aab5d commit 01de7d4

1 file changed

Lines changed: 30 additions & 15 deletions

File tree

src/java/org/apache/commons/cli/avalon/CLOption.java

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,6 @@ public final String getArgument( final int index )
7171
}
7272
}
7373

74-
/**
75-
* Retrieve id of option.
76-
*
77-
* The id is eqivalent to character code if it can be a single letter option.
78-
*
79-
* @return the id
80-
* @deprecated use <code>getDescriptor().getId()</code> instead
81-
*/
82-
public final int getId()
83-
{
84-
return m_descriptor == null ? TEXT_ARGUMENT : m_descriptor.getId();
85-
}
86-
8774
public final CLOptionDescriptor getDescriptor()
8875
{
8976
return m_descriptor;
@@ -158,8 +145,14 @@ public final int getArgumentCount()
158145
public final String toString()
159146
{
160147
final StringBuffer sb = new StringBuffer();
161-
sb.append( "[Option " );
162-
sb.append( (char)m_descriptor.getId() );
148+
sb.append("[");
149+
final char id = (char) m_descriptor.getId();
150+
if (id == TEXT_ARGUMENT) {
151+
sb.append("Text ");
152+
} else {
153+
sb.append("Option ");
154+
sb.append(id);
155+
}
163156

164157
if( null != m_arguments )
165158
{
@@ -171,4 +164,26 @@ public final String toString()
171164

172165
return sb.toString();
173166
}
167+
168+
/*
169+
* Convert to a shorter String for test purposes
170+
*
171+
* @return the string value
172+
*/
173+
final String toShortString() {
174+
final StringBuffer sb = new StringBuffer();
175+
final char id = (char) m_descriptor.getId();
176+
if (id != TEXT_ARGUMENT) {
177+
sb.append("-");
178+
sb.append(id);
179+
}
180+
181+
if (null != m_arguments) {
182+
if (id != TEXT_ARGUMENT) {
183+
sb.append("=");
184+
}
185+
sb.append(Arrays.asList(m_arguments));
186+
}
187+
return sb.toString();
188+
}
174189
}

0 commit comments

Comments
 (0)