8067207: Replace concat String to append in StringBuilder parameters (client)
Reviewed-by: serb
Contributed-by: Otavio Santana <otaviojava@java.net>
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java Thu Dec 11 15:19:12 2014 +0800
@@ -167,9 +167,9 @@
for (int i = 0; i < allchannelnames.length; i++) {
if ((channelmask & m) != 0L) {
if (i < channelnames.length) {
- sb.append(channelnames[i] + " ");
+ sb.append(channelnames[i]).append(' ');
} else {
- sb.append(allchannelnames[i] + " ");
+ sb.append(allchannelnames[i]).append(' ');
}
}
m *= 2L;
--- a/jdk/src/java.desktop/share/classes/javax/swing/GroupLayout.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/GroupLayout.java Thu Dec 11 15:19:12 2014 +0800
@@ -1213,15 +1213,15 @@
registerComponents(horizontalGroup, HORIZONTAL);
registerComponents(verticalGroup, VERTICAL);
}
- StringBuffer buffer = new StringBuffer();
- buffer.append("HORIZONTAL\n");
- createSpringDescription(buffer, horizontalGroup, " ", HORIZONTAL);
- buffer.append("\nVERTICAL\n");
- createSpringDescription(buffer, verticalGroup, " ", VERTICAL);
- return buffer.toString();
+ StringBuilder sb = new StringBuilder();
+ sb.append("HORIZONTAL\n");
+ createSpringDescription(sb, horizontalGroup, " ", HORIZONTAL);
+ sb.append("\nVERTICAL\n");
+ createSpringDescription(sb, verticalGroup, " ", VERTICAL);
+ return sb.toString();
}
- private void createSpringDescription(StringBuffer buffer, Spring spring,
+ private void createSpringDescription(StringBuilder sb, Spring spring,
String indent, int axis) {
String origin = "";
String padding = "";
@@ -1239,20 +1239,19 @@
padding = ", userCreated=" + paddingSpring.getUserCreated() +
", matches=" + paddingSpring.getMatchDescription();
}
- buffer.append(indent + spring.getClass().getName() + " " +
- Integer.toHexString(spring.hashCode()) + " " +
- origin +
- ", size=" + spring.getSize() +
- ", alignment=" + spring.getAlignment() +
- " prefs=[" + spring.getMinimumSize(axis) +
- " " + spring.getPreferredSize(axis) +
- " " + spring.getMaximumSize(axis) +
- padding + "]\n");
+ sb.append(indent).append(spring.getClass().getName()).append(' ')
+ .append(Integer.toHexString(spring.hashCode())).append(' ')
+ .append(origin).append(", size=").append(spring.getSize())
+ .append(", alignment=").append(spring.getAlignment())
+ .append(" prefs=[").append(spring.getMinimumSize(axis))
+ .append(' ').append(spring.getPreferredSize(axis)).append(' ')
+ .append(spring.getMaximumSize(axis)).append(padding)
+ .append("]\n");
if (spring instanceof Group) {
List<Spring> springs = ((Group)spring).springs;
indent += " ";
for (int counter = 0; counter < springs.size(); counter++) {
- createSpringDescription(buffer, springs.get(counter), indent,
+ createSpringDescription(sb, springs.get(counter), indent,
axis);
}
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/JColorChooser.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JColorChooser.java Thu Dec 11 15:19:12 2014 +0800
@@ -543,17 +543,17 @@
* @return a string representation of this <code>JColorChooser</code>
*/
protected String paramString() {
- StringBuilder chooserPanelsString = new StringBuilder("");
- for (int i=0; i<chooserPanels.length; i++) {
- chooserPanelsString.append("[" + chooserPanels[i].toString()
- + "]");
+ StringBuilder chooserPanelsString = new StringBuilder();
+ for (AbstractColorChooserPanel panel : chooserPanels) {
+ chooserPanelsString.append('[').append(panel)
+ .append(']');
}
- String previewPanelString = (previewPanel != null ?
- previewPanel.toString() : "");
+ String previewPanelString = (previewPanel != null ? previewPanel
+ .toString() : "");
- return super.paramString() +
- ",chooserPanels=" + chooserPanelsString.toString() +
- ",previewPanel=" + previewPanelString;
+ return super.paramString() + ",chooserPanels="
+ + chooserPanelsString.toString() + ",previewPanel="
+ + previewPanelString;
}
/////////////////
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java Thu Dec 11 15:19:12 2014 +0800
@@ -1330,8 +1330,8 @@
for (Object obj : values) {
String val = ((obj == null) ? "" : obj.toString());
- plainBuf.append(val + "\n");
- htmlBuf.append(" <li>" + val + "\n");
+ plainBuf.append(val).append('\n');
+ htmlBuf.append(" <li>").append(val).append('\n');
}
// remove the last newline
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java Thu Dec 11 15:19:12 2014 +0800
@@ -2948,8 +2948,8 @@
for (int i = 0; i < values.length; i++) {
Object obj = values[i];
String val = ((obj == null) ? "" : obj.toString());
- plainStr.append(val + "\n");
- htmlStr.append(" <li>" + val + "\n");
+ plainStr.append(val).append('\n');
+ htmlStr.append(" <li>").append(val).append('\n');
}
// remove the last newline
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTableUI.java Thu Dec 11 15:19:12 2014 +0800
@@ -2230,11 +2230,11 @@
for (int col = 0; col < cols.length; col++) {
Object obj = table.getValueAt(rows[row], cols[col]);
String val = ((obj == null) ? "" : obj.toString());
- plainStr.append(val + "\t");
- htmlStr.append(" <td>" + val + "</td>\n");
+ plainStr.append(val).append('\t');
+ htmlStr.append(" <td>").append(val).append("</td>\n");
}
// we want a newline at the end of each line and not a tab
- plainStr.deleteCharAt(plainStr.length() - 1).append("\n");
+ plainStr.deleteCharAt(plainStr.length() - 1).append('\n');
htmlStr.append("</tr>\n");
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Thu Dec 11 15:19:12 2014 +0800
@@ -3618,8 +3618,8 @@
boolean leaf = model.isLeaf(node);
String label = getDisplayString(path, true, leaf);
- plainStr.append(label + "\n");
- htmlStr.append(" <li>" + label + "\n");
+ plainStr.append(label).append('\n');
+ htmlStr.append(" <li>").append(label).append('\n');
}
// remove the last newline
--- a/jdk/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java Wed Dec 10 17:10:57 2014 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/font/StandardGlyphVector.java Thu Dec 11 15:19:12 2014 +0800
@@ -1894,9 +1894,9 @@
}
}
catch(Exception e) {
- buf.append(" " + e.getMessage());
+ buf.append(' ').append(e.getMessage());
}
- buf.append("}");
+ buf.append('}');
return buf;
}