]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use chain of .append() methods instead of String concatenation
authorPer-Åke Minborg <minborg@speedment.com>
Fri, 28 Oct 2016 15:46:30 +0000 (08:46 -0700)
committerVaadin Code Review <review@vaadin.com>
Fri, 4 Nov 2016 13:36:29 +0000 (13:36 +0000)
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf721d

server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
server/src/main/java/com/vaadin/server/JsonPaintTarget.java
server/src/main/java/com/vaadin/server/communication/PortletBootstrapHandler.java
server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java
server/src/test/java/com/vaadin/tests/server/clientconnector/AttachDetachListenersTest.java
server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java
server/src/test/java/com/vaadin/tests/util/GraphVizClassHierarchyCreator.java

index e68fbb59033f8e4048ff64ff4ebb6171fea7f8a6..7d4de85cfe63b8fcde1189698c23eb6639564235 100644 (file)
@@ -217,7 +217,7 @@ public class ComponentSizeValidator implements Serializable {
             Component parent = component.getParent();
             String paintableId = component.getConnectorId();
 
-            clientJSON.append("\"id\":\"" + paintableId + "\"");
+            clientJSON.append("\"id\":\"").append(paintableId).append("\"");
 
             if (invalidHeight) {
                 Stack<ComponentInfo> attributes = null;
@@ -247,7 +247,7 @@ public class ComponentSizeValidator implements Serializable {
                     attributes = getHeightAttributes(component);
                 }
                 printServerError(msg, attributes, false, serverErrorStream);
-                clientJSON.append(",\"heightMsg\":\"" + msg + "\"");
+                clientJSON.append(",\"heightMsg\":\"").append(msg).append("\"");
             }
             if (invalidWidth) {
                 Stack<ComponentInfo> attributes = null;
@@ -275,7 +275,7 @@ public class ComponentSizeValidator implements Serializable {
                     msg = "A component with relative width needs a parent with defined width.";
                     attributes = getWidthAttributes(component);
                 }
-                clientJSON.append(",\"widthMsg\":\"" + msg + "\"");
+                clientJSON.append(",\"widthMsg\":\"").append(msg).append("\"");
                 printServerError(msg, attributes, true, serverErrorStream);
             }
             if (subErrors.size() > 0) {
@@ -402,8 +402,7 @@ public class ComponentSizeValidator implements Serializable {
         }
 
         if (createLoc != null) {
-            err.append(", created at (" + createLoc.file + ":"
-                    + createLoc.lineNumber + ")");
+            err.append(", created at (").append(createLoc.file).append(":").append(createLoc.lineNumber).append(")");
 
         }
 
@@ -411,8 +410,7 @@ public class ComponentSizeValidator implements Serializable {
             err.append(" (");
             err.append(attribute);
             if (sizeLoc != null) {
-                err.append(", set at (" + sizeLoc.file + ":"
-                        + sizeLoc.lineNumber + ")");
+                err.append(", set at (").append(sizeLoc.file).append(":").append(sizeLoc.lineNumber).append(")");
             }
 
             err.append(")");
index 4463fd1ab5dce92ab0b9a1465576853ae0fef313..9792673062597e00b3ded8b33d7ce218002781cb 100644 (file)
@@ -443,7 +443,7 @@ public class JsonPaintTarget implements PaintTarget {
                     "Parameters must be non-null strings");
         }
         final StringBuilder buf = new StringBuilder();
-        buf.append("\"" + name + "\":[");
+        buf.append("\"").append(name).append("\":[");
         for (int i = 0; i < values.length; i++) {
             if (i > 0) {
                 buf.append(",");
@@ -743,7 +743,7 @@ public class JsonPaintTarget implements PaintTarget {
         private boolean tagClosed = false;
 
         public JsonTag(String tagName) {
-            data.append("[\"" + tagName + "\"");
+            data.append("[\"").append(tagName).append("\"");
         }
 
         private void closeTag() {
index 2b40b6caca836892433267d2fd8c078c37211280..a75e6a810ba72377d69bad0392f9f9e098592855 100644 (file)
@@ -78,7 +78,7 @@ public class PortletBootstrapHandler extends BootstrapHandler {
                 && !portalTheme.equals(context.getThemeName())) {
             String portalThemeUri = getThemeUri(context, portalTheme);
             // XSS safe - originates from portal properties
-            builder.append("vaadin.loadTheme('" + portalThemeUri + "');");
+            builder.append("vaadin.loadTheme('").append(portalThemeUri).append("');");
         }
 
         super.appendMainScriptTagContents(context, builder);
index f0bcc8887a4b8d55830c3e6a063dd0c266f0ec55..e2e81488710f97c421965a86b66ab94b75c66f76 100644 (file)
@@ -268,7 +268,7 @@ public abstract class DeclarativeTestBaseBase<T extends Component> {
         }
         Collections.sort(names);
 
-        sb.append("<" + producedElem.tagName() + "");
+        sb.append("<").append(producedElem.tagName()).append("");
         for (String attrName : names) {
             sb.append(" ").append(attrName);
             if (!booleanAttributes.contains(attrName)) {
index 75ab52370db42413fbd464b8704e969bee7b6213..b870e0ab4f155f2ad52989f1df3b916769259814 100644 (file)
@@ -160,8 +160,7 @@ public class AttachDetachListenersTest {
         @Override
         public void appendTo(StringBuffer buffer) {
             buffer.append("EventEquals(");
-            buffer.append("expected " + expected.getClass().getSimpleName()
-                    + " with connector " + expected.getConnector());
+            buffer.append("expected ").append(expected.getClass().getSimpleName()).append(" with connector ").append(expected.getConnector());
             buffer.append(")");
         }
 
index 1a1d15edcffeca6c173a9fa7c2044dbdc19b60ba..be3f402e168cce573d390e9da87d78e66c681a78 100644 (file)
@@ -256,7 +256,7 @@ public class NavigatorTest {
         EasyMock.reportMatcher(new IArgumentMatcher() {
             @Override
             public void appendTo(StringBuffer buffer) {
-                buffer.append("paramsIs(\"" + expected + "\")");
+                buffer.append("paramsIs(\"").append(expected).append("\")");
             }
 
             @Override
index c322eb7ed8728a06bc6aa3faa9a957609d0185ad..ebde4b191a0aeef7399d08680cfecdd2a2a3d80f 100644 (file)
@@ -50,14 +50,14 @@ public class GraphVizClassHierarchyCreator {
         header.append("    node [shape = ellipse, style=\"dotted\"] ");
         for (Class c : classesAndParents) {
             if (!c.isInterface() && Modifier.isAbstract(c.getModifiers())) {
-                header.append(c.getSimpleName() + " ");
+                header.append(c.getSimpleName()).append(" ");
             }
         }
         if (includeInterfaces) {
             System.out.print("    node [shape = ellipse, style=\"solid\"] ");
             for (Class c : classesAndParents) {
                 if (c.isInterface()) {
-                    header.append(c.getSimpleName() + " ");
+                    header.append(c.getSimpleName()).append(" ");
                 }
             }
             header.append(";\n");