From 4c564a2d2fd41e25d274aea485bfc8c890af6ba1 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Tue, 14 Feb 2012 15:57:55 -0500 Subject: [PATCH] Implement the new TMF Event Model --- .../tests/event/LttngEventContentTest.java | 16 +- .../core/tests/event/LttngEventFieldTest.java | 15 +- .../core/tests/event/LttngEventTest.java | 6 +- .../core/tests/event/LttngEventTypeTest.java | 10 +- .../tests/state/handlers/AbsStateUpdate.java | 6 +- .../state/tests/handlers/AbsStateUpdate.java | 6 +- .../lttng/core/event/LttngEventContent.java | 118 +++---- .../lttng/core/event/LttngEventField.java | 71 ++-- .../lttng/core/event/LttngEventType.java | 6 +- .../core/model/LTTngTreeNodeGeneric.java | 5 +- .../evProcessor/state/AbsStateProcessing.java | 2 +- .../lttng/core/trace/LTTngTextTrace.java | 19 +- .../lttng/ui/views/events/EventsTable.java | 20 +- .../tmf/core/tests/event/AllTests.java | 1 - .../core/tests/event/TmfEventContentTest.java | 315 ------------------ .../core/tests/event/TmfEventFieldTest.java | 52 ++- .../tmf/core/tests/event/TmfEventTest.java | 19 +- .../core/tests/event/TmfEventTypeTest.java | 93 +++--- .../TmfAsyncSequenceDiagramEventTest.java | 19 +- .../TmfSyncSequenceDiagramEventTest.java | 12 +- .../stubs/component/TmfDataProviderStub.java | 12 +- .../tmf/stubs/event/TmfEventContentStub.java | 72 ---- .../tmf/stubs/event/TmfEventTypeStub.java | 29 +- .../tmf/stubs/request/TmfDataRequestStub.java | 4 +- .../tmf/stubs/trace/TmfEventParserStub.java | 14 +- .../eclipse/linuxtools/tmf/core/Tracer.java | 4 +- .../tmf/core/component/ITmfDataProvider.java | 4 +- .../tmf/core/component/TmfDataProvider.java | 6 +- .../core/component/TmfProviderManager.java | 32 +- .../tmf/core/event/ITmfDataItem.java | 69 ---- .../linuxtools/tmf/core/event/ITmfEvent.java | 63 +++- .../tmf/core/event/ITmfEventContent.java | 57 ---- .../tmf/core/event/ITmfEventField.java | 33 +- .../tmf/core/event/ITmfEventType.java | 32 +- .../tmf/core/event/TmfDataItem.java | 249 -------------- .../linuxtools/tmf/core/event/TmfEvent.java | 184 ++++++++-- .../tmf/core/event/TmfEventContent.java | 238 ------------- .../tmf/core/event/TmfEventField.java | 151 ++++++--- .../tmf/core/event/TmfEventType.java | 129 ++----- .../tmf/core/event/TmfEventTypeManager.java | 4 +- .../core/event/TmfNoSuchFieldException.java | 30 -- .../tmf/core/event/TmfSimpleTimestamp.java | 2 +- .../tmf/core/event/TmfTimeRange.java | 4 +- .../tmf/core/event/TmfTimestamp.java | 6 +- .../filter/model/TmfFilterCompareNode.java | 77 +++-- .../filter/model/TmfFilterContainsNode.java | 25 +- .../filter/model/TmfFilterEqualsNode.java | 31 +- .../filter/model/TmfFilterEventTypeNode.java | 2 +- .../filter/model/TmfFilterMatchesNode.java | 23 +- .../tmf/core/request/ITmfDataRequest.java | 4 +- .../core/request/TmfCoalescedDataRequest.java | 4 +- .../tmf/core/request/TmfDataRequest.java | 4 +- .../TmfBaseColumnDataProviderTest.java | 21 +- .../statistics/TmfBaseStatisticsDataTest.java | 25 +- .../statistics/TmfStatisticsTreeNodeTest.java | 21 +- .../TmfTreeContentProviderTest.java | 15 +- .../uml2sd/trace/TmfUml2SDTestTrace.java | 29 +- .../tmf/ui/parsers/custom/CustomEvent.java | 4 +- .../ui/parsers/custom/CustomEventContent.java | 32 +- .../ui/parsers/custom/CustomEventType.java | 15 +- .../tmf/ui/parsers/custom/CustomTxtTrace.java | 2 +- .../tmf/ui/parsers/custom/CustomXmlTrace.java | 2 +- .../tmf/ui/viewers/events/TmfEventsTable.java | 24 +- .../tmf/ui/views/filter/FilterViewer.java | 4 +- .../uml2sd/impl/TmfUml2SDSyncLoader.java | 29 +- 65 files changed, 879 insertions(+), 1753 deletions(-) delete mode 100644 org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventContentTest.java delete mode 100644 org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventContentStub.java delete mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataItem.java delete mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java delete mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfDataItem.java delete mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventContent.java delete mode 100644 org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfNoSuchFieldException.java diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java index d151fa76a1..0467c8328d 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventContentTest.java @@ -101,7 +101,7 @@ public class LttngEventContentTest extends TestCase { LttngEventContent testContent = null; LttngEventContent testContent2 = null; LttngEventField[] testFields = new LttngEventField[1]; - testFields[0] = new LttngEventField(testContent2, "test"); + testFields[0] = new LttngEventField("test"); // Default construction with good argument try { @@ -153,7 +153,7 @@ public class LttngEventContentTest extends TestCase { tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); testContent = prepareToTest(); // getFieldS() - assertNotSame("getFields() returned null!",null,testContent.getFields() ); + assertNotSame("getFields() returned null!", null, testContent.getFields() ); // *** FIXME *** // Depending from the Java version because of the "hashcode()" on String. @@ -161,7 +161,7 @@ public class LttngEventContentTest extends TestCase { // // getField(int) //assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString()); - assertNotSame("getField(int) returned unexpected result!",null, testContent.getField(0).toString()); + assertNotSame("getField(int) returned unexpected result!", null, testContent.getField(0).toString()); // getField(name) @@ -171,7 +171,7 @@ public class LttngEventContentTest extends TestCase { // Test that get event return the correct event assertTrue("getEvent() returned unexpected result!", tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue()); // getType() - assertEquals("getType() returned unexpected result!",firstEventContentType, testContent.getType().toString()); + assertEquals("getType() returned unexpected result!",firstEventContentType, testContent.getEvent().getType().toString()); //*** To test getFields with a fields number >0, we need to move to an event that have some more tmpStream = initializeEventStream(); @@ -189,17 +189,17 @@ public class LttngEventContentTest extends TestCase { // Test that get event return the correct event assertTrue("getEvent() returned unexpected result!",tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue()); // getType() - assertEquals("getType() returned unexpected result!",secondEventContentType, testContent.getType().toString()); + assertEquals("getType() returned unexpected result!",secondEventContentType, testContent.getEvent().getType().toString()); // getFieldS() - assertNotSame("getFields() returned null!",null,testContent.getFields() ); + assertNotSame("getFields() returned null!", null, testContent.getFields() ); // getField(int) assertEquals("getField(int) returned unexpected result!",secondEventContentSecondField, testContent.getField(1).toString()); // getField(name) assertEquals("getField(name) returned unexpected result!",secondEventContentSecondField, testContent.getField(secondEventContentSecondFieldName).toString()); // getRawContent - assertNotSame("getRawContent() returned null!",null, testContent.getMapContent()); + assertNotSame("getRawContent() returned null!", null, testContent.getMapContent()); } @@ -226,7 +226,7 @@ public class LttngEventContentTest extends TestCase { LttngEventType testType = new LttngEventType(); try { - tmpContent.setType(testType); + tmpContent.getEvent().setType(testType); } catch( Exception e) { fail("setType(type) failed!"); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java index 11b4cf81ef..31677ae64b 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventFieldTest.java @@ -13,7 +13,6 @@ import org.eclipse.linuxtools.lttng.core.event.LttngEventContent; import org.eclipse.linuxtools.lttng.core.event.LttngEventField; import org.eclipse.linuxtools.lttng.core.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.core.trace.LTTngTextTrace; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; import org.eclipse.linuxtools.tmf.core.trace.TmfContext; import org.eclipse.linuxtools.tmf.core.trace.TmfLocation; @@ -77,7 +76,7 @@ public class LttngEventFieldTest extends TestCase { // Default construction with good argument try { - testField = new LttngEventField(testContent, "test", "test"); + testField = new LttngEventField("test", "test"); } catch( Exception e) { fail("Default construction failed!"); @@ -85,7 +84,7 @@ public class LttngEventFieldTest extends TestCase { // Copy constructor with correct parameters try { - testField = new LttngEventField(testContent, "test", "test"); + testField = new LttngEventField("test", "test"); testField2 = new LttngEventField(testField); } catch( Exception e) { @@ -100,11 +99,11 @@ public class LttngEventFieldTest extends TestCase { LTTngTextTrace tmpStream = initializeEventStream(); LttngEventField testField = null; - try { +// try { testField = (LttngEventField) tmpStream.getNextEvent( new TmfContext(new TmfLocation(0L), 0) ).getContent().getField(0); - } catch (TmfNoSuchFieldException e) { - e.printStackTrace(); - } +// } catch (TmfNoSuchFieldException e) { +// e.printStackTrace(); +// } assertNotSame("getField is null!", null, testField); // *** FIXME *** @@ -112,7 +111,7 @@ public class LttngEventFieldTest extends TestCase { // We can't really test that safetly // //assertTrue("getName() returned unexpected result!",firstEventName.equals(testField.getId().toString())); - assertNotSame("getName() returned unexpected result!",null, testField.getId()); + assertNotSame("getName() returned unexpected result!",null, testField.getName()); assertTrue("getValue() returned unexpected result!",firstEventValue.equals(testField.getValue().toString())); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java index 59e465462b..7ad8b7c1ea 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTest.java @@ -105,7 +105,7 @@ public class LttngEventTest extends TestCase { try { // In order to test LttngEvent, we need all these constructors/functions to work. // Make sure to run their unit tests first! - testMarkerFields = new String[1]; + testMarkerFields = new String[] { "test" }; testEvent = null; testTime = new LttngTimestamp(0L); testSource = "test"; @@ -154,7 +154,7 @@ public class LttngEventTest extends TestCase { assertEquals("Reference not what expected!", eventReference, testEvent.getReference()); // These should be overridden functions - assertEquals("Type not what expected!",eventType,testEvent.getType().getId()); + assertEquals("Type not what expected!",eventType,testEvent.getType().getName()); assertEquals("Channel not what expected!",eventChannel,testEvent.getChannelName()); assertEquals("CpuId not what expected!",eventCpu,testEvent.getCpuId()); assertEquals("Marker not what expected!",eventMarker,testEvent.getMarkerName()); @@ -177,7 +177,7 @@ public class LttngEventTest extends TestCase { LttngEventContent testContent = null; JniEvent testJniEvent = null; - String[] testMarkerFields = new String[1]; + String[] testMarkerFields = new String[] { "test" }; testType = new LttngEventType("test", 0L, "test", 0, testMarkerFields); testContent = new LttngEventContent(testEvent); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java index c00d487ff4..b149e250f1 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/event/LttngEventTypeTest.java @@ -85,18 +85,18 @@ public class LttngEventTypeTest extends TestCase { // Default construction with good arguments try { - tmpEventType = new LttngEventType("test", 0L, "test", 0, new String[1]); + tmpEventType = new LttngEventType("test", 0L, "test", 0, new String[] { "test" }); } - catch( Exception e) { + catch (Exception e) { fail("Construction failed!"); } // Copy constructor try { - tmpEventType = new LttngEventType("test", 0L, "test", 0, new String[1]); + tmpEventType = new LttngEventType("test", 0L, "test", 0, new String[] { "test" }); tmpEventType2 = new LttngEventType(tmpEventType); } - catch( Exception e) { + catch (Exception e) { fail("Construction failed!"); } } @@ -109,7 +109,7 @@ public class LttngEventTypeTest extends TestCase { assertTrue("Cpu Id not what was expected!",firstEventCpu == tmpEventType.getCpuId() ); assertTrue("Marker Name not what was expected!",firstEventMarker.equals((String)tmpEventType.getMarkerName()) ); // Just test the non-nullity of labels - assertNotSame("getLabels returned null",null, tmpEventType.getFieldLabels() ); + assertNotSame("getLabels returned null",null, tmpEventType.getFieldNames() ); } public void testToString() { diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/handlers/AbsStateUpdate.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/handlers/AbsStateUpdate.java index ec7c2b9122..2853e3bf3a 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/handlers/AbsStateUpdate.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/handlers/AbsStateUpdate.java @@ -273,7 +273,7 @@ public abstract class AbsStateUpdate implements ILttngEventProcessor { String expectedFieldName = expectedField.getInName(); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - fieldname = field.getId(); + fieldname = field.getName(); if (fieldname.equals(expectedFieldName)) { Object fieldObj = field.getValue(); if (fieldObj instanceof Long) { @@ -328,7 +328,7 @@ public abstract class AbsStateUpdate implements ILttngEventProcessor { String expectedFieldName = expectedField.getInName(); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - fieldname = field.getId(); + fieldname = field.getName(); if (fieldname.equals(expectedFieldName)) { Object fieldObj = field.getValue(); if (fieldObj instanceof String) { @@ -362,7 +362,7 @@ public abstract class AbsStateUpdate implements ILttngEventProcessor { sb.append(" number of fields: " + fields.length + "Fields: "); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - sb.append(field.getId() + " "); + sb.append(field.getName() + " "); } TraceDebug.debug(sb.toString(), 5); diff --git a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/tests/handlers/AbsStateUpdate.java b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/tests/handlers/AbsStateUpdate.java index c1da336262..7185761735 100644 --- a/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/tests/handlers/AbsStateUpdate.java +++ b/org.eclipse.linuxtools.lttng.core.tests/src/org/eclipse/linuxtools/lttng/core/tests/state/tests/handlers/AbsStateUpdate.java @@ -273,7 +273,7 @@ public abstract class AbsStateUpdate implements ILttngEventProcessor { String expectedFieldName = expectedField.getInName(); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - fieldname = field.getId(); + fieldname = field.getName(); if (fieldname.equals(expectedFieldName)) { Object fieldObj = field.getValue(); if (fieldObj instanceof Long) { @@ -328,7 +328,7 @@ public abstract class AbsStateUpdate implements ILttngEventProcessor { String expectedFieldName = expectedField.getInName(); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - fieldname = field.getId(); + fieldname = field.getName(); if (fieldname.equals(expectedFieldName)) { Object fieldObj = field.getValue(); if (fieldObj instanceof String) { @@ -362,7 +362,7 @@ public abstract class AbsStateUpdate implements ILttngEventProcessor { sb.append(" number of fields: " + fields.length + "Fields: "); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - sb.append(field.getId() + " "); + sb.append(field.getName() + " "); } TraceDebug.debug(sb.toString(), 5); diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventContent.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventContent.java index c1555bbaa4..2c8e36f215 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventContent.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventContent.java @@ -15,26 +15,28 @@ package org.eclipse.linuxtools.lttng.core.event; import java.util.HashMap; import org.eclipse.linuxtools.lttng.jni.JniEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; +import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; /** * LttngEventContent

* * Lttng specific implementation of the TmfEventContent.

*/ -public class LttngEventContent extends TmfEventContent { +public class LttngEventContent extends TmfEventField { + + private LttngEvent fParentEvent; // Hash map that contain the (parsed) fields. This is the actual payload of the event. - HashMap fFieldsMap = new HashMap(); + private HashMap fFieldsMap = new HashMap(); /** * Default constructor.

* - * */ public LttngEventContent() { - super(null, null); + super(ITmfEventField.ROOT_ID, null); } /** @@ -45,7 +47,8 @@ public class LttngEventContent extends TmfEventContent { * @see org.eclipse.linuxtools.lttng.core.event.LttngEvent */ public LttngEventContent(LttngEvent thisParent) { - super(thisParent, null); + super(ITmfEventField.ROOT_ID, null); + fParentEvent = thisParent; } /** @@ -57,8 +60,8 @@ public class LttngEventContent extends TmfEventContent { * @see org.eclipse.linuxtools.lttng.core.event.LttngEvent */ public LttngEventContent(LttngEvent thisParent, HashMap thisContent) { - super(thisParent, null); - + super(ITmfEventField.ROOT_ID, null); + fParentEvent = thisParent; fFieldsMap = thisContent; } @@ -68,13 +71,11 @@ public class LttngEventContent extends TmfEventContent { * @param oldContent Content to copy from */ public LttngEventContent(LttngEventContent oldContent) { - this((LttngEvent)oldContent.getEvent(), oldContent.getMapContent() ); + this((LttngEvent) oldContent.getEvent(), oldContent.getMapContent()); } - - @Override public LttngEvent getEvent() { - return (LttngEvent)fParentEvent; + return fParentEvent; } public void setEvent(LttngEvent newParent) { @@ -84,13 +85,14 @@ public class LttngEventContent extends TmfEventContent { // *** VERIFY *** // These are not very useful, are they? - @Override - public LttngEventType getType() { - return (LttngEventType)fParentEvent.getType(); - } - public void setType(LttngEventType newType) { - ((LttngEvent)fParentEvent).setType(newType); - } + +// public LttngEventType getType() { +// return (LttngEventType)fParentEvent.getType(); +// } + +// public void setType(LttngEventType newType) { +// ((LttngEvent)fParentEvent).setType(newType); +// } // ***TODO*** @@ -107,10 +109,8 @@ public class LttngEventContent extends TmfEventContent { * * @return Currently parsed fields. */ - @Override public Object[] getRawContent() { - Object[] returnedContent = fFieldsMap.values().toArray( new Object[fFieldsMap.size()] ); - + Object[] returnedContent = fFieldsMap.values().toArray(new Object[fFieldsMap.size()]); return returnedContent; } @@ -155,11 +155,13 @@ public class LttngEventContent extends TmfEventContent { */ @Override public synchronized LttngEventField[] getFields() { - if (fFieldsMap.size() < fParentEvent.getType().getNbFields()) { + int nbFields = fParentEvent.getType().getFieldNames().length; + + if (fFieldsMap.size() < nbFields) { LttngEventField tmpField = null; LttngEventType tmpType = (LttngEventType)fParentEvent.getType(); - for ( int pos=0; pos(); for (String key : fFieldsMap.keySet()) { clone.fFieldsMap.put(new String(key), ((LttngEventField) fFieldsMap.get(key)).clone()); diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventField.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventField.java index 0950e50ace..4033277801 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventField.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventField.java @@ -12,8 +12,6 @@ package org.eclipse.linuxtools.lttng.core.event; -import org.eclipse.linuxtools.tmf.core.event.ITmfEventContent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; /** @@ -25,49 +23,32 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; * mean the fields will have a name and a value. */ public class LttngEventField extends TmfEventField { - - /** - * Constructor with parameters.

- * - * @param parent Parent content for this field - * @param id Name (label) of this field - */ - public LttngEventField(TmfEventContent parent, String id) { - super(parent, id, null); + + public LttngEventField(String name, Object value, LttngEventField[] subfields) { + super(name, value, subfields); + } + + public LttngEventField(String name, Object value) { + this(name, value, null); } - /** - * Constructor with parameters with optional value.

- * - * @param parent Parent content for this field - * @param id Name (label) of this field - * @param value Parsed value (payload) of this field - */ - public LttngEventField(ITmfEventContent parent, String id, Object value) { - super(parent, id, value); - } - - /** - * Copy constructor.

- * - * @param oldField the field to copy from - */ - public LttngEventField(LttngEventField oldField) { - this(oldField.getContent(), oldField.getId(), oldField.getValue()); - } - - @Override - @SuppressWarnings("nls") - public String toString() { - Object value = getValue(); - return getId() + ":" + ((value != null) ? value.toString() : "null"); - } - - @Override - public LttngEventField clone() { - LttngEventField clone = (LttngEventField) super.clone(); - clone.fValue = fValue; - return clone; - } - + public LttngEventField(String name) { + this(name, null, null); + } + + public LttngEventField(LttngEventField field) { + super(field); + } + + @Override + public LttngEventField clone() { + LttngEventField clone = null; + clone = (LttngEventField) super.clone(); + return clone; + } + + @Override + public String toString() { + return getName() + ":" + getValue(); //$NON-NLS-1$ + } } diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventType.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventType.java index 8b92f1483f..55fee284f0 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventType.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/event/LttngEventType.java @@ -53,7 +53,7 @@ public class LttngEventType extends TmfEventType { * */ public LttngEventType(String typeId, String[] labels) { - super(DEFAULT_CONTEXT, typeId, labels); + super(DEFAULT_CONTEXT, typeId, TmfEventField.makeRoot(labels)); } /** @@ -64,7 +64,7 @@ public class LttngEventType extends TmfEventType { * @param thisMarkerfieldsName MarkerFields related to this marker */ public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, int thisMarkerId, String[] thisMarkerfieldsName) { - super(DEFAULT_CONTEXT, thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, thisMarkerfieldsName); //$NON-NLS-1$ //$NON-NLS-2$ + super(DEFAULT_CONTEXT, thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, TmfEventField.makeRoot(thisMarkerfieldsName)); //$NON-NLS-1$ //$NON-NLS-2$ tracefileName = thisTracefileName; cpuId = thisCpuId; @@ -78,7 +78,7 @@ public class LttngEventType extends TmfEventType { * @param oldType Type we want to copy from */ public LttngEventType(LttngEventType oldType) { - this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.markerId, oldType.getFieldLabels()); + this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.markerId, oldType.getFieldNames()); } diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/model/LTTngTreeNodeGeneric.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/model/LTTngTreeNodeGeneric.java index 451f89da45..06dd109cd1 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/model/LTTngTreeNodeGeneric.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/model/LTTngTreeNodeGeneric.java @@ -17,11 +17,10 @@ import java.util.Map; import org.eclipse.linuxtools.lttng.core.LttngConstants; import org.eclipse.linuxtools.lttng.core.TraceDebug; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; -import org.eclipse.linuxtools.tmf.core.event.TmfEventType; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; public abstract class LTTngTreeNodeGeneric> - extends TmfDataItem implements ILTTngTreeNode { + extends TmfEvent implements ILTTngTreeNode { // ======================================================================== // Data diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/state/evProcessor/state/AbsStateProcessing.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/state/evProcessor/state/AbsStateProcessing.java index 00ce0efaac..14bf792305 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/state/evProcessor/state/AbsStateProcessing.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/state/evProcessor/state/AbsStateProcessing.java @@ -201,7 +201,7 @@ public abstract class AbsStateProcessing { sb.append(" number of fields: " + fields.length + "Fields: "); for (int i = 0; i < fields.length; i++) { field = (LttngEventField) fields[i]; - sb.append(field.getId() + " "); + sb.append(field.getName() + " "); } TraceDebug.debug(sb.toString(), 5); diff --git a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java index 482c280d6c..2881e964e2 100644 --- a/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java +++ b/org.eclipse.linuxtools.lttng.core/src/org/eclipse/linuxtools/lttng/core/trace/LTTngTextTrace.java @@ -23,7 +23,6 @@ import org.eclipse.linuxtools.lttng.core.event.LttngEventField; import org.eclipse.linuxtools.lttng.core.event.LttngEventType; import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp; import org.eclipse.linuxtools.lttng.jni.JniEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint; @@ -373,7 +372,7 @@ public class LTTngTextTrace extends TmfTrace { } catch (NumberFormatException e) { } - LttngEventField tmpField = new LttngEventField(eventContent, markerName, payload); + LttngEventField tmpField = new LttngEventField(markerName, payload); fieldsMap.put(markerName, tmpField); tmpIndexBegin = tmpIndexEnd+1; @@ -385,7 +384,7 @@ public class LTTngTextTrace extends TmfTrace { markerName = ""; //$NON-NLS-1$ payload = ""; //$NON-NLS-1$ - LttngEventField tmpField = new LttngEventField(eventContent, markerName, payload); + LttngEventField tmpField = new LttngEventField(markerName, payload); fieldsMap.put(markerName, tmpField); } @@ -494,7 +493,7 @@ class TextLttngEventContent extends LttngEventContent { } public TextLttngEventContent(TextLttngEventContent oldContent) { - this( (TextLttngEvent)oldContent.fParentEvent, oldContent.getMapContent()); + this(((TextLttngEvent) oldContent.getEvent()), oldContent.getMapContent()); } @Override @@ -513,13 +512,13 @@ class TextLttngEventContent extends LttngEventContent { public LttngEventField getField(int position) { LttngEventField returnedField = null; String label = null; - try { - label = fParentEvent.getType().getFieldLabel(position); +// try { + label = getEvent().getType().getFieldName(position); returnedField = this.getField(label); - } - catch (TmfNoSuchFieldException e) { - System.out.println("Invalid field position requested : " + position + ", ignoring (getField)."); //$NON-NLS-1$ //$NON-NLS-2$ - } +// } +// catch (TmfNoSuchFieldException e) { +// System.out.println("Invalid field position requested : " + position + ", ignoring (getField)."); //$NON-NLS-1$ //$NON-NLS-2$ +// } return returnedField; } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java index 2c6388df59..7a4deab4d7 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/events/EventsTable.java @@ -13,9 +13,8 @@ package org.eclipse.linuxtools.lttng.ui.views.events; -import org.eclipse.linuxtools.tmf.core.event.ITmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData; @@ -53,10 +52,10 @@ public class EventsTable extends TmfEventsTable { public EventsTable(Composite parent, int cacheSize) { super(parent, cacheSize, COLUMN_DATA); - fTable.getColumns()[0].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TIMESTAMP); - fTable.getColumns()[1].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_REFERENCE); - fTable.getColumns()[2].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TYPE); - fTable.getColumns()[3].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_CONTENT); + fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP); + fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE); + fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE); + fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT); } /** @@ -67,12 +66,11 @@ public class EventsTable extends TmfEventsTable { protected TmfEventField[] extractItemFields(TmfEvent event) { TmfEventField[] fields = new TmfEventField[0]; if (event != null) { - ITmfEventContent content = event.getContent(); fields = new TmfEventField[] { - new TmfEventField(content, TmfEventContent.FIELD_ID_TIMESTAMP, ((Long) event.getTimestamp().getValue()).toString()), - new TmfEventField(content, TmfEventContent.FIELD_ID_REFERENCE, event.getReference()), - new TmfEventField(content, TmfEventContent.FIELD_ID_TYPE, event.getType().getId()), - new TmfEventField(content, TmfEventContent.FIELD_ID_CONTENT, event.getContent().toString()) + new TmfEventField(ITmfEvent.EVENT_FIELD_TIMESTAMP, ((Long) event.getTimestamp().getValue()).toString()), + new TmfEventField(ITmfEvent.EVENT_FIELD_REFERENCE, event.getReference()), + new TmfEventField(ITmfEvent.EVENT_FIELD_TYPE, event.getType().getName()), + new TmfEventField(ITmfEvent.EVENT_FIELD_CONTENT, event.getContent().toString()) }; } return fields; diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java index 9c4b23ed95..4ced46a711 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java @@ -12,7 +12,6 @@ public class AllTests { TestSuite suite = new TestSuite("Test suite for " + TmfCorePlugin.PLUGIN_ID + ".event"); //$NON-NLS-1$); //$JUnit-BEGIN$ suite.addTestSuite(TmfEventFieldTest.class); - suite.addTestSuite(TmfEventContentTest.class); suite.addTestSuite(TmfEventTypeTest.class); suite.addTestSuite(TmfTimestampTest.class); suite.addTestSuite(TmfTimeRangeTest.class); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventContentTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventContentTest.java deleted file mode 100644 index ac49384774..0000000000 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventContentTest.java +++ /dev/null @@ -1,315 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.tests.event; - -import junit.framework.TestCase; - -import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventField; -import org.eclipse.linuxtools.tmf.core.event.TmfEventType; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; -import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.stubs.event.TmfEventContentStub; -import org.eclipse.linuxtools.tmf.stubs.event.TmfEventTypeStub; - -/** - * TmfEventContentTest - *

- * Test suite for the TmfEventContent class. - */ -@SuppressWarnings("nls") -public class TmfEventContentTest extends TestCase { - - // ------------------------------------------------------------------------ - // Variables - // ------------------------------------------------------------------------ - - private final TmfTimestamp fTimestamp; - private final String fEventSource; - private final TmfEventType fEventType; - private final TmfEventTypeStub fEventTypeStub; - private final String fReference; - private final TmfEvent fEvent; - private final TmfEvent fEventStub; - - private final String fRawContent0 = "Some content"; - private final String fRawContent1 = "Some other content"; - - private final TmfEventContent fBasicContent0; - private final TmfEventContent fBasicContent1; - private final TmfEventContent fBasicContent2; - private final TmfEventContentStub fStubContent; - - // ------------------------------------------------------------------------ - // Housekeeping - // ------------------------------------------------------------------------ - - /** - * @param name the test name - */ - public TmfEventContentTest(String name) { - super(name); - fTimestamp = new TmfTimestamp(); - fEventSource = ""; - fEventType = new TmfEventTypeStub(); - fEventTypeStub = new TmfEventTypeStub(); - fReference = ""; - - fEvent = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference); - fBasicContent0 = new TmfEventContent(fEvent, fRawContent0); - fBasicContent1 = new TmfEventContent(fEvent, fRawContent0); - fBasicContent2 = new TmfEventContent(fEvent, fRawContent0); - - fEventStub = new TmfEvent(fTimestamp, fEventSource, fEventTypeStub, fReference); - fStubContent = new TmfEventContentStub(fEventStub, fRawContent1); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - public void testTmfEventContent() { - assertSame("getLabels", fEvent, fBasicContent0.getEvent()); - assertEquals("getType", fEventType, fBasicContent0.getType()); - assertEquals("getContent", fRawContent0, fBasicContent0.getRawContent()); - } - - public void testTmfEventContentCopy() { - TmfEventContent content = new TmfEventContent(fBasicContent0); - assertSame("getLabels", fEvent, content.getEvent()); - assertEquals("getType", fEventType, content.getType()); - assertEquals("getContent", fRawContent0, content.getRawContent()); - } - - public void testTmfEventContentCopy2() { - try { - new TmfEventContent(null); - fail("null copy"); - } - catch (IllegalArgumentException e) { - // Success - } - } - -// // ------------------------------------------------------------------------ -// // setEvent -// // ------------------------------------------------------------------------ -// -// public void testSetEvent() { -// TmfEvent event = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference); -// TmfEventContent content1 = new TmfEventContent(event, fRawContent0); -// event.setContent(content1); -// TmfEventContent content2 = new TmfEventContent(null, fRawContent1); -// -// content2.setEvent(event); -// -// assertEquals("setEvent", event, content2.getEvent()); -//// assertEquals("setEvent", content2, event.getContent()); -//// assertEquals("setEvent", null, content1.getEvent()); -// } - - // ------------------------------------------------------------------------ - // equals - // ------------------------------------------------------------------------ - - public void testEqualsReflexivity() throws Exception { - @SuppressWarnings("unused") - Object[] fields1 = fBasicContent0.getFields(); - @SuppressWarnings("unused") - Object[] fields2 = fStubContent.getFields(); - - assertTrue("equals", fBasicContent0.equals(fBasicContent0)); - assertTrue("equals", fStubContent.equals(fStubContent)); - - assertTrue("equals", !fBasicContent0.equals(fStubContent)); - assertTrue("equals", !fStubContent.equals(fBasicContent0)); - } - - public void testEqualsSymmetry() throws Exception { - assertTrue("equals", fBasicContent0.equals(fBasicContent2)); - assertTrue("equals", fBasicContent2.equals(fBasicContent0)); - - assertTrue("equals", !fBasicContent0.equals(fStubContent)); - assertTrue("equals", !fStubContent.equals(fBasicContent0)); - } - - public void testEqualsTransivity() throws Exception { - assertTrue("equals", fBasicContent0.equals(fBasicContent1)); - assertTrue("equals", fBasicContent1.equals(fBasicContent2)); - assertTrue("equals", fBasicContent0.equals(fBasicContent2)); - } - - public void testEqualsNull() throws Exception { - assertTrue("equals", !fBasicContent0.equals(null)); - assertTrue("equals", !fStubContent.equals(null)); - } - - // ------------------------------------------------------------------------ - // hashCode - // ------------------------------------------------------------------------ - - public void testHashCode() throws Exception { - assertTrue("hashCode", fBasicContent0.hashCode() == fBasicContent2.hashCode()); - assertTrue("hashCode", fBasicContent0.hashCode() != fStubContent.hashCode()); - } - - public void testHashCode2() throws Exception { - TmfEventContent basicContent0 = new TmfEventContent(null, fRawContent0); - TmfEventContent basicContent1 = new TmfEventContent(fEvent, null); - TmfEventContent basicContent2 = new TmfEventContent(null, null); - - assertTrue("hashCode", fBasicContent0.hashCode() == basicContent0.hashCode()); - assertTrue("hashCode", fBasicContent0.hashCode() != basicContent1.hashCode()); - assertTrue("hashCode", fBasicContent0.hashCode() != basicContent2.hashCode()); - - assertTrue("hashCode", basicContent0.hashCode() != basicContent1.hashCode()); - assertTrue("hashCode", basicContent0.hashCode() != basicContent2.hashCode()); - - assertTrue("hashCode", basicContent1.hashCode() == basicContent2.hashCode()); - } - - // ------------------------------------------------------------------------ - // toString - // ------------------------------------------------------------------------ - - public void testToString() { - String expected = "TmfEventContent [fRawContent=" + fRawContent0 + ", fFields=null]"; - TmfEventContent content = new TmfEventContent(fEvent, fRawContent0); - assertEquals("toString", expected, content.toString()); - } - - public void testToString2() { - String expected = "TmfEventContent [fRawContent=" + fRawContent0 + ", fFields=null]"; - TmfEventContentStub content = new TmfEventContentStub(fEvent, fRawContent0); - assertEquals("toString", expected, content.toString()); - } - - // ------------------------------------------------------------------------ - // Basic content parsing - // ------------------------------------------------------------------------ - - public void testGetFields() { - TmfEventField expected = new TmfEventField(fBasicContent0, TmfEventContent.FIELD_ID_CONTENT, fRawContent0); - Object[] fields = fBasicContent0.getFields(); - assertEquals("getFields", 1, fields.length); - assertEquals("getFields", expected, fields[0]); - } - -// public void testGetFieldFromId() { -// Object field; -// try { -// field = fStubContent.getField("Content"); -// assertEquals("getField", fRawContent0, field.toString()); -// } catch (TmfNoSuchFieldException e) { -// fail("Field not found"); -// } -// } - - public void testGetFieldFromIdFailed() { - try { - fBasicContent0.getField("Dummy"); - fail("Found an inexisting field..."); - } catch (TmfNoSuchFieldException e) { - // Success - } - } - - public void testGetFieldFromPos() { - String expected = "TmfEventField [fFieldId=" + - TmfEventContent.FIELD_ID_CONTENT + ", fValue=" + fRawContent0 + "]"; - Object field = fBasicContent0.getField(0); - assertEquals("getField", expected, field.toString()); - } - - public void testGetFieldFromPosFailed() { - Object field = fBasicContent0.getField(10); - assertEquals("getField", null, field); - } - - // ------------------------------------------------------------------------ - // Standard content parsing - // ------------------------------------------------------------------------ - - public void testGetFields2() { - Object[] fields = fStubContent.getFields(); - assertEquals("getFields", 5, fields.length); - } - - public void testGetFieldFromId2() { - Object field; - TmfEventField expected; - try { - field = fStubContent.getField("Field1"); - expected = new TmfEventField(fStubContent, "field1", new Integer(1)); - assertEquals("getField", expected, field); - - field = fStubContent.getField("Field2"); - expected = new TmfEventField(fStubContent, "field2", new Integer(-10)); - assertEquals("getField", expected, field); - - field = fStubContent.getField("Field3"); - expected = new TmfEventField(fStubContent, "field3", new Boolean(true)); - assertEquals("getField", expected, field); - - field = fStubContent.getField("Field4"); - expected = new TmfEventField(fStubContent, "field4", "some string"); - assertEquals("getField", expected, field); - - field = fStubContent.getField("Field5"); - expected = new TmfEventField(fStubContent, "field5", new TmfTimestamp(1, 2, 3)); - assertEquals("getField", expected, field); - - } catch (TmfNoSuchFieldException e) { - fail("Field not found"); - } - } - - public void testGetFieldFromPos2() { - TmfEventContentStub content = new TmfEventContentStub(fEvent, fRawContent0); - - Object field; - TmfEventField expected; - - field = content.getField(0); - expected = new TmfEventField(content, "field1", new Integer(1)); - assertEquals("getField", expected, field); - - field = content.getField(1); - expected = new TmfEventField(content, "field2", new Integer(-10)); - assertEquals("getField", expected, field); - - field = content.getField(2); - expected = new TmfEventField(content, "field3", new Boolean(true)); - assertEquals("getField", expected, field); - - field = content.getField(3); - expected = new TmfEventField(content, "field4", "some string"); - assertEquals("getField",expected, field); - - field = content.getField(4); - expected = new TmfEventField(content, "field5", new TmfTimestamp(1, 2, 3)); - assertEquals("getField", expected, field); - } - -} diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java index 18d194bca1..99ffc9ef7e 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventFieldTest.java @@ -14,12 +14,8 @@ package org.eclipse.linuxtools.tmf.core.tests.event; import junit.framework.TestCase; -import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; -import org.eclipse.linuxtools.tmf.core.event.TmfEventType; -import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; -import org.eclipse.linuxtools.tmf.stubs.event.TmfEventTypeStub; /** * TmfEventFieldTest @@ -33,7 +29,6 @@ public class TmfEventFieldTest extends TestCase { // Variables // ------------------------------------------------------------------------ - private final TmfEventContent fContent; private final String fFieldId = "Field"; private final Object fValue1 = new String("Value"); private final Object fValue2 = new Integer(10); @@ -52,18 +47,10 @@ public class TmfEventFieldTest extends TestCase { */ public TmfEventFieldTest(String name) { super(name); - TmfTimestamp fTimestamp = new TmfTimestamp(); - String fEventSource = ""; - TmfEventType fEventType = new TmfEventTypeStub(); - String fReference = ""; - TmfEvent fEvent = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference); - - fContent = new TmfEventContent(fEvent, "Some content"); - - fField0 = new TmfEventField(fContent, fFieldId, fValue1); - fField1 = new TmfEventField(fContent, fFieldId, fValue1); - fField2 = new TmfEventField(fContent, fFieldId, fValue1); - fField3 = new TmfEventField(fContent, fFieldId, fValue2); + fField0 = new TmfEventField(fFieldId, fValue1, null); + fField1 = new TmfEventField(fFieldId, fValue1, null); + fField2 = new TmfEventField(fFieldId, fValue1, null); + fField3 = new TmfEventField(fFieldId, fValue2, null); } @Override @@ -81,14 +68,13 @@ public class TmfEventFieldTest extends TestCase { // ------------------------------------------------------------------------ public void testTmfEventField() { - assertSame("getParent", fContent, fField0.getContent()); - assertSame("getId", fFieldId, fField0.getId()); + assertSame("getId", fFieldId, fField0.getName()); assertSame("getValue", fValue1, fField0.getValue()); } public void testTmfEventFieldBadArg() { try { - new TmfEventField(fContent, null, fValue1); + new TmfEventField(null, fValue1, null); fail("null copy"); } catch (IllegalArgumentException e) { @@ -97,10 +83,9 @@ public class TmfEventFieldTest extends TestCase { } public void testTmfEventFieldCopy() { - TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1); + TmfEventField original = new TmfEventField(fFieldId, fValue1, null); TmfEventField field = new TmfEventField(original); - assertSame("getContent", fContent, field.getContent()); - assertSame("getId", fFieldId, field.getId()); + assertSame("getId", fFieldId, field.getName()); assertSame("getValue", fValue1, field.getValue()); } @@ -119,26 +104,27 @@ public class TmfEventFieldTest extends TestCase { // ------------------------------------------------------------------------ private class MyField extends TmfEventField { - public MyField(TmfEventContent parent, String id, Object value) { - super(parent, id, value); + public MyField(String id, Object value) { + super(id, value); } public MyField(TmfEventField field) { super(field); } @Override - public void setValue(Object value) { - super.setValue(value); + public void setValue(Object value, ITmfEventField[] subfields) { + super.setValue(value, subfields); } } public void testSetValue() { - TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1); +// TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1); + TmfEventField original = new TmfEventField(fFieldId, fValue1, null); TmfEventField field = new TmfEventField(original); MyField myField = new MyField(field); assertSame("getValue", fValue1, myField.getValue()); - myField.setValue(fValue2); + myField.setValue(fValue2, null); assertSame("getValue", fValue2, myField.getValue()); } @@ -188,11 +174,13 @@ public class TmfEventFieldTest extends TestCase { public void testToString() { String expected1 = "TmfEventField [fFieldId=" + fFieldId + ", fValue=" + fValue1.toString() + "]"; - TmfEventField field = new TmfEventField(fContent, fFieldId, fValue1); +// TmfEventField field = new TmfEventField(fContent, fFieldId, fValue1); + TmfEventField field = new TmfEventField(fFieldId, fValue1, null); assertEquals("toString", expected1, field.toString()); String expected2 = "TmfEventField [fFieldId=" + fFieldId + ", fValue=" + fValue2.toString() + "]"; - field = new TmfEventField(fContent, fFieldId, fValue2); +// field = new TmfEventField(fContent, fFieldId, fValue2); + field = new TmfEventField(fFieldId, fValue2, null); assertEquals("toString", expected2, field.toString()); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java index 66658c0201..347e865b04 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTest.java @@ -14,8 +14,9 @@ package org.eclipse.linuxtools.tmf.core.tests.event; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; @@ -40,14 +41,14 @@ public class TmfEventTest extends TestCase { private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5); private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5); private final String fSource = "Source"; - private final TmfEventType fType = new TmfEventType(fContext, fTypeId, fLabels); + private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; private final TmfEvent fEvent1; private final TmfEvent fEvent2; - private final TmfEventContent fContent1; - private final TmfEventContent fContent2; + private final TmfEventField fContent1; + private final TmfEventField fContent2; // ------------------------------------------------------------------------ // Housekeeping @@ -59,13 +60,11 @@ public class TmfEventTest extends TestCase { public TmfEventTest(String name) { super(name); - fEvent1 = new TmfEvent(fTimestamp1, fSource, fType, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); - fEvent1.setContent(fContent1); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); + fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference); - fEvent2 = new TmfEvent(fTimestamp2, fSource, fType, fReference); - fContent2 = new TmfEventContent(fEvent2, "Some other content"); - fEvent2.setContent(fContent2); + fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content"); + fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType, fContent2, fReference); } @Override diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java index 26a292c924..fc4951e97c 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/TmfEventTypeTest.java @@ -14,8 +14,8 @@ package org.eclipse.linuxtools.tmf.core.tests.event; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; /** * TmfEventTypeTest @@ -37,10 +37,10 @@ public class TmfEventTypeTest extends TestCase { private final String[] fLabels1 = new String[] { fLabel0, fLabel1 }; private final String[] fLabels2 = new String[] { fLabel1, fLabel0 }; - private final TmfEventType fType0 = new TmfEventType(fContext, fTypeId, fLabels1); - private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId, fLabels1); - private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId, fLabels1); - private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, fLabels2); + private final TmfEventType fType0 = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels1)); + private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels1)); + private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels1)); + private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels2)); // ------------------------------------------------------------------------ // Housekeeping @@ -69,51 +69,45 @@ public class TmfEventTypeTest extends TestCase { public void testTmfEventTypeDefault() { TmfEventType type = new TmfEventType(); - assertEquals("getTypeId", TmfEventType.DEFAULT_TYPE_ID, type.getId()); - assertEquals("getNbFields", 0, type.getNbFields()); - assertEquals("getLabels", 0, type.getFieldLabels().length); + assertEquals("getTypeId", TmfEventType.DEFAULT_TYPE_ID, type.getName()); + assertNull("getLabels", type.getFieldName(0)); - try { - assertEquals("getFieldIndex", 0, type.getFieldIndex(fLabel0)); - fail("getFieldIndex: no such field"); - assertEquals("getLabel", 0, type.getFieldLabel(0)); - fail("getFieldIndex: no such field"); - } catch (TmfNoSuchFieldException e) { - // Success - } +// assertEquals("getFieldIndex", 0, type.getFieldIndex(fLabel0)); +// fail("getFieldIndex: no such field"); + assertNull("getLabel", type.getFieldName(0)); +// fail("getFieldIndex: no such field"); } public void testTmfEventType() { - TmfEventType type = new TmfEventType(fContext, fTypeId, fLabels1); + TmfEventType type = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels1)); String[] expected = new String[] { fLabel0, fLabel1 }; - try { - assertEquals("getTypeId", fTypeId, type.getId()); - assertEquals("getNbFields", fLabels1.length, type.getNbFields()); - assertEquals("getFieldIndex", 0, type.getFieldIndex(fLabel0)); - assertEquals("getFieldIndex", 1, type.getFieldIndex(fLabel1)); - String[] labels = type.getFieldLabels(); +// try { + assertEquals("getTypeId", fTypeId, type.getName()); +// assertEquals("getFieldIndex", 0, type.getFieldIndex(fLabel0)); +// assertEquals("getFieldIndex", 1, type.getFieldIndex(fLabel1)); + String[] labels = type.getFieldNames(); for (int i = 0; i < labels.length; i++) { assertEquals("getLabels", expected[i], labels[i]); } - assertEquals("getLabel", fLabel0, type.getFieldLabel(0)); - assertEquals("getLabel", fLabel1, type.getFieldLabel(1)); - } catch (TmfNoSuchFieldException e) { - fail("getFieldIndex: no such field"); - } - - try { - assertEquals("getFieldIndex", 0, type.getFieldIndex("Dummy")); - fail("getFieldIndex: inexistant field"); - } catch (TmfNoSuchFieldException e) { - // Success - } - - try { - type.getFieldLabel(10); - fail("getLabel: inexistant field"); - } catch (TmfNoSuchFieldException e) { - // Success - } + assertEquals("getLabel", fLabel0, type.getFieldName(0)); + assertEquals("getLabel", fLabel1, type.getFieldName(1)); +// } catch (TmfNoSuchFieldException e) { +// fail("getFieldIndex: no such field"); +// } + +// try { +// assertEquals("getFieldIndex", 0, type.getFieldIndex("Dummy")); +// fail("getFieldIndex: inexistant field"); +// } catch (TmfNoSuchFieldException e) { +// // Success +// } + +// try { + assertNull(type.getFieldName(10)); +// fail("getLabel: inexistant field"); +// } catch (TmfNoSuchFieldException e) { +// // Success +// } } public void testTmfEventType2() { @@ -135,13 +129,12 @@ public class TmfEventTypeTest extends TestCase { } public void testTmfEventTypeCopy() { - TmfEventType original = new TmfEventType(fContext, fTypeId, fLabels1); + TmfEventType original = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels1)); TmfEventType copy = new TmfEventType(original); String[] expected = new String[] { fLabel0, fLabel1 }; - assertEquals("getTypeId", fTypeId, copy.getId()); - assertEquals("getNbFields", fLabels1.length, copy.getNbFields()); - String[] labels = copy.getFieldLabels(); + assertEquals("getTypeId", fTypeId, copy.getName()); + String[] labels = copy.getFieldNames(); for (int i = 0; i < labels.length; i++) { assertEquals("getLabels", expected[i], labels[i]); } @@ -203,14 +196,12 @@ public class TmfEventTypeTest extends TestCase { public void testToString() { String expected1 = "TmfEventType [fContext=" + TmfEventType.DEFAULT_CONTEXT_ID + - ", fTypeId=" + TmfEventType.DEFAULT_TYPE_ID + - ", fNbFields=0, fFieldLabels=[]]"; + ", fTypeId=" + TmfEventType.DEFAULT_TYPE_ID + "]"; TmfEventType type1 = new TmfEventType(); assertEquals("toString", expected1, type1.toString()); - String expected2 = "TmfEventType [fContext=" + fContext + ", fTypeId=" + fTypeId + - ", fNbFields=2, fFieldLabels=[label1, label2]]"; - TmfEventType type2 = new TmfEventType(fContext, fTypeId, fLabels1); + String expected2 = "TmfEventType [fContext=" + fContext + ", fTypeId=" + fTypeId + "]"; + TmfEventType type2 = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels1)); assertEquals("toString", expected2, type2.toString()); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java index f329fb8fe2..73a2532311 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java @@ -13,8 +13,9 @@ package org.eclipse.linuxtools.tmf.core.tests.uml2sd; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.uml2sd.TmfAsyncSequenceDiagramEvent; @@ -31,23 +32,21 @@ public class TmfAsyncSequenceDiagramEventTest extends TestCase { private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5); private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5); private final String fSource = "Source"; - private final TmfEventType fType = new TmfEventType(fContext, fTypeId, fLabels); + private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; private final TmfEvent fEvent1; private final TmfEvent fEvent2; - private final TmfEventContent fContent1; - private final TmfEventContent fContent2; + private final TmfEventField fContent1; + private final TmfEventField fContent2; public TmfAsyncSequenceDiagramEventTest() { - fEvent1 = new TmfEvent(fTimestamp1, fSource, fType, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); - fEvent1.setContent(fContent1); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); + fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference); - fEvent2 = new TmfEvent(fTimestamp2, fSource, fType, fReference); - fContent2 = new TmfEventContent(fEvent2, "Some other content"); - fEvent2.setContent(fContent2); + fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content"); + fEvent2 = new TmfEvent(null, fTimestamp2, fSource, fType, fContent2, fReference); } @Override diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java index c314099bd8..f20f4a7266 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java @@ -13,8 +13,9 @@ package org.eclipse.linuxtools.tmf.core.tests.uml2sd; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent; @@ -30,16 +31,15 @@ public class TmfSyncSequenceDiagramEventTest extends TestCase { private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5); private final String fSource = "Source"; - private final TmfEventType fType = new TmfEventType(fContext, fTypeId, fLabels); + private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; private final TmfEvent fEvent1; - private final TmfEventContent fContent1; + private final TmfEventField fContent1; public TmfSyncSequenceDiagramEventTest () { - fEvent1 = new TmfEvent(fTimestamp1, fSource, fType, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); - fEvent1.setContent(fContent1); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); + fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference); } @Override diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/component/TmfDataProviderStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/component/TmfDataProviderStub.java index b07f5ff9b1..b25b3ce334 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/component/TmfDataProviderStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/component/TmfDataProviderStub.java @@ -20,7 +20,7 @@ import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin; @@ -33,7 +33,7 @@ import org.eclipse.linuxtools.tmf.stubs.trace.TmfTraceStub; * TODO: Implement me. Please. */ @SuppressWarnings("nls") -public class TmfDataProviderStub extends TmfDataProvider { +public class TmfDataProviderStub extends TmfDataProvider { private static final String DIRECTORY = "testfiles"; private static final String TEST_STREAM = "M-Test-10K"; @@ -41,7 +41,7 @@ public class TmfDataProviderStub extends TmfDataProvider { private TmfTraceStub fTrace; public TmfDataProviderStub(String path) throws IOException { - super("TmfDataProviderStub", TmfDataItem.class); + super("TmfDataProviderStub", TmfEvent.class); URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); try { File test = new File(FileLocator.toFileURL(location).toURI()); @@ -60,7 +60,7 @@ public class TmfDataProviderStub extends TmfDataProvider { // ------------------------------------------------------------------------ @Override - public ITmfContext armRequest(ITmfDataRequest request) { + public ITmfContext armRequest(ITmfDataRequest request) { if (request instanceof ITmfEventRequest) { ITmfContext context = fTrace.seekEvent(((ITmfEventRequest) request).getRange().getStartTime()); return context; @@ -69,12 +69,12 @@ public class TmfDataProviderStub extends TmfDataProvider { } @Override - public TmfDataItem getNext(ITmfContext context) { + public TmfEvent getNext(ITmfContext context) { return fTrace.getNext(context); } @Override - public boolean isCompleted(ITmfDataRequest request, TmfDataItem data, int nbRead) { + public boolean isCompleted(ITmfDataRequest request, TmfEvent data, int nbRead) { return false; } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventContentStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventContentStub.java deleted file mode 100644 index 06ba6ff01c..0000000000 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventContentStub.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.stubs.event; - -import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventField; -import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; - -/** - * TmfEventContentStub - *

- * TODO: Implement me. Please. - */ -@SuppressWarnings("nls") -public class TmfEventContentStub extends TmfEventContent { - - public TmfEventContentStub(TmfEvent parent, String content) { - super(parent, content); - } - - public TmfEventContentStub(TmfEventContentStub other) { - super(other); - } - - @Override - protected void parseContent() { - Object value1 = new Integer(1); - Object value2 = new Integer(-10); - Object value3 = new Boolean(true); - Object value4 = new String("some string"); - Object value5 = new TmfTimestamp(1, (byte) 2, 3); - - TmfEventField field1 = new TmfEventField(this, "field1", value1); - TmfEventField field2 = new TmfEventField(this, "field2", value2); - TmfEventField field3 = new TmfEventField(this, "field3", value3); - TmfEventField field4 = new TmfEventField(this, "field4", value4); - TmfEventField field5 = new TmfEventField(this, "field5", value5); - - fFields = new TmfEventField[] { field1, field2, field3, field4, field5 }; - } - - @Override - public TmfEventContent clone() { - TmfEventContentStub content = new TmfEventContentStub(this); - content.fRawContent = "Some content"; - content.fFields = null; - return content; - } - -// @Override -// public String toString() { -// Object[] fields = getFields(); -// StringBuilder result = new StringBuilder("[TmfEventContent("); -// for (int i = 0; i < fields.length; i++) { -// if (i > 0) result.append(","); -// result.append(fields[i]); -// } -// result.append(")]"); -// return result.toString(); -// } -} diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventTypeStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventTypeStub.java index 5956bdbdda..b2844d75ae 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventTypeStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/event/TmfEventTypeStub.java @@ -1,17 +1,18 @@ /******************************************************************************* * Copyright (c) 2009 Ericsson * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which + * 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 * - * Contributors: - * Francois Chouinard - Initial API and implementation + * Contributors: Francois Chouinard - Initial API and implementation *******************************************************************************/ package org.eclipse.linuxtools.tmf.stubs.event; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; /** @@ -22,14 +23,18 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventType; @SuppressWarnings("nls") public class TmfEventTypeStub extends TmfEventType { - private static final String FIELD_1 = "Field1"; - private static final String FIELD_2 = "Field2"; - private static final String FIELD_3 = "Field3"; - private static final String FIELD_4 = "Field4"; - private static final String FIELD_5 = "Field5"; - private static final String[] FIELDS = new String[] { FIELD_1, FIELD_2, FIELD_3, FIELD_4, FIELD_5 }; + private static final ITmfEventField FIELD_1 = new TmfEventField("Field1", null); + private static final ITmfEventField FIELD_2 = new TmfEventField("Field2", null); + private static final ITmfEventField FIELD_3 = new TmfEventField("Field3", null); + private static final ITmfEventField FIELD_4 = new TmfEventField("Field4", null); + private static final ITmfEventField FIELD_5 = new TmfEventField("Field5", null); - public TmfEventTypeStub() { - super("UnitTest", "TmfEventTypeStub", FIELDS); + private static final ITmfEventField[] FIELDS = new ITmfEventField[] { + FIELD_1, FIELD_2, FIELD_3, FIELD_4, FIELD_5 }; + + private static ITmfEventField ROOT = new TmfEventField(ITmfEventField.ROOT_ID, FIELDS); + + public TmfEventTypeStub() { + super("UnitTest", "TmfEventTypeStub", ROOT); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/request/TmfDataRequestStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/request/TmfDataRequestStub.java index 0a21917a10..4ef8e8986a 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/request/TmfDataRequestStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/request/TmfDataRequestStub.java @@ -12,7 +12,7 @@ package org.eclipse.linuxtools.tmf.stubs.request; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; /** @@ -20,7 +20,7 @@ import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; *

* TODO: Implement me. Please. */ -public class TmfDataRequestStub extends TmfDataRequest { +public class TmfDataRequestStub extends TmfDataRequest { /** * Default constructor diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java index d5c87f5e1a..d78bf8408b 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java +++ b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/stubs/trace/TmfEventParserStub.java @@ -17,8 +17,9 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.util.Vector; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser; @@ -54,7 +55,8 @@ public class TmfEventParserStub implements ITmfEventParser { fields.add(field); } String[] fieldArray = new String[i]; - fTypes[i] = new TmfEventType("UnitTest", "Type-" + i, fields.toArray(fieldArray)); + ITmfEventField rootField = TmfEventField.makeRoot(fields.toArray(fieldArray)); + fTypes[i] = new TmfEventType("UnitTest", "Type-" + i, rootField); } } @@ -104,11 +106,11 @@ public class TmfEventParserStub implements ITmfEventParser { } content += "]"; - TmfEvent event = new TmfEvent( + TmfEventField root = new TmfEventField(ITmfEventField.ROOT_ID, content); + TmfEvent event = new TmfEvent(eventStream, new TmfTimestamp(ts, (byte) -3, 0), // millisecs - source, fTypes[typeIndex], name); - TmfEventContent cnt = new TmfEventContent(event, content); - event.setContent(cnt); + source, fTypes[typeIndex], root, name); + event.setContent(root); return event; } catch (EOFException e) { } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/Tracer.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/Tracer.java index 5ab7113091..b2f02fa90c 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/Tracer.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/Tracer.java @@ -7,7 +7,7 @@ import java.io.IOException; import org.eclipse.core.runtime.Platform; import org.eclipse.linuxtools.tmf.core.component.ITmfComponent; import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; import org.eclipse.linuxtools.tmf.core.signal.TmfSignal; @@ -171,7 +171,7 @@ public class Tracer { trace(message); } - public static void traceEvent(ITmfDataProvider provider, ITmfDataRequest request, TmfDataItem data) { + public static void traceEvent(ITmfDataProvider provider, ITmfDataRequest request, TmfEvent data) { String message = ("[EVT] Provider=" + provider.toString() + ", Req=" + request.getRequestId() + ", Event=" + data .toString()); trace(message); diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java index b0d2cf1115..68b1780491 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java @@ -12,7 +12,7 @@ package org.eclipse.linuxtools.tmf.core.component; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; /** @@ -20,7 +20,7 @@ import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; *

* TODO: Implement me. Please. */ -public interface ITmfDataProvider { +public interface ITmfDataProvider { /** * Queues the request for processing. diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java index 37de48768f..d76f32886b 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java @@ -18,12 +18,12 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.SynchronousQueue; import org.eclipse.linuxtools.tmf.core.Tracer; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; +import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType; import org.eclipse.linuxtools.tmf.core.request.TmfCoalescedDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfRequestExecutor; -import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType; import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal; @@ -42,7 +42,7 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; *

* TODO: Add support for providing multiple data types. */ -public abstract class TmfDataProvider extends TmfComponent implements ITmfDataProvider { +public abstract class TmfDataProvider extends TmfComponent implements ITmfDataProvider { // ------------------------------------------------------------------------ // Constants diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfProviderManager.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfProviderManager.java index be5da1369e..cc7c3cbe45 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfProviderManager.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfProviderManager.java @@ -17,7 +17,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; /** * TmfProviderManager.java @@ -36,8 +36,8 @@ public class TmfProviderManager { // Keeps track of the providers for each event type // ------------------------------------------------------------------------ - private static Map, List>> fProviders = - new HashMap, List>>(); + private static Map, List>> fProviders = + new HashMap, List>>(); /** * Registers [provider] as a provider of [eventType] @@ -45,9 +45,9 @@ public class TmfProviderManager { * @param eventType * @param provider */ - public static void register(Class eventType, TmfDataProvider provider) { + public static void register(Class eventType, TmfDataProvider provider) { if (fProviders.get(eventType) == null) - fProviders.put(eventType, new ArrayList>()); + fProviders.put(eventType, new ArrayList>()); fProviders.get(eventType).add(provider); } @@ -57,8 +57,8 @@ public class TmfProviderManager { * @param dataClass * @param provider */ - public static void deregister(Class dataClass, TmfDataProvider provider) { - List> list = fProviders.get(dataClass); + public static void deregister(Class dataClass, TmfDataProvider provider) { + List> list = fProviders.get(dataClass); if (list != null) { list.remove(provider); if (list.size() == 0) @@ -73,11 +73,11 @@ public class TmfProviderManager { * @return */ @SuppressWarnings("unchecked") - public static TmfDataProvider[] getProviders(Class dataClass) { - List> list = fProviders.get(dataClass); + public static TmfDataProvider[] getProviders(Class dataClass) { + List> list = fProviders.get(dataClass); if (list == null) - list = new ArrayList>(); - TmfDataProvider[] result = new TmfDataProvider[list.size()]; + list = new ArrayList>(); + TmfDataProvider[] result = new TmfDataProvider[list.size()]; return list.toArray(result); } @@ -89,20 +89,20 @@ public class TmfProviderManager { * @return */ @SuppressWarnings("unchecked") - public static TmfDataProvider[] getProviders(Class dataClass, Class> providerClass) { + public static TmfDataProvider[] getProviders(Class dataClass, Class> providerClass) { if (providerClass == null) { return getProviders(dataClass); } - TmfDataProvider[] list = getProviders(dataClass); - List> result = new ArrayList>(); + TmfDataProvider[] list = getProviders(dataClass); + List> result = new ArrayList>(); if (list != null) { - for (TmfDataProvider provider : list) { + for (TmfDataProvider provider : list) { if (provider.getClass() == providerClass) { result.add(provider); } } } - TmfDataProvider[] array = new TmfDataProvider[result.size()]; + TmfDataProvider[] array = new TmfDataProvider[result.size()]; return result.toArray(array); } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataItem.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataItem.java deleted file mode 100644 index f6d34278af..0000000000 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfDataItem.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.event; - -import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; - -/** - * ITmfDataItem - *

- * The basic event structure in the TMF. In its canonical form, a data item has: - *

- * For convenience, a free-form reference field is also provided. It could be - * used as e.g. a location marker (filename:lineno) to indicate where the event - * was generated. - */ -public interface ITmfDataItem extends Cloneable { - - /** - * @return the trace that 'owns' the event - */ - public ITmfTrace getTrace(); - - /** - * @return the event rank within the parent trace - */ - public long getRank(); - - /** - * @return the event source - */ - public String getSource(); - - /** - * @return the event type - */ - public ITmfEventType getType(); - - /** - * @return the event content - */ - public ITmfEventContent getContent(); - - /** - * @return the event reference - */ - public String getReference(); - - /** - * @return a clone of the data item - */ - public ITmfDataItem clone(); - -} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java index 421682f5d4..1cba08aef5 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEvent.java @@ -12,16 +12,73 @@ package org.eclipse.linuxtools.tmf.core.event; +import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; + /** * ITmfEvent *

- * The ITmfEvent is essentially an ITmfDataEvent with a timestamp. -*/ -public interface ITmfEvent extends ITmfDataItem, Cloneable { + * The basic event structure in the TMF. In its canonical form, a data item has: + *

+ * For convenience, a free-form reference field is also provided. It could be + * used as e.g. a location marker (filename:lineno) to indicate where the event + * was generated. + */ +public interface ITmfEvent extends Cloneable { + + /** + * Pre-defined event attributes + */ + public String EVENT_FIELD_TIMESTAMP = ":timestamp:"; //$NON-NLS-1$ + public String EVENT_FIELD_SOURCE = ":source:"; //$NON-NLS-1$ + public String EVENT_FIELD_TYPE = ":type:"; //$NON-NLS-1$ + public String EVENT_FIELD_CONTENT = ":content:"; //$NON-NLS-1$ + public String EVENT_FIELD_REFERENCE = ":reference:"; //$NON-NLS-1$ + + /** + * @return the trace that 'owns' the event + */ + public ITmfTrace getTrace(); + + /** + * @return the event rank within the parent trace + */ + public long getRank(); /** * @return the event timestamp */ public ITmfTimestamp getTimestamp(); + /** + * @return the event source + */ + public String getSource(); + + /** + * @return the event type + */ + public ITmfEventType getType(); + + /** + * @return the event content + */ + public ITmfEventField getContent(); + + /** + * @return the event reference + */ + public String getReference(); + + /** + * @return a clone of the data item + */ + public ITmfEvent clone(); + } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java deleted file mode 100644 index f552b07475..0000000000 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventContent.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.event; - -/** - * ITmfEventContent - *

- */ -public interface ITmfEventContent extends Cloneable { - - /** - * @return the raw event content - */ - public Object getRawContent(); - - /** - * @return the formatted event content (string'ified) - */ - public String getFmtContent(); - - /** - * @return the event type - */ - public ITmfEventType getType(); - - /** - * @return the list of event fields - */ - public ITmfEventField[] getFields(); - - /** - * @param index the field index - * @return the corresponding field - */ - public ITmfEventField getField(int index) throws TmfNoSuchFieldException; - - /** - * @param name the field name - * @return the corresponding field - */ - public ITmfEventField getField(String name) throws TmfNoSuchFieldException; - - /** - * @return a clone of the event content - */ - public ITmfEventContent clone(); -} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java index d27c6e51e4..8b421a2b19 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java @@ -15,13 +15,20 @@ package org.eclipse.linuxtools.tmf.core.event; /** * ITmfEventField *

+ * The TMF event payload structure. Each field can be either a terminal or + * further decomposed into subfields. */ public interface ITmfEventField extends Cloneable { + /** + * The root field id (the main container) + */ + public static final String ROOT_ID = ":root:"; //$NON-NLS-1$ + /** * @return the field ID */ - public String getId(); + public String getName(); /** * @return the field value @@ -29,9 +36,29 @@ public interface ITmfEventField extends Cloneable { public Object getValue(); /** - * @return the list of subfields (if any) + * @return the list of subfield names (empty array if none) + */ + public String[] getFieldNames(); + + /** + * @return the nth field name (null if absent or inexistent) + */ + public String getFieldName(int index); + + /** + * @return the list of subfields (empty array if none) + */ + public ITmfEventField[] getFields(); + + /** + * @return a specific subfield by name (null if absent or inexistent) + */ + public ITmfEventField getField(String name); + + /** + * @return a specific subfield by index (null if absent or inexistent) */ - public ITmfEventField[] getSubFields(); + public ITmfEventField getField(int index); /** * @return a clone of the event type diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java index 2a648b57be..8005c346a4 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventType.java @@ -15,9 +15,23 @@ package org.eclipse.linuxtools.tmf.core.event; /** * ITmfEventType *

+ * The TMF event event type. It contains a reference to the full field structure + * for that event type. + *

+ * Types are unique within their context space. */ public interface ITmfEventType extends Cloneable { + /** + * The default event type content + */ + public static final String DEFAULT_CONTEXT_ID = "TmfContext"; //$NON-NLS-1$ + + /** + * The default event type name + */ + public static final String DEFAULT_TYPE_ID = "TmfType"; //$NON-NLS-1$ + /** * @return the event type context */ @@ -26,29 +40,23 @@ public interface ITmfEventType extends Cloneable { /** * @return the event type ID */ - public String getId(); + public String getName(); /** - * @return the number of fields + * @return the event type root field */ - public int getNbFields(); + public ITmfEventField getRootField(); /** - * @return the event field labels + * @return the event field names (labels) */ - public String[] getFieldLabels(); + public String[] getFieldNames(); /** * @param index the event field index * @return the corresponding event field label */ - public String getFieldLabel(int index) throws TmfNoSuchFieldException; - - /** - * @param fieldId the event field ID - * @return the corresponding event field index - */ - public int getFieldIndex(String fieldId) throws TmfNoSuchFieldException; + public String getFieldName(int index); /** * @return a clone of the event content diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfDataItem.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfDataItem.java deleted file mode 100644 index 681d557cb2..0000000000 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfDataItem.java +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2012 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - * Francois Chouinard - Updated as per TMF Event Model 1.0 - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.event; - -import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; - -/** - * TmfDataItem - *

- * A basic implementation of ITmfDataItem. - * - * Notice that for performance reasons TmfDataEvent is NOT immutable. If a copy - * of an event is needed, use the copy constructor (shallow copy) or the clone() - * method (deep copy). - */ -public class TmfDataItem implements ITmfDataItem { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - protected ITmfTrace fTrace; - protected long fRank; - protected String fSource; - protected ITmfEventType fType; - protected ITmfEventContent fContent; - protected String fReference; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Default constructor - */ - public TmfDataItem() { - } - - /** - * Full constructor - * - * @param trace the parent trace - * @param rank the vent rank (in the trace) - * @param source the event source - * @param type the event type - * @param reference the event reference - */ - public TmfDataItem(ITmfTrace trace, long rank, - String source, TmfEventType type, TmfEventContent content, - String reference) - { - fTrace = trace; - fRank = rank; - fSource = source; - fType = type; - fContent = content; - fReference = reference; - } - - /** - * Copy constructor - * - * @param event the original event - */ - public TmfDataItem(TmfDataItem event) { - if (event == null) - throw new IllegalArgumentException(); - fTrace = event.fTrace; - fRank = event.fRank; - fSource = event.fSource; - fType = event.fType; - fContent = event.fContent; - fReference = event.fReference; - } - - // ------------------------------------------------------------------------ - // ITmfDataItem - // ------------------------------------------------------------------------ - - /** - * @return the parent trace - */ - public ITmfTrace getTrace() { - return fTrace; - } - - /** - * @return the event rank - */ - public long getRank() { - return fRank; - } - - /** - * @return the event source - */ - public String getSource() { - return fSource; - } - - /** - * @return the event type - */ - public ITmfEventType getType() { - return fType; - } - - /** - * @return the event content - */ - public ITmfEventContent getContent() { - return fContent; - } - - /** - * @return the event reference - */ - public String getReference() { - return fReference; - } - - // ------------------------------------------------------------------------ - // Convenience setters - // ------------------------------------------------------------------------ - - /** - * @param source the new event source - */ - public void setSource(String source) { - fSource = source; - } - - /** - * @param type the new event type - */ - public void setType(TmfEventType type) { - fType = type; - } - - /** - * @param content the event new content - */ - public void setContent(TmfEventContent content) { - fContent = content; - } - - /** - * @param reference the new event reference - */ - public void setReference(String reference) { - fReference = reference; - } - - // ------------------------------------------------------------------------ - // Cloneable - // ------------------------------------------------------------------------ - - @Override - public TmfDataItem clone() { - TmfDataItem clone = null; - try { - clone = (TmfDataItem) super.clone(); - clone.fTrace = fTrace; - clone.fRank = fRank; - clone.fSource = fSource; - clone.fType = fType != null ? fType.clone() : null; - clone.fContent = fContent != null ? fContent.clone() : null; - clone.fReference = fReference; - } catch (CloneNotSupportedException e) { - } - return clone; - } - - // ------------------------------------------------------------------------ - // Object - // ------------------------------------------------------------------------ - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fContent == null) ? 0 : fContent.hashCode()); - result = prime * result + (int) (fRank ^ (fRank >>> 32)); - result = prime * result + ((fReference == null) ? 0 : fReference.hashCode()); - result = prime * result + ((fSource == null) ? 0 : fSource.hashCode()); - result = prime * result + ((fTrace == null) ? 0 : fTrace.hashCode()); - result = prime * result + ((fType == null) ? 0 : fType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TmfDataItem other = (TmfDataItem) obj; - if (fContent == null) { - if (other.fContent != null) - return false; - } else if (!fContent.equals(other.fContent)) - return false; - if (fRank != other.fRank) - return false; - if (fReference == null) { - if (other.fReference != null) - return false; - } else if (!fReference.equals(other.fReference)) - return false; - if (fSource == null) { - if (other.fSource != null) - return false; - } else if (!fSource.equals(other.fSource)) - return false; - if (fTrace == null) { - if (other.fTrace != null) - return false; - } else if (!fTrace.equals(other.fTrace)) - return false; - if (fType == null) { - if (other.fType != null) - return false; - } else if (!fType.equals(other.fType)) - return false; - return true; - } - - @Override - @SuppressWarnings("nls") - public String toString() { - return "TmfDataEvent [fTrace=" + fTrace + ", fRank=" + fRank - + ", fSource=" + fSource + ", fType=" + fType + ", fContent=" - + fContent + ", fReference=" + fReference + "]"; - } - -} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java index 2c0c471469..f78fe03165 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEvent.java @@ -18,27 +18,24 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; /** * TmfEvent *

- * The basic event structure in the TMF. In its canonical form, an event has: - *

- * For convenience, a free-form reference field is also provided. It could be - * used as e.g. a location marker in the event stream to distinguish between - * otherwise identical events. + * A basic implementation of ITmfEvent. * - * Notice that for performance reasons TmfEvent is NOT immutable. If a copy of + * Note that for performance reasons TmfEvent is NOT immutable. If a copy of * the event is needed, use the copy constructor. */ -public class TmfEvent extends TmfDataItem implements ITmfEvent { +public class TmfEvent implements ITmfEvent { // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ + protected ITmfTrace fTrace; + protected long fRank; protected ITmfTimestamp fTimestamp; + protected String fSource; + protected ITmfEventType fType; + protected ITmfEventField fContent; + protected String fReference; // ------------------------------------------------------------------------ // Constructors @@ -54,33 +51,49 @@ public class TmfEvent extends TmfDataItem implements ITmfEvent { * Full constructor * * @param trace the parent trace - * @param rank the vent rank (in the trace) + * @param rank the event rank (in the trace) * @param timestamp the event timestamp * @param source the event source * @param type the event type + * @param type the event content (payload) * @param reference the event reference */ - public TmfEvent(ITmfTrace trace, long rank, ITmfTimestamp timestamp, String source, - TmfEventType type, String reference) + public TmfEvent(ITmfTrace trace, long rank, ITmfTimestamp timestamp, String source, + TmfEventType type, ITmfEventField content, String reference) { - super(trace, rank, source, type, null, reference); + fTrace = trace; + fRank = rank; fTimestamp = timestamp; + fSource = source; + fType = type; + fContent = content; + fReference = reference; } /** * Constructor - no rank */ - public TmfEvent(ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, - TmfEventType type, String reference) + public TmfEvent(ITmfTrace trace, ITmfTimestamp timestamp, String source, + TmfEventType type, ITmfEventField content, String reference) { - this(parentTrace, -1, timestamp, source, type, reference); + this(trace, -1, timestamp, source, type, content, reference); } /** - * Constructor - no trace, no rank + * Constructor - no rank, no content */ - public TmfEvent(ITmfTimestamp timestamp, String source, TmfEventType type, String reference) { - this(null, -1, timestamp, source, type, reference); + public TmfEvent(ITmfTrace trace, ITmfTimestamp timestamp, String source, + TmfEventType type, String reference) + { + this(trace, -1, timestamp, source, type, null, reference); + } + + /** + * Constructor - no rank, no content, no trace + */ + public TmfEvent(TmfTimestamp timestamp, String source, TmfEventType type, String reference) + { + this(null, -1, timestamp, source, type, null, reference); } /** @@ -89,21 +102,88 @@ public class TmfEvent extends TmfDataItem implements ITmfEvent { * @param event the original event */ public TmfEvent(TmfEvent event) { - super(event); - fTimestamp = event.fTimestamp != null ? event.fTimestamp.clone() : null; + if (event == null) + throw new IllegalArgumentException(); + fTrace = event.fTrace; + fRank = event.fRank; + fTimestamp = event.fTimestamp; + fSource = event.fSource; + fType = event.fType; + fContent = event.fContent; + fReference = event.fReference; } // ------------------------------------------------------------------------ // ITmfEvent // ------------------------------------------------------------------------ - /** - * @return the effective event timestamp - */ + public ITmfTrace getTrace() { + return fTrace; + } + + public long getRank() { + return fRank; + } + public ITmfTimestamp getTimestamp() { return fTimestamp; } + public String getSource() { + return fSource; + } + + public ITmfEventType getType() { + return fType; + } + + public ITmfEventField getContent() { + return fContent; + } + + public String getReference() { + return fReference; + } + + // ------------------------------------------------------------------------ + // Convenience setters + // ------------------------------------------------------------------------ + + /** + * @param source the new event source + */ + public void setSource(String source) { + fSource = source; + } + + /** + * @param timestamp the new event timestamp + */ + public void setTimestamp(ITmfTimestamp timestamp) { + fTimestamp = timestamp; + } + + /** + * @param type the new event type + */ + public void setType(TmfEventType type) { + fType = type; + } + + /** + * @param content the event new content + */ + public void setContent(ITmfEventField content) { + fContent = content; + } + + /** + * @param reference the new event reference + */ + public void setReference(String reference) { + fReference = reference; + } + // ------------------------------------------------------------------------ // Cloneable // ------------------------------------------------------------------------ @@ -111,8 +191,17 @@ public class TmfEvent extends TmfDataItem implements ITmfEvent { @Override public TmfEvent clone() { TmfEvent clone = null; - clone = (TmfEvent) super.clone(); - clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null; + try { + clone = (TmfEvent) super.clone(); + clone.fTrace = fTrace; + clone.fRank = fRank; + clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null; + clone.fSource = fSource; + clone.fType = fType != null ? fType.clone() : null; + clone.fContent = fContent != null ? fContent.clone() : null; + clone.fReference = fReference; + } catch (CloneNotSupportedException e) { + } return clone; } @@ -123,8 +212,14 @@ public class TmfEvent extends TmfDataItem implements ITmfEvent { @Override public int hashCode() { final int prime = 31; - int result = super.hashCode(); + int result = 1; + result = prime * result + ((fTrace == null) ? 0 : fTrace.hashCode()); + result = prime * result + (int) (fRank ^ (fRank >>> 32)); result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode()); + result = prime * result + ((fSource == null) ? 0 : fSource.hashCode()); + result = prime * result + ((fType == null) ? 0 : fType.hashCode()); + result = prime * result + ((fContent == null) ? 0 : fContent.hashCode()); + result = prime * result + ((fReference == null) ? 0 : fReference.hashCode()); return result; } @@ -132,16 +227,43 @@ public class TmfEvent extends TmfDataItem implements ITmfEvent { public boolean equals(Object obj) { if (this == obj) return true; - if (!super.equals(obj)) + if (obj == null) return false; if (getClass() != obj.getClass()) return false; TmfEvent other = (TmfEvent) obj; + if (fTrace == null) { + if (other.fTrace != null) + return false; + } else if (!fTrace.equals(other.fTrace)) + return false; + if (fRank != other.fRank) + return false; if (fTimestamp == null) { if (other.fTimestamp != null) return false; } else if (!fTimestamp.equals(other.fTimestamp)) return false; + if (fSource == null) { + if (other.fSource != null) + return false; + } else if (!fSource.equals(other.fSource)) + return false; + if (fType == null) { + if (other.fType != null) + return false; + } else if (!fType.equals(other.fType)) + return false; + if (fContent == null) { + if (other.fContent != null) + return false; + } else if (!fContent.equals(other.fContent)) + return false; + if (fReference == null) { + if (other.fReference != null) + return false; + } else if (!fReference.equals(other.fReference)) + return false; return true; } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventContent.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventContent.java deleted file mode 100644 index c2259bee58..0000000000 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventContent.java +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2012 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - * Francois Chouinard - Updated as per TMF Event Model 1.0 - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.event; - -import java.util.Arrays; - -/** - * TmfEventContent - *

- * A basic implementation of ITmfEventContent where the raw content is a String. - */ -public class TmfEventContent implements ITmfEventContent { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - - // Default field IDs - public static final String FIELD_ID_TIMESTAMP = ":timestamp:"; //$NON-NLS-1$ - public static final String FIELD_ID_SOURCE = ":source:"; //$NON-NLS-1$ - public static final String FIELD_ID_TYPE = ":type:"; //$NON-NLS-1$ - public static final String FIELD_ID_REFERENCE = ":reference:"; //$NON-NLS-1$ - public static final String FIELD_ID_CONTENT = ":content:"; //$NON-NLS-1$ - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - protected TmfEvent fParentEvent; - protected String fRawContent; - protected TmfEventField[] fFields; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Default constructor - */ - @SuppressWarnings("unused") - private TmfEventContent() { - throw new AssertionError(); - } - - /** - * Full constructor - * - * @param parent the parent event (owner) - * @param content the raw content as a byte[] - */ - public TmfEventContent(TmfEvent parent, String content) { - fParentEvent = parent; - fRawContent = content; - } - - /** - * Copy constructor - * - * @param content the original event content - */ - public TmfEventContent(TmfEventContent content) { - if (content == null) - throw new IllegalArgumentException(); - fParentEvent = content.fParentEvent; - fRawContent = content.fRawContent; - fFields = content.fFields; - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return the parent (containing) event - */ - public TmfEvent getEvent() { - return fParentEvent; - } - - /** - * @return the event type - */ - public ITmfEventType getType() { - return fParentEvent.getType(); - } - - /** - * @return the raw content - */ - public Object getRawContent() { - return fRawContent; - } - - /** - * @return the serialized content - */ - public String getFmtContent() { - return fRawContent; - } - - /** - * Returns the list of fields in the same order as TmfEventType.getLabels() - * - * @return the ordered set of fields (optional fields might be null) - */ - public ITmfEventField[] getFields() { - if (fFields == null) { - parseContent(); - } - return fFields; - } - - /** - * @param id the field id - * @return the corresponding field - * @throws TmfNoSuchFieldException - */ - public ITmfEventField getField(String id) throws TmfNoSuchFieldException { - if (fFields == null) { - parseContent(); - } - try { - return fFields[getType().getFieldIndex(id)]; - } catch (TmfNoSuchFieldException e) { - // Required for filtering from default TmfEventsTable columns - if (id.equals(FIELD_ID_CONTENT)) { - return new TmfEventField(this, FIELD_ID_CONTENT, toString()); - } else if (id.equals(FIELD_ID_TIMESTAMP)) { - return new TmfEventField(this, FIELD_ID_TIMESTAMP, fParentEvent.getTimestamp().toString()); - } else if (id.equals(FIELD_ID_SOURCE)) { - return new TmfEventField(this, FIELD_ID_SOURCE, fParentEvent.getSource()); - } else if (id.equals(FIELD_ID_TYPE)) { - return new TmfEventField(this, FIELD_ID_TYPE, fParentEvent.getType().getId()); - } else if (id.equals(FIELD_ID_REFERENCE)) { - return new TmfEventField(this, FIELD_ID_REFERENCE, fParentEvent.getReference()); - } - throw e; - } - } - - /** - * @param n the field index as per TmfEventType.getLabels() - * @return the corresponding field (null if non-existing) - */ - public ITmfEventField getField(int n) { - if (fFields == null) { - parseContent(); - } - if (n >= 0 && n < fFields.length) - return fFields[n]; - - return null; - } - - // ------------------------------------------------------------------------ - // Operations - // ------------------------------------------------------------------------ - - /** - * Parse the content into fields. By default, a single field (the raw - * content) is returned. - * - * Should be overridden. - */ - protected void parseContent() { - fFields = new TmfEventField[1]; - fFields[0] = new TmfEventField(this, FIELD_ID_CONTENT, fRawContent); - } - - // ------------------------------------------------------------------------ - // Cloneable - // ------------------------------------------------------------------------ - - @Override - public ITmfEventContent clone() { - TmfEventContent clone = null; - try { - clone = (TmfEventContent) super.clone(); - clone.fParentEvent = fParentEvent; - clone.fRawContent = fRawContent; - clone.fFields = fFields; - } - catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - return clone; - } - - // ------------------------------------------------------------------------ - // Object - // ------------------------------------------------------------------------ - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(fFields); - result = prime * result + ((fRawContent == null) ? 0 : fRawContent.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TmfEventContent other = (TmfEventContent) obj; - if (!Arrays.equals(fFields, other.fFields)) - return false; - if (fRawContent == null) { - if (other.fRawContent != null) - return false; - } else if (!fRawContent.equals(other.fRawContent)) - return false; - return true; - } - - @Override - @SuppressWarnings("nls") - public String toString() { - return "TmfEventContent [fRawContent=" + fRawContent + ", fFields=" + Arrays.toString(fFields) + "]"; - } - -} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java index 6a01746bff..ca5fd9dfe7 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java @@ -13,10 +13,13 @@ package org.eclipse.linuxtools.tmf.core.event; +import java.util.HashMap; +import java.util.Map; + /** * TmfEventField *

- * A basic implementation of ITmfEventField with no subfields. + * A basic implementation of ITmfEventField. */ public class TmfEventField implements ITmfEventField { @@ -24,11 +27,13 @@ public class TmfEventField implements ITmfEventField { // Attributes // ------------------------------------------------------------------------ - protected ITmfEventContent fEventContent; - protected String fFieldId; - protected Object fValue; - protected ITmfEventField[] fSubFields; + private String fName; + private Object fValue; + private ITmfEventField[] fFields; + private String[] fFieldNames; + private Map fNameMapping; + // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ @@ -41,21 +46,41 @@ public class TmfEventField implements ITmfEventField { throw new AssertionError(); } + /** + * Constructor for a terminal field (i.e. no subfields) + * + * @param name the event field id + * @param value the event field value + */ + public TmfEventField(String name, Object value) { + this(name, value, new ITmfEventField[0]); + } + + /** + * Constructor for a non-valued field (for structural purposes) + * + * @param name the event field id + * @param subfields the list of subfields + */ + public TmfEventField(String name, ITmfEventField[] fields) { + this(name, null, fields); + } + /** * Full constructor * - * @param content the event content (field container) - * @param id the event field id + * @param name the event field id * @param value the event field value + * @param subfields the list of subfields */ - public TmfEventField(ITmfEventContent content, String id, Object value) { - if (id == null) { + public TmfEventField(String name, Object value, ITmfEventField[] fields) { + if (name == null) { throw new IllegalArgumentException(); } - fEventContent = content; - fFieldId = id; + fName = name; fValue = value; - fSubFields = null; + fFields = fields; + populateStructs(); } /** @@ -66,30 +91,48 @@ public class TmfEventField implements ITmfEventField { public TmfEventField(TmfEventField field) { if (field == null) throw new IllegalArgumentException(); - fEventContent = field.fEventContent; - fFieldId = field.fFieldId; + fName = field.fName; fValue = field.fValue; - fSubFields = field.fSubFields; + fFields = field.fFields; + fFieldNames = field.fFieldNames; } // ------------------------------------------------------------------------ // ITmfEventField // ------------------------------------------------------------------------ - public ITmfEventContent getContent() { - return fEventContent; - } - - public String getId() { - return fFieldId; + public String getName() { + return fName; } public Object getValue() { return fValue; } - public ITmfEventField[] getSubFields() { - return fSubFields; + public String[] getFieldNames() { + return fFieldNames; + } + + public String getFieldName(int index) { + ITmfEventField field = getField(index); + if (field != null) { + return field.getName(); + } + return null; + } + + public ITmfEventField[] getFields() { + return fFields; + } + + public ITmfEventField getField(String name) { + return fNameMapping.get(name); + } + + public ITmfEventField getField(int index) { + if (index >= 0 && index < fFields.length) + return fFields[index]; + return null; } // ------------------------------------------------------------------------ @@ -97,10 +140,46 @@ public class TmfEventField implements ITmfEventField { // ------------------------------------------------------------------------ /** - * @param value new field value + * @param value new field raw value + * @param fields the corresponding fields */ - protected void setValue(Object value) { + protected void setValue(Object value, ITmfEventField[] fields) { fValue = value; + fFields = fields; + populateStructs(); + } + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + /** + * Create a root field from a list of labels. + * + * @param labels the list of labels + * @return the (flat) root list + */ + public final static ITmfEventField makeRoot(String[] labels) { + ITmfEventField[] fields = new ITmfEventField[labels.length]; + for (int i = 0; i < labels.length; i++) { + fields[i] = new TmfEventField(labels[i], null); + } + ITmfEventField rootField = new TmfEventField(ITmfEventField.ROOT_ID, fields); + return rootField; + } + + /* + * Populate the subfield names and the name map + */ + private void populateStructs() { + int nbFields = (fFields != null) ? fFields.length : 0; + fFieldNames = new String[nbFields]; + fNameMapping = new HashMap(); + for (int i = 0; i < nbFields; i++) { + String name = fFields[i].getName(); + fFieldNames[i] = name; + fNameMapping.put(name, fFields[i]); + } } // ------------------------------------------------------------------------ @@ -112,10 +191,10 @@ public class TmfEventField implements ITmfEventField { TmfEventField clone = null; try { clone = (TmfEventField) super.clone(); - clone.fEventContent = fEventContent; - clone.fFieldId = fFieldId; + clone.fName = fName; clone.fValue = fValue; - clone.fSubFields = (fSubFields != null) ? fSubFields.clone() : null; + clone.fFields = (fFields != null) ? fFields.clone() : null; + clone.populateStructs(); } catch (CloneNotSupportedException e) { } return clone; @@ -129,8 +208,7 @@ public class TmfEventField implements ITmfEventField { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((fEventContent == null) ? 0 : fEventContent.hashCode()); - result = prime * result + ((fFieldId == null) ? 0 : fFieldId.hashCode()); + result = prime * result + ((fName == null) ? 0 : fName.hashCode()); result = prime * result + ((fValue == null) ? 0 : fValue.hashCode()); return result; } @@ -144,15 +222,10 @@ public class TmfEventField implements ITmfEventField { if (getClass() != obj.getClass()) return false; TmfEventField other = (TmfEventField) obj; - if (fEventContent == null) { - if (other.fEventContent != null) - return false; - } else if (!fEventContent.equals(other.fEventContent)) - return false; - if (fFieldId == null) { - if (other.fFieldId != null) + if (fName == null) { + if (other.fName != null) return false; - } else if (!fFieldId.equals(other.fFieldId)) + } else if (!fName.equals(other.fName)) return false; if (fValue == null) { if (other.fValue != null) @@ -165,7 +238,7 @@ public class TmfEventField implements ITmfEventField { @Override @SuppressWarnings("nls") public String toString() { - return "TmfEventField [fFieldId=" + fFieldId + ", fValue=" + fValue + "]"; + return "TmfEventField [fFieldId=" + fName + ", fValue=" + fValue + "]"; } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java index 7f39bf3297..70793a4d81 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventType.java @@ -13,10 +13,6 @@ package org.eclipse.linuxtools.tmf.core.event; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - /** * TmfEventType *

@@ -24,22 +20,13 @@ import java.util.Map; */ public class TmfEventType implements ITmfEventType { - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - - public static final String DEFAULT_CONTEXT_ID = "Context"; //$NON-NLS-1$ - public static final String DEFAULT_TYPE_ID = "Type"; //$NON-NLS-1$ - // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ private String fContext; private String fTypeId; - private int fNbFields; - private Map fFieldMap; - private String[] fFieldLabels; + private ITmfEventField fRootField; // ------------------------------------------------------------------------ // Constructors @@ -52,29 +39,23 @@ public class TmfEventType implements ITmfEventType { this(DEFAULT_CONTEXT_ID, DEFAULT_TYPE_ID, null); } - /** - * Full constructor - * - * @param context the type context - * @param typeId the type name - * @param labels the list of field labels - */ - public TmfEventType(String context, String typeId, String[] labels) { - if (context == null || typeId == null) - throw new IllegalArgumentException(); - fContext = context; - fTypeId = typeId; - fFieldLabels = (labels != null) ? labels : new String[] { }; - fNbFields = (fFieldLabels != null) ? fFieldLabels.length : 0; - fFieldMap = new HashMap(); - for (int i = 0; i < fNbFields; i++) { - String id = fFieldLabels[i]; - fFieldMap.put(id, i); - } - - // Register to the event type manager - TmfEventTypeManager.getInstance().add(context, this); - } + /** + * Full constructor + * + * @param context the type context + * @param typeId the type name + * @param root the root field + */ + public TmfEventType(String context, String typeId, ITmfEventField root) { + if (context == null || typeId == null) + throw new IllegalArgumentException(); + fContext = context; + fTypeId = typeId; + fRootField = root; + + // Register to the event type manager + TmfEventTypeManager.getInstance().add(context, this); + } /** * Copy constructor @@ -84,11 +65,9 @@ public class TmfEventType implements ITmfEventType { public TmfEventType(TmfEventType type) { if (type == null) throw new IllegalArgumentException(); - fContext = type.fContext; - fTypeId = type.fTypeId; - fFieldLabels = type.fFieldLabels; - fNbFields = type.fNbFields; - fFieldMap = type.fFieldMap; + fContext = type.fContext; + fTypeId = type.fTypeId; + fRootField = type.fRootField; } // ------------------------------------------------------------------------ @@ -99,29 +78,20 @@ public class TmfEventType implements ITmfEventType { return fContext; } - public String getId() { + public String getName() { return fTypeId; } - public int getNbFields() { - return fNbFields; - } - - public String[] getFieldLabels() { - return fFieldLabels; + public ITmfEventField getRootField() { + return fRootField; } - public String getFieldLabel(int i) throws TmfNoSuchFieldException { - if (i >= 0 && i < fNbFields) - return fFieldLabels[i]; - throw new TmfNoSuchFieldException("Invalid index (" + i + ")"); //$NON-NLS-1$//$NON-NLS-2$ + public String[] getFieldNames() { + return (fRootField != null) ? fRootField.getFieldNames() : null; } - public int getFieldIndex(String fieldId) throws TmfNoSuchFieldException { - Integer index = fFieldMap.get(fieldId); - if (index == null) - throw (new TmfNoSuchFieldException("Invalid field (" + fieldId + ")")); //$NON-NLS-1$//$NON-NLS-2$ - return index; + public String getFieldName(int index) { + return (fRootField != null) ? fRootField.getFieldName(index) : null; } // ------------------------------------------------------------------------ @@ -135,14 +105,7 @@ public class TmfEventType implements ITmfEventType { clone = (TmfEventType) super.clone(); clone.fContext = fContext; clone.fTypeId = fTypeId; - // Clone the fields - clone.fNbFields = fNbFields; - clone.fFieldLabels = new String[fNbFields]; - clone.fFieldMap = new HashMap(); - for (int i = 0; i < fNbFields; i++) { - clone.fFieldLabels[i] = fFieldLabels[i]; - clone.fFieldMap.put(fFieldLabels[i], Integer.valueOf(i)); - } + clone.fRootField = (fRootField != null) ? fRootField.clone() : null; } catch (CloneNotSupportedException e) { } @@ -158,9 +121,6 @@ public class TmfEventType implements ITmfEventType { final int prime = 31; int result = 1; result = prime * result + ((fContext == null) ? 0 : fContext.hashCode()); - result = prime * result + Arrays.hashCode(fFieldLabels); - result = prime * result + ((fFieldMap == null) ? 0 : fFieldMap.hashCode()); - result = prime * result + fNbFields; result = prime * result + ((fTypeId == null) ? 0 : fTypeId.hashCode()); return result; } @@ -179,15 +139,6 @@ public class TmfEventType implements ITmfEventType { return false; } else if (!fContext.equals(other.fContext)) return false; - if (!Arrays.equals(fFieldLabels, other.fFieldLabels)) - return false; - if (fFieldMap == null) { - if (other.fFieldMap != null) - return false; - } else if (!fFieldMap.equals(other.fFieldMap)) - return false; - if (fNbFields != other.fNbFields) - return false; if (fTypeId == null) { if (other.fTypeId != null) return false; @@ -199,27 +150,7 @@ public class TmfEventType implements ITmfEventType { @Override @SuppressWarnings("nls") public String toString() { - return "TmfEventType [fContext=" + fContext + ", fTypeId=" + fTypeId + ", fNbFields=" - + fNbFields + ", fFieldLabels=" + Arrays.toString(fFieldLabels) + "]"; + return "TmfEventType [fContext=" + fContext + ", fTypeId=" + fTypeId + "]"; } -// @Override -// public int hashCode() { -// return fTypeId.hashCode(); -// } -// -// @Override -// public boolean equals(Object other) { -// if (!(other instanceof TmfEventType)) -// return false; -// TmfEventType o = (TmfEventType) other; -// return fTypeId.equals(o.fTypeId); -// } -// -// @Override -// @SuppressWarnings("nls") -// public String toString() { -// return "[TmfEventType:" + fTypeId + "]"; -// } - } \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java index 9567f8dedc..614f5d1db7 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventTypeManager.java @@ -18,7 +18,7 @@ import java.util.HashMap; * TmfEventTypeManager *

* The TmfEventTypeManager acts as a central repository for the available - * event types. + * event types. Types are managed in their context space. *

*/ public final class TmfEventTypeManager { @@ -63,7 +63,7 @@ public final class TmfEventTypeManager { if (types == null) { types = new HashMap(); } - types.put(type.getId(), type); + types.put(type.getName(), type); fEventTypes.put(context, types); } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfNoSuchFieldException.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfNoSuchFieldException.java deleted file mode 100644 index b7420a6297..0000000000 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfNoSuchFieldException.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * 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 - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.event; - -/** - * TmfNoSuchFieldException - *

- * TODO: Implement me. Please. - */ -public class TmfNoSuchFieldException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 2504826473032522133L; - - public TmfNoSuchFieldException(String message) { - super(message); - } -} diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java index f0a7bcd37e..b83672050d 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfSimpleTimestamp.java @@ -100,7 +100,7 @@ public class TmfSimpleTimestamp extends TmfTimestamp { @Override @SuppressWarnings("nls") public String toString() { - return "TmfSimpleTimestamp [fValue=" + fValue + ", fScale=" + fScale + ", fPrecision=" + fPrecision + "]"; + return "TmfSimpleTimestamp [fValue=" + fValue + "]"; } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java index 0c30227ee9..8ca69f9bc3 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimeRange.java @@ -16,7 +16,7 @@ package org.eclipse.linuxtools.tmf.core.event; /** * TmfTimeRange *

- * A utility class to define time ranges. + * A utility class to define and manage time ranges. */ public class TmfTimeRange implements Cloneable { @@ -77,7 +77,7 @@ public class TmfTimeRange implements Cloneable { } // ------------------------------------------------------------------------ - // Accessors + // Getters // ------------------------------------------------------------------------ /** diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java index 9172ccada7..78f619b37a 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfTimestamp.java @@ -34,9 +34,9 @@ public class TmfTimestamp implements ITmfTimestamp { // Attributes // ------------------------------------------------------------------------ - protected long fValue; // The timestamp raw value - protected int fScale; // The time scale - protected int fPrecision; // The value precision (tolerance) + protected long fValue; // The timestamp raw value + protected int fScale; // The time scale + protected int fPrecision; // The value precision (tolerance) // ------------------------------------------------------------------------ // Constructors diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java index fb9bb56c18..7dff3e6072 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterCompareNode.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; @@ -113,44 +112,44 @@ public class TmfFilterCompareNode extends TmfFilterTreeNode { @Override public boolean matches(TmfEvent event) { - try { - Object value = event.getContent().getField(fField); - if (value == null) { - return false ^ fNot; - } - if (fType == Type.NUM) { - if (fValueNumber instanceof Number) { - if (value instanceof Number) { - Double valueDouble = ((Number) value).doubleValue(); - return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot; - } else { - try { - Double valueDouble = NumberFormat.getInstance().parse(value.toString()).doubleValue(); - return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot; - } catch (ParseException e) { - } - } - } - } else if (fType == Type.ALPHA) { - String valueString = value.toString(); - return (valueString.compareTo(fValue.toString()) == fResult) ^ fNot; - } else if (fType == Type.TIMESTAMP) { - if (fValueTimestamp instanceof TmfTimestamp) { - if (value instanceof TmfTimestamp) { - TmfTimestamp valueTimestamp = (TmfTimestamp) value; - return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot; - } else { - try { - TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat.getInstance().parse(value.toString()).doubleValue())); - return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot; - } catch (ParseException e) { - } - } - } - } - } catch (TmfNoSuchFieldException e) { - } - return false ^ fNot; + Object value = event.getContent().getField(fField).getValue(); + if (value == null) { + return false ^ fNot; + } + if (fType == Type.NUM) { + if (fValueNumber instanceof Number) { + if (value instanceof Number) { + Double valueDouble = ((Number) value).doubleValue(); + return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot; + } else { + try { + Double valueDouble = NumberFormat.getInstance().parse(value.toString()) + .doubleValue(); + return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) + ^ fNot; + } catch (ParseException e) { + } + } + } + } else if (fType == Type.ALPHA) { + String valueString = value.toString(); + return (valueString.compareTo(fValue.toString()) == fResult) ^ fNot; + } else if (fType == Type.TIMESTAMP) { + if (fValueTimestamp instanceof TmfTimestamp) { + if (value instanceof TmfTimestamp) { + TmfTimestamp valueTimestamp = (TmfTimestamp) value; + return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot; + } else { + try { + TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat + .getInstance().parse(value.toString()).doubleValue())); + return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot; + } catch (ParseException e) { + } + } + } + } + return false ^ fNot; } @Override diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java index 01a7c0429f..9a77053b85 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; public class TmfFilterContainsNode extends TmfFilterTreeNode { @@ -77,20 +76,16 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode { @Override public boolean matches(TmfEvent event) { - try { - Object value = event.getContent().getField(fField); - if (value == null) { - return false ^ fNot; - } - String valueString = value.toString(); - if (fIgnoreCase) { - return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot; - } else { - return valueString.contains(fValue) ^ fNot; - } - } catch (TmfNoSuchFieldException e) { - return false ^ fNot; - } + Object value = event.getContent().getField(fField); + if (value == null) { + return false ^ fNot; + } + String valueString = value.toString(); + if (fIgnoreCase) { + return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot; + } else { + return valueString.contains(fValue) ^ fNot; + } } @Override diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java index d7781b5dab..1ae98755cb 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; public class TmfFilterEqualsNode extends TmfFilterTreeNode { @@ -75,23 +74,19 @@ public class TmfFilterEqualsNode extends TmfFilterTreeNode { @Override public boolean matches(TmfEvent event) { - try { - Object value = event.getContent().getField(fField); - if (value == null) { - return false ^ fNot; - } - String valueString = value.toString(); - if (valueString == null) { - return false ^ fNot; - } - if (fIgnoreCase) { - return valueString.equalsIgnoreCase(fValue) ^ fNot; - } else { - return valueString.equals(fValue) ^ fNot; - } - } catch (TmfNoSuchFieldException e) { - return false ^ fNot; - } + Object value = event.getContent().getField(fField); + if (value == null) { + return false ^ fNot; + } + String valueString = value.toString(); + if (valueString == null) { + return false ^ fNot; + } + if (fIgnoreCase) { + return valueString.equalsIgnoreCase(fValue) ^ fNot; + } else { + return valueString.equals(fValue) ^ fNot; + } } @Override diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java index 20de59833c..26bae73b5f 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEventTypeNode.java @@ -58,7 +58,7 @@ public class TmfFilterEventTypeNode extends TmfFilterTreeNode { if (fType.contains(":")) { //$NON-NLS-1$ // special case for custom parsers if (fType.startsWith(event.getClass().getCanonicalName())) { - if (fType.endsWith(event.getType().getId())) { + if (fType.endsWith(event.getType().getName())) { match = true; } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java index 828de83989..17a3382d31 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterMatchesNode.java @@ -18,7 +18,6 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; public class TmfFilterMatchesNode extends TmfFilterTreeNode { @@ -73,19 +72,15 @@ public class TmfFilterMatchesNode extends TmfFilterTreeNode { @Override public boolean matches(TmfEvent event) { - if (fPattern == null) { - return false ^ fNot; - } - try { - Object value = event.getContent().getField(fField); - if (value == null) { - return false ^ fNot; - } - String valueString = value.toString(); - return fPattern.matcher(valueString).matches() ^ fNot; - } catch (TmfNoSuchFieldException e) { - return false ^ fNot; - } + if (fPattern == null) { + return false ^ fNot; + } + Object value = event.getContent().getField(fField); + if (value == null) { + return false ^ fNot; + } + String valueString = value.toString(); + return fPattern.matcher(valueString).matches() ^ fNot; } @Override diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java index 7c67bdb356..7ed4d61507 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java @@ -12,14 +12,14 @@ package org.eclipse.linuxtools.tmf.core.request; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; /** * ITmfDataRequest *

* TODO: Implement me. Please. */ -public interface ITmfDataRequest { +public interface ITmfDataRequest { // ------------------------------------------------------------------------ // Constants diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfCoalescedDataRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfCoalescedDataRequest.java index 39a7a2de64..ea8d49a51b 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfCoalescedDataRequest.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfCoalescedDataRequest.java @@ -14,14 +14,14 @@ package org.eclipse.linuxtools.tmf.core.request; import java.util.Vector; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; /** * TmfCoalescedDataRequest *

* TODO: Implement me. Please. */ -public class TmfCoalescedDataRequest extends TmfDataRequest { +public class TmfCoalescedDataRequest extends TmfDataRequest { // ------------------------------------------------------------------------ // Attributes diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java index 91c5009b6f..96bdc62d24 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java @@ -15,7 +15,7 @@ package org.eclipse.linuxtools.tmf.core.request; import java.util.concurrent.CountDownLatch; import org.eclipse.linuxtools.tmf.core.Tracer; -import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; +import org.eclipse.linuxtools.tmf.core.event.TmfEvent; /** * TmfDataRequest @@ -69,7 +69,7 @@ import org.eclipse.linuxtools.tmf.core.event.TmfDataItem; * * TODO: Implement request failures (codes, etc...) */ -public abstract class TmfDataRequest implements ITmfDataRequest { +public abstract class TmfDataRequest implements ITmfDataRequest { // ------------------------------------------------------------------------ // Constants diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java index 90819878e4..6e31cf85a8 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java @@ -18,8 +18,9 @@ import junit.framework.TestCase; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; @@ -59,9 +60,9 @@ public class TmfBaseColumnDataProviderTest extends TestCase { private final String fSource = "Source"; - private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, fLabels); + private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; @@ -69,9 +70,9 @@ public class TmfBaseColumnDataProviderTest extends TestCase { private final TmfEvent fEvent2; private final TmfEvent fEvent3; - private final TmfEventContent fContent1; - private final TmfEventContent fContent2; - private final TmfEventContent fContent3; + private final TmfEventField fContent1; + private final TmfEventField fContent2; + private final TmfEventField fContent3; private final TmfBaseStatisticsTree fStatsData; @@ -87,15 +88,15 @@ public class TmfBaseColumnDataProviderTest extends TestCase { fTestName = name; fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); fEvent1.setContent(fContent1); fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference); - fContent2 = new TmfEventContent(fEvent2, "Some other content"); + fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content"); fEvent2.setContent(fContent2); fEvent3 = new TmfEvent(fTimestamp3, fSource, fType3, fReference); - fContent3 = new TmfEventContent(fEvent3, "Some other different content"); + fContent3 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other different content"); fEvent3.setContent(fContent3); fStatsData = new TmfBaseStatisticsTree(); diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java index 314774a5de..f3be43e0d1 100755 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java @@ -19,8 +19,9 @@ import java.util.Vector; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; @@ -53,9 +54,9 @@ public class TmfBaseStatisticsDataTest extends TestCase { private final String fSource = "Source"; - private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, fLabels); + private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; @@ -63,9 +64,9 @@ public class TmfBaseStatisticsDataTest extends TestCase { private final TmfEvent fEvent2; private final TmfEvent fEvent3; - private final TmfEventContent fContent1; - private final TmfEventContent fContent2; - private final TmfEventContent fContent3; + private final TmfEventField fContent1; + private final TmfEventField fContent2; + private final TmfEventField fContent3; private final TmfBaseStatisticsTree fStatsData; @@ -84,15 +85,15 @@ public class TmfBaseStatisticsDataTest extends TestCase { fTestName = name; fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); fEvent1.setContent(fContent1); fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference); - fContent2 = new TmfEventContent(fEvent2, "Some other content"); + fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content"); fEvent2.setContent(fContent2); fEvent3 = new TmfEvent(fTimestamp3, fSource, fType3, fReference); - fContent3 = new TmfEventContent(fEvent3, "Some other different content"); + fContent3 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other different content"); fEvent3.setContent(fContent3); fStatsData = new TmfBaseStatisticsTree(); @@ -282,8 +283,8 @@ public class TmfBaseStatisticsDataTest extends TestCase { fStatsData.reset(new TmfFixedArray(fTestName, Messages.TmfStatisticsData_EventTypes)); assertEquals("reset", 0, fStatsData.getChildren(new TmfFixedArray(fTestName, Messages.TmfStatisticsData_EventTypes)).size()); - assertNull("reset", fStatsData.get(new TmfFixedArray(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getId()))); - assertNull("reset", fStatsData.get(new TmfFixedArray(fTestName, Messages.TmfStatisticsData_EventTypes, fType3.getId()))); + assertNull("reset", fStatsData.get(new TmfFixedArray(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()))); + assertNull("reset", fStatsData.get(new TmfFixedArray(fTestName, Messages.TmfStatisticsData_EventTypes, fType3.getName()))); fStatsData.reset(new TmfFixedArray(fTestName)); diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java index c597d9e9d0..88acdba338 100755 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java @@ -19,8 +19,9 @@ import java.util.Vector; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; @@ -54,9 +55,9 @@ public class TmfStatisticsTreeNodeTest extends TestCase { private final String fSource = "Source"; - private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, fLabels); + private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; @@ -64,9 +65,9 @@ public class TmfStatisticsTreeNodeTest extends TestCase { private final TmfEvent fEvent2; private final TmfEvent fEvent3; - private final TmfEventContent fContent1; - private final TmfEventContent fContent2; - private final TmfEventContent fContent3; + private final TmfEventField fContent1; + private final TmfEventField fContent2; + private final TmfEventField fContent3; private final TmfBaseStatisticsTree fStatsData; @@ -85,15 +86,15 @@ public class TmfStatisticsTreeNodeTest extends TestCase { fTestName = name; fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); fEvent1.setContent(fContent1); fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference); - fContent2 = new TmfEventContent(fEvent2, "Some other content"); + fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content"); fEvent2.setContent(fContent2); fEvent3 = new TmfEvent(fTimestamp3, fSource, fType3, fReference); - fContent3 = new TmfEventContent(fEvent3, "Some other different content"); + fContent3 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other different content"); fEvent3.setContent(fContent3); fStatsData = new TmfBaseStatisticsTree(); diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java index d10ffdddfd..db218effc6 100755 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java @@ -19,8 +19,9 @@ import java.util.Vector; import junit.framework.TestCase; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; @@ -53,16 +54,16 @@ public class TmfTreeContentProviderTest extends TestCase { private final String fSource = "Source"; - private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, fLabels); - private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId2, fLabels); + private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels)); + private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels)); private final String fReference = "Some reference"; private final TmfEvent fEvent1; private final TmfEvent fEvent2; - private final TmfEventContent fContent1; - private final TmfEventContent fContent2; + private final TmfEventField fContent1; + private final TmfEventField fContent2; private final TmfBaseStatisticsTree fStatsData; @@ -84,11 +85,11 @@ public class TmfTreeContentProviderTest extends TestCase { fTestName = name; fEvent1 = new TmfEvent(fTimestamp1, fSource, fType1, fReference); - fContent1 = new TmfEventContent(fEvent1, "Some content"); + fContent1 = new TmfEventField(ITmfEventField.ROOT_ID, "Some content"); fEvent1.setContent(fContent1); fEvent2 = new TmfEvent(fTimestamp2, fSource, fType2, fReference); - fContent2 = new TmfEventContent(fEvent2, "Some other content"); + fContent2 = new TmfEventField(ITmfEventField.ROOT_ID, "Some other content"); fEvent2.setContent(fContent2); fStatsData = new TmfBaseStatisticsTree(); diff --git a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java index 9f04713ebf..f8f0aec3aa 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java @@ -15,8 +15,8 @@ import java.io.EOFException; import java.io.IOException; import java.io.RandomAccessFile; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; @@ -57,8 +57,8 @@ public class TmfUml2SDTestTrace implements ITmfEventParser { String[] labels = {"sender", "receiver", "signal"}; - TmfEventType tmfEventType = new TmfEventType("UnitTest", type, labels); - TmfEvent tmfEvent = new TmfEvent(new TmfTimestamp(ts, (byte)-9), source, tmfEventType, reference); + TmfEventType tmfEventType = new TmfEventType("UnitTest", type, TmfEventField.makeRoot(labels)); + TmfEvent tmfEvent = new TmfEvent(new TmfTimestamp(ts, -9), source, tmfEventType, reference); String content = "["; content += sender; @@ -66,22 +66,13 @@ public class TmfUml2SDTestTrace implements ITmfEventParser { content += "," + signal; content += "]"; - TmfEventContent tmfContent = new TmfEventContent(tmfEvent, content) { - @Override - public void parseContent() { - String raw = fRawContent.toString(); - int i = raw.indexOf(","); - String sender = raw.substring(1, i); - int k = raw.indexOf(",", i+1); - String receiver = raw.substring(i+1, k); - i = raw.indexOf(",", k+1); - String signal = raw.substring(k+1, raw.length() - 1); - fFields = new TmfEventField[3]; - fFields[0] = new TmfEventField(this, "sender", sender); - fFields[1] = new TmfEventField(this, "receiver", receiver);; - fFields[2] = new TmfEventField(this, "signal", signal);; - } - }; + // Pre-parse the content + TmfEventField[] fields = new TmfEventField[3]; + fields[0] = new TmfEventField("sender", sender); + fields[1] = new TmfEventField("receiver", receiver); + fields[2] = new TmfEventField("signal", signal); + + ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_ID, content, fields); tmfEvent.setContent(tmfContent); return tmfEvent; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java index 1a275f31cb..e5a4c01c93 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEvent.java @@ -86,9 +86,9 @@ public class CustomEvent extends TmfEvent { String value = fData.get(outputColumn.name); if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(fDefinition.timeStampOutputFormat); - fColumnData[i++] = new TmfEventField(getContent(), outputColumn.name, dateFormat.format(date)); + fColumnData[i++] = new TmfEventField(outputColumn.name, dateFormat.format(date)); } else { - fColumnData[i++] = new TmfEventField(getContent(), outputColumn.name, (value != null ? value : "")); //$NON-NLS-1$ + fColumnData[i++] = new TmfEventField(outputColumn.name, (value != null ? value : "")); //$NON-NLS-1$ } } fData = null; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java index 9900e66372..c08c4e62b5 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventContent.java @@ -1,24 +1,26 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; -import java.util.Arrays; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; - -public class CustomEventContent extends TmfEventContent { +public class CustomEventContent extends TmfEventField { + CustomEvent fParent; + public CustomEventContent(CustomEvent parent, String content) { - super(parent, content); - } - - @Override - protected void parseContent() { - CustomEvent event = (CustomEvent) fParentEvent; - fFields = event.extractItemFields(); + super(ITmfEventField.ROOT_ID, content); + fParent = parent; } - @Override - public String toString() { - return Arrays.toString(getFields()); - } +// @Override +// protected void parseContent() { +// CustomEvent event = (CustomEvent) fParentEvent; +// fFields = event.extractItemFields(); +// } +// +// @Override +// public String toString() { +// return Arrays.toString(getFields()); +// } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java index 516cdde1d2..b6f2093aad 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomEventType.java @@ -1,5 +1,7 @@ package org.eclipse.linuxtools.tmf.ui.parsers.custom; +import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; +import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; public abstract class CustomEventType extends TmfEventType { @@ -7,15 +9,16 @@ public abstract class CustomEventType extends TmfEventType { private static String CONTEXT_ID = "CustomEventType"; //$NON-NLS-1$ public CustomEventType(CustomTraceDefinition definition) { - super(CONTEXT_ID, definition.definitionName, getLabels(definition)); + super(CONTEXT_ID, definition.definitionName, getRootField(definition)); } - private static String[] getLabels(CustomTraceDefinition definition) { - String[] labels = new String[definition.outputs.size()]; - for (int i = 0; i < labels.length; i++) { - labels[i] = definition.outputs.get(i).name; + private static ITmfEventField getRootField(CustomTraceDefinition definition) { + ITmfEventField[] fields = new ITmfEventField[definition.outputs.size()]; + for (int i = 0; i < fields.length; i++) { + fields[i] = new TmfEventField(definition.outputs.get(i).name, null); } - return labels; + ITmfEventField rootField = new TmfEventField(ITmfEventField.ROOT_ID, fields); + return rootField; } } diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java index f77498fff7..ca5745c734 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomTxtTrace.java @@ -286,7 +286,7 @@ public class CustomTxtTrace extends TmfTrace { } } } - ((StringBuffer) event.getContent().getRawContent()).append("\n").append(line); //$NON-NLS-1$ + ((StringBuffer) event.getContent().getValue()).append("\n").append(line); //$NON-NLS-1$ } } rawPos = context.raFile.getFilePointer(); diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java index daba0fb0ad..310b7b9429 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/parsers/custom/CustomXmlTrace.java @@ -189,7 +189,7 @@ public class CustomXmlTrace extends TmfTrace { Element element = parseElementBuffer(elementBuffer); event = extractEvent(element, fRecordInputElement); - ((StringBuffer) event.getContent().getRawContent()).append(elementBuffer); + ((StringBuffer) event.getContent().getValue()).append(elementBuffer); String line; String recordElementStart = "<" + fRecordInputElement.elementName; //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java index adf05e07c6..03945036be 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java @@ -44,10 +44,9 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.LocalResourceManager; import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider; import org.eclipse.linuxtools.tmf.core.component.TmfComponent; -import org.eclipse.linuxtools.tmf.core.event.ITmfEventContent; +import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; -import org.eclipse.linuxtools.tmf.core.event.TmfEventContent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; @@ -238,11 +237,11 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS // Set the default column field ids if this is not a subclass if (Arrays.equals(columnData, COLUMN_DATA)) { - fTable.getColumns()[0].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TIMESTAMP); - fTable.getColumns()[1].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_SOURCE); - fTable.getColumns()[2].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TYPE); - fTable.getColumns()[3].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_REFERENCE); - fTable.getColumns()[4].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_CONTENT); + fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP); + fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_SOURCE); + fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE); + fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE); + fTable.getColumns()[4].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT); } // Set the frozen row for header row @@ -1375,13 +1374,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS protected TmfEventField[] extractItemFields(TmfEvent event) { TmfEventField[] fields = new TmfEventField[0]; if (event != null) { - ITmfEventContent content = event.getContent(); fields = new TmfEventField[] { - new TmfEventField(content, TmfEventContent.FIELD_ID_TIMESTAMP, ((Long) event.getTimestamp().getValue()).toString()), - new TmfEventField(content, TmfEventContent.FIELD_ID_SOURCE, event.getSource()), - new TmfEventField(content, TmfEventContent.FIELD_ID_TYPE, event.getType().getId()), - new TmfEventField(content, TmfEventContent.FIELD_ID_REFERENCE, event.getReference()), - new TmfEventField(content, TmfEventContent.FIELD_ID_CONTENT, event.getContent().toString()) + new TmfEventField(ITmfEvent.EVENT_FIELD_TIMESTAMP, ((Long) event.getTimestamp().getValue()).toString()), + new TmfEventField(ITmfEvent.EVENT_FIELD_SOURCE, event.getSource()), + new TmfEventField(ITmfEvent.EVENT_FIELD_TYPE, event.getType().getName()), + new TmfEventField(ITmfEvent.EVENT_FIELD_REFERENCE, event.getReference()), + new TmfEventField(ITmfEvent.EVENT_FIELD_CONTENT, event.getContent().toString()) }; } return fields; diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java index c257c9f7c9..ed056de094 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java @@ -341,7 +341,7 @@ class FilterViewer extends Composite { TmfEvent event = (TmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); ITmfEventType eventType = event.getType(); if (eventType != null) { - for (String field : eventType.getFieldLabels()) { + for (String field : eventType.getRootField().getFieldNames()) { fieldsList.add(field); } } @@ -380,7 +380,7 @@ class FilterViewer extends Composite { if (eventType != null) { fieldsList.add("[" + TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)) + //$NON-NLS-1$ " : " + ce.getAttribute(TmfTraceType.NAME_ATTR) + "]"); //$NON-NLS-1$ //$NON-NLS-2$ - for (String field : eventType.getFieldLabels()) { + for (String field : eventType.getFieldNames()) { fieldsList.add(field); } fieldsList.add(""); //$NON-NLS-1$ diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java index fc8a1a5a6a..7e7d5d408d 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/impl/TmfUml2SDSyncLoader.java @@ -27,7 +27,6 @@ import org.eclipse.linuxtools.tmf.core.component.TmfComponent; import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.event.TmfEvent; import org.eclipse.linuxtools.tmf.core.event.TmfEventField; -import org.eclipse.linuxtools.tmf.core.event.TmfNoSuchFieldException; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment; @@ -1332,22 +1331,18 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, //type = .*RECEIVE.* or .*SEND.* //content = sender::receiver:,signal: String eventType = tmfEvent.getType().toString(); - if (eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeSend) || - eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeReceive)) { - try { - Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSender); - Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldReceiver); - Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSignal); - if ((sender instanceof TmfEventField) && (receiver instanceof TmfEventField) && (name instanceof TmfEventField)) { - ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent, - ((TmfEventField)sender).getValue().toString(), - ((TmfEventField)receiver).getValue().toString(), - ((TmfEventField)name).getValue().toString()); - - return sdEvent; - } - } catch (TmfNoSuchFieldException e) { - } + if (eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeSend) || eventType.contains(Messages.TmfUml2SDSyncCloader_EventTypeReceive)) { + Object sender = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSender); + Object receiver = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldReceiver); + Object name = tmfEvent.getContent().getField(Messages.TmfUml2SDSyncCloader_FieldSignal); + if ((sender instanceof TmfEventField) && (receiver instanceof TmfEventField) && (name instanceof TmfEventField)) { + ITmfSyncSequenceDiagramEvent sdEvent = new TmfSyncSequenceDiagramEvent(tmfEvent, + ((TmfEventField) sender).getValue().toString(), + ((TmfEventField) receiver).getValue().toString(), + ((TmfEventField) name).getValue().toString()); + + return sdEvent; + } } return null; } -- 2.34.1