tmf: Correctly print HTInterval in its toString()
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 26 Jul 2012 18:09:38 +0000 (14:09 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 26 Jul 2012 18:44:21 +0000 (14:44 -0400)
The ASCII value of '[' would get added to the start time,
instead of doing the expected string concatenation.

Changed the whole thing to use a StringBuilder instead.

Change-Id: Iea7f2b409c7c177a4a0b35494294fca7258835a1
Reported-by: Patrick Tassé <patrick.tasse@gmail.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/6985
Reviewed-by: Bernd Hufmann <bhufmann@gmail.com>
IP-Clean: Bernd Hufmann <bhufmann@gmail.com>
Tested-by: Bernd Hufmann <bhufmann@gmail.com>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/historytree/HTInterval.java

index 71ada2f75e249933536a962744e8d53acf77fd43..0432f4e2def48e52554f2b21f1464ee4c4037824 100644 (file)
@@ -2,12 +2,12 @@
  * Copyright (c) 2012 Ericsson
  * Copyright (c) 2010, 2011 École Polytechnique de Montréal
  * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
- * 
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.tmf.core.statesystem.historytree;
@@ -24,9 +24,9 @@ import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
 /**
  * The interval component, which will be contained in a node of the History
  * Tree.
- * 
+ *
  * @author alexmont
- * 
+ *
  */
 final class HTInterval implements ITmfStateInterval, Comparable<HTInterval> {
 
@@ -42,7 +42,7 @@ final class HTInterval implements ITmfStateInterval, Comparable<HTInterval> {
 
     /**
      * Standard constructor
-     * 
+     *
      * @param intervalStart
      * @param intervalEnd
      * @param attribute
@@ -65,7 +65,7 @@ final class HTInterval implements ITmfStateInterval, Comparable<HTInterval> {
     /**
      * Reader constructor. Builds the interval using an already-allocated
      * ByteBuffer, which normally comes from a NIO FileChannel.
-     * 
+     *
      * @param buffer
      *            The ByteBuffer from which to read the information
      * @throws IOException
@@ -149,7 +149,7 @@ final class HTInterval implements ITmfStateInterval, Comparable<HTInterval> {
      * Antagonist of the previous constructor, write the Data entry
      * corresponding to this interval in a ByteBuffer (mapped to a block in the
      * history-file, hopefully)
-     * 
+     *
      * @param buffer
      *            The already-allocated ByteBuffer corresponding to a SHT Node
      * @param endPosOfStringEntry
@@ -248,7 +248,7 @@ final class HTInterval implements ITmfStateInterval, Comparable<HTInterval> {
 
     /**
      * Total serialized size of this interval
-     * 
+     *
      * @return
      */
     int getIntervalSize() {
@@ -296,8 +296,19 @@ final class HTInterval implements ITmfStateInterval, Comparable<HTInterval> {
     @Override
     public String toString() {
         /* Only for debug, should not be externalized */
-        return '[' + start + ", " + end + ']' + //$NON-NLS-1$
-                ", attribute = " + attribute + //$NON-NLS-1$
-                ", value = " + sv.toString(); //$NON-NLS-1$
+        StringBuilder sb = new StringBuilder();
+        sb.append('[');
+        sb.append(start);
+        sb.append(", "); //$NON-NLS-1$
+        sb.append(end);
+        sb.append(']');
+
+        sb.append(", attribute = "); //$NON-NLS-1$
+        sb.append(attribute);
+
+        sb.append(", value = "); //$NON-NLS-1$
+        sb.append(sv.toString());
+
+        return sb.toString();
     }
 }
This page took 0.026946 seconds and 5 git commands to generate.