Skip to content

Commit 10eeaf6

Browse files
committed
Replaced StringBuilder with StringBuffer wherever possible without breaking binary compatibility
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@1214688 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3ba638a commit 10eeaf6

6 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/main/java/org/apache/commons/cli/AmbiguousOptionException.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ public Collection<String> getMatchingOptions()
6666
*/
6767
private static String createMessage(String option, Collection<String> matchingOptions)
6868
{
69-
StringBuffer buff = new StringBuffer("Ambiguous option: '");
70-
buff.append(option);
71-
buff.append("' (could be: ");
69+
StringBuilder buf = new StringBuilder("Ambiguous option: '");
70+
buf.append(option);
71+
buf.append("' (could be: ");
7272

7373
Iterator<String> it = matchingOptions.iterator();
7474
while (it.hasNext())
7575
{
76-
buff.append("'");
77-
buff.append(it.next());
78-
buff.append("'");
76+
buf.append("'");
77+
buf.append(it.next());
78+
buf.append("'");
7979
if (it.hasNext())
8080
{
81-
buff.append(", ");
81+
buf.append(", ");
8282
}
8383
}
84-
buff.append(")");
84+
buf.append(")");
8585

86-
return buff.toString();
86+
return buf.toString();
8787
}
8888
}

src/main/java/org/apache/commons/cli/CommandLine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public List<String> getArgList()
321321

322322
/*
323323
public String toString() {
324-
StringBuffer buf = new StringBuffer();
324+
StringBuilder buf = new StringBuilder();
325325
326326
buf.append("[ CommandLine: [ options: ");
327327
buf.append(options.toString());

src/main/java/org/apache/commons/cli/HelpFormatter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ protected StringBuffer renderOptions(StringBuffer sb, int width, Options options
804804
for (Iterator i = optList.iterator(); i.hasNext();)
805805
{
806806
Option option = (Option) i.next();
807-
StringBuffer optBuf = new StringBuffer(prefixList.get(x++).toString());
807+
StringBuilder optBuf = new StringBuilder(prefixList.get(x++).toString());
808808

809809
if (optBuf.length() < max)
810810
{
@@ -894,7 +894,7 @@ protected StringBuffer renderWrappedText(StringBuffer sb, int width,
894894
* @param nextLineTabStop The position on the next line for the first tab.
895895
* @param text The text to be rendered.
896896
*/
897-
private StringBuffer renderWrappedTextBlock(StringBuffer sb, int width, int nextLineTabStop, String text)
897+
private Appendable renderWrappedTextBlock(StringBuffer sb, int width, int nextLineTabStop, String text)
898898
{
899899
try
900900
{

src/main/java/org/apache/commons/cli/MissingOptionException.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ public List getMissingOptions()
7878
*/
7979
private static String createMessage(List missingOptions)
8080
{
81-
StringBuffer buff = new StringBuffer("Missing required option");
82-
buff.append(missingOptions.size() == 1 ? "" : "s");
83-
buff.append(": ");
81+
StringBuilder buf = new StringBuilder("Missing required option");
82+
buf.append(missingOptions.size() == 1 ? "" : "s");
83+
buf.append(": ");
8484

8585
Iterator it = missingOptions.iterator();
8686
while (it.hasNext())
8787
{
88-
buff.append(it.next());
88+
buf.append(it.next());
8989
if (it.hasNext())
9090
{
91-
buff.append(", ");
91+
buf.append(", ");
9292
}
9393
}
9494

95-
return buff.toString();
95+
return buf.toString();
9696
}
9797
}

src/main/java/org/apache/commons/cli/Option.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public List<String> getValuesList()
547547
*/
548548
public String toString()
549549
{
550-
StringBuffer buf = new StringBuffer().append("[ option: ");
550+
StringBuilder buf = new StringBuilder().append("[ option: ");
551551

552552
buf.append(opt);
553553

src/main/java/org/apache/commons/cli/Options.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public OptionGroup getOptionGroup(Option opt)
294294
*/
295295
public String toString()
296296
{
297-
StringBuffer buf = new StringBuffer();
297+
StringBuilder buf = new StringBuilder();
298298

299299
buf.append("[ Options: [ short ");
300300
buf.append(shortOpts.toString());

0 commit comments

Comments
 (0)