From a6223d74d26869538692c36da10c7cae33c2754f Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Mon, 7 Jan 2013 16:52:04 -0500 Subject: [PATCH] TMF: Fix for displaying arrays in the events properties Change-Id: Icf87b2b4e64b2d16a30c15a1463844cf3daf608f Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/9509 Reviewed-by: Patrick Tasse IP-Clean: Patrick Tasse Tested-by: Hudson CI --- .../ctfadaptor/CtfTmfEventFieldTest.java | 15 ++++++-- .../tmf/core/ctfadaptor/CtfTmfEventField.java | 35 +++++++++++++------ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java index 61fac4df61..1dbc2a9c94 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventFieldTest.java @@ -123,7 +123,7 @@ public class CtfTmfEventFieldTest { CtfTmfEventField result; result = CtfTmfEventField.parseField(fixture.lookupArray(ARRAY), NAME); String result2 = CtfTmfEventField.copyFrom(result).toString(); - assertEquals( result2, "test={ 2, 2}"); //$NON-NLS-1$ + assertEquals( result2, "test=[2, 2]"); //$NON-NLS-1$ } /** @@ -145,7 +145,18 @@ public class CtfTmfEventFieldTest { Definition fieldDef = fixture.lookupDefinition(SEQ); CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME); String result2 =CtfTmfEventField.copyFrom(result).toString(); - assertEquals( result2, "test={ 2, 2}"); //$NON-NLS-1$ + assertEquals( result2, "test=[2, 2]"); //$NON-NLS-1$ + } + + /** + * Run the CtfTmfEventField parseField(Definition,String) method test. + */ + @Test + public void testParseField_sequence_value() { + Definition fieldDef = fixture.lookupDefinition(SEQ); + CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME); + String result2 = CtfTmfEventField.copyFrom(result).getValue().toString(); + assertEquals( result2, "[2, 2]"); //$NON-NLS-1$ } /** diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java index eac087b6f9..75924c3ead 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java @@ -15,6 +15,9 @@ package org.eclipse.linuxtools.tmf.core.ctfadaptor; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.linuxtools.ctf.core.event.types.ArrayDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.ArrayDefinition; import org.eclipse.linuxtools.ctf.core.event.types.Definition; @@ -189,7 +192,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { other.name); case FIELDTYPE_INTEGER_ARRAY: return new CTFIntegerArrayField( - ((CTFIntegerArrayField) other).getValue(), other.name); + ((CTFIntegerArrayField) other).getLongValues(), other.name); case FIELDTYPE_FLOAT: return new CTFFloatField(((CTFFloatField) other).getValue(), other.name); @@ -397,22 +400,32 @@ final class CTFIntegerArrayField extends CtfTmfEventField { return FIELDTYPE_INTEGER_ARRAY; } - @Override - public long[] getValue() { + /** + * Gets the values of the array + * @return the values in the array + * + * @since 2.0 + */ + long[] getLongValues() { return this.longValues; } + @Override + public List getValue() { + List retVal = new ArrayList(); + for( Long l : longValues){ + retVal.add(l); + } + return retVal; + } + @Override public String toString() { StringBuffer buffer = new StringBuffer(); - buffer.append("{ "); //$NON-NLS-1$ - - buffer.append(longValues[0]); - for (int i = 1; i < longValues.length; i++) { - buffer.append(", " + longValues[i]); //$NON-NLS-1$ - } - buffer.append('}'); - return name + '=' + buffer.toString(); + buffer.append(name); + buffer.append('='); + buffer.append(getValue()); + return buffer.toString(); } } -- 2.34.1