tmf : use of StringBuilder.append() instead of String operator +
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Fri, 4 Dec 2015 18:03:55 +0000 (13:03 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 8 Dec 2015 16:10:49 +0000 (11:10 -0500)
Change-Id: I062c411af568289f5c17a279953703d720109119
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/62015
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterTreeLabelProvider.java

index c211d3c669c9d69148d767797e356c20025bf76e..bbabe58b75a2d29839c333d09e0a29f4de1bc941 100644 (file)
@@ -69,65 +69,65 @@ public class FilterTreeLabelProvider implements ILabelProvider {
 
     @Override
     public String getText(Object element) {
-        String label = null;
+        StringBuilder label = new StringBuilder();
 
         if (element instanceof TmfFilterNode) {
 
             TmfFilterNode node = (TmfFilterNode) element;
-            label = node.getNodeName() + ' ' + (node.getFilterName() != null &&
+            label.append(node.getNodeName()).append(' ').append(node.getFilterName() != null &&
                     !node.getFilterName().isEmpty() ? node.getFilterName() : Messages.FilterTreeLabelProvider_FilterNameHint);
 
         } else if (element instanceof TmfFilterTraceTypeNode) {
 
             TmfFilterTraceTypeNode node = (TmfFilterTraceTypeNode) element;
-            label = "WITH " + node.getNodeName() + ' ' + (node.getName() != null ? node.getName() : Messages.FilterTreeLabelProvider_TraceTypeHint); //$NON-NLS-1$
+            label.append("WITH ").append(node.getNodeName()).append(' ').append((node.getName() != null ? node.getName() : Messages.FilterTreeLabelProvider_TraceTypeHint)); //$NON-NLS-1$
 
         } else if (element instanceof TmfFilterAndNode) {
 
             TmfFilterAndNode node = (TmfFilterAndNode) element;
-            label = (node.isNot() ? NOT : EMPTY_STRING) + node.getNodeName();
+            label.append((node.isNot() ? NOT : EMPTY_STRING)).append(node.getNodeName());
 
         } else if (element instanceof TmfFilterOrNode) {
 
             TmfFilterOrNode node = (TmfFilterOrNode) element;
-            label = (node.isNot() ? NOT : EMPTY_STRING) + node.getNodeName();
+            label.append(node.isNot() ? NOT : EMPTY_STRING).append(node.getNodeName());
 
         } else if (element instanceof TmfFilterContainsNode) {
 
             TmfFilterContainsNode node = (TmfFilterContainsNode) element;
-            label = (node.isNot() ? NOT : EMPTY_STRING) +
-                    (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
-                    ' ' + node.getNodeName() +
-                    (node.getValue() != null ? SPACE_QUOTE + node.getValue() + QUOTE : EMPTY_STRING);
+            label.append(node.isNot() ? NOT : EMPTY_STRING)
+            .append(node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint)
+            .append(' ').append(node.getNodeName()).append(node.getValue() != null ?
+                    new StringBuilder().append(SPACE_QUOTE).append(node.getValue()).append(QUOTE).toString() : EMPTY_STRING);
 
         } else if (element instanceof TmfFilterEqualsNode) {
 
             TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;
-            label = (node.isNot() ? NOT : EMPTY_STRING) +
-                    (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
-                    ' ' + node.getNodeName() +
-                    (node.getValue() != null ? SPACE_QUOTE + node.getValue() + QUOTE : EMPTY_STRING);
+            label.append(node.isNot() ? NOT : EMPTY_STRING)
+            .append(node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint)
+            .append(' ').append(node.getNodeName())
+            .append(node.getValue() != null ? new StringBuilder().append(SPACE_QUOTE).append(node.getValue()).append(QUOTE).toString() : EMPTY_STRING);
 
         } else if (element instanceof TmfFilterMatchesNode) {
 
             TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;
-            label = (node.isNot() ? NOT : EMPTY_STRING) +
-                    (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
-                    ' ' + node.getNodeName() +
-                    (node.getRegex() != null ? SPACE_QUOTE + node.getRegex() + QUOTE : EMPTY_STRING);
+            label.append(node.isNot() ? NOT : EMPTY_STRING)
+            .append(node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint)
+            .append(' ').append(node.getNodeName())
+            .append(node.getRegex() != null ? new StringBuilder().append(SPACE_QUOTE).append(node.getRegex()).append(QUOTE).toString() : EMPTY_STRING);
 
         } else if (element instanceof TmfFilterCompareNode) {
 
             TmfFilterCompareNode node = (TmfFilterCompareNode) element;
-            label = (node.isNot() ? NOT : EMPTY_STRING) +
-                    (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
-                    (node.getResult() < 0 ? " <" : (node.getResult() > 0 ? " >" : " =")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-                    (node.getType() == Type.ALPHA ? SPACE_QUOTE : node.getType() == Type.TIMESTAMP ? " [" : ' ') + //$NON-NLS-1$
-                    (node.hasValidValue() ? node.getValue() : Messages.FilterTreeLabelProvider_ValueHint) +
-                    (node.getType() == Type.ALPHA ? '\"' : node.getType() == Type.TIMESTAMP ? ']' : EMPTY_STRING);
+            label.append(node.isNot() ? NOT : EMPTY_STRING)
+            .append(node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint)
+            .append(node.getResult() < 0 ? " <" : (node.getResult() > 0 ? " >" : " =")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            .append(node.getType() == Type.ALPHA ? SPACE_QUOTE : node.getType() == Type.TIMESTAMP ? " [" : ' ') //$NON-NLS-1$
+            .append(node.hasValidValue() ? node.getValue() : Messages.FilterTreeLabelProvider_ValueHint)
+            .append(node.getType() == Type.ALPHA ? '\"' : node.getType() == Type.TIMESTAMP ? ']' : EMPTY_STRING);
 
         }
-        return label;
+        return label.toString();
     }
 
 }
This page took 0.040628 seconds and 5 git commands to generate.