Update for Bug287562 (Event Model code refresh + JUnits)
authorFrancois Chouinard <fchouinard@gmail.com>
Tue, 25 Aug 2009 18:59:16 +0000 (18:59 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Tue, 25 Aug 2009 18:59:16 +0000 (18:59 +0000)
28 files changed:
org.eclipse.linuxtools.tmf.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/AllEventTests.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventContentTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventFormatTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfEventTypeTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimeRangeTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTraceEventTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventLogTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequestTest.java
org.eclipse.linuxtools.tmf/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/TmfCorePlugin.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/ITmfContentParser.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEvent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventField.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventFormat.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventReference.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventSource.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventType.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimeRange.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimeWindow.java [deleted file]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTraceEvent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventRequest.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/eventlog/TmfEventStream.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/eventlog/TmfTrace.java

index 405bd9d4fa1a12287837b2c4a9ec1234ab2d4971..ff905a6e93badfb7d1b3e0319af750e3a5230fe2 100644 (file)
@@ -5,6 +5,5 @@ Bundle-SymbolicName: org.eclipse.linuxtools.tmf.tests
 Bundle-Version: 0.0.1
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: Eclipse
-Require-Bundle: org.junit4;bundle-version="4.5.0"
-Import-Package: org.eclipse.linuxtools.tmf.event,
- org.eclipse.linuxtools.tmf.eventlog
+Require-Bundle: org.junit4;bundle-version="4.5.0",
+ org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
index 11c55f6d24efcbb1c9a3c3c351ac4228b6c987bd..373579f1685f6907bb945ea64acef6075a0db34a 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -18,6 +18,7 @@ import org.junit.runners.Suite;
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
     TmfTimestampTest.class,
+    TmfTimeRangeTest.class,
     TmfEventTypeTest.class,
     TmfEventFormatTest.class,
     TmfEventContentTest.class,
index b2f2bebbcfcba120cc238ae4cd45f484bf8a57e2..4e36cd7137a04568b26752dfa1a1537f9584c3ff 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -19,7 +19,7 @@ import org.junit.Test;
 /**
  * <b><u>TmfEventContentTest</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfEventContent class.
  */
 public class TmfEventContentTest {
 
@@ -29,8 +29,7 @@ public class TmfEventContentTest {
 
        @Test
        public void testTmfEventContent() {
-               TmfEventContent content = new TmfEventContent("Some content",
-                               new TmfEventFormat());
+               TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat());
                assertEquals("getFormat", 1, content.getFormat().getLabels().length);
                assertEquals("getLabels", "Content", content.getFormat().getLabels()[0]);
                assertEquals("getContent", "Some content", content.getContent());
@@ -42,8 +41,7 @@ public class TmfEventContentTest {
 
        @Test
        public void testBasicGetField() {
-               TmfEventContent content = new TmfEventContent("Some content",
-                               new TmfEventFormat());
+               TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat());
                assertEquals("getField", 1, content.getFields().length);
                assertEquals("getField", "Some content", content.getField(0).toString());
        }
@@ -56,8 +54,7 @@ public class TmfEventContentTest {
                assertEquals("getField", "-10", content.getField(1).toString());
                assertEquals("getField", "true", content.getField(2).toString());
                assertEquals("getField", "some string", content.getField(3).toString());
-               assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4)
-                               .toString());
+               assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4).toString());
        }
 
 }
index 523517202fda99bf230de855605db015a582207f..6c89085774c21a5e6895da091cc52d91099fd026 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -19,7 +19,7 @@ import org.junit.Test;
 /**
  * <b><u>TmfEventFormatTest</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfEventFormat class.
  */
 public class TmfEventFormatTest {
 
index c960ae8acf169c9ace77be472fb095bcb3e41383..c6e880ff5f5170fdd85b365360a8b24ff7004f23 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -19,7 +19,7 @@ import org.junit.Test;
 /**
  * <b><u>TmfEventTest</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * JUNit test suite for the TmfEvent class.
  */
 public class TmfEventTest {
 
@@ -40,29 +40,80 @@ public class TmfEventTest {
         TmfEvent event = new TmfEvent(timestamp, source, type, content, reference);
 
         // Check the event timestamp
-        TmfTimestamp evTS = event.getTimestamp();
-        assertEquals("getValue", 12345, evTS.getValue());
-        assertEquals("getscale",     2, evTS.getScale());
-        assertEquals("getPrecision", 5, evTS.getPrecision());
+        TmfTimestamp ts = event.getTimestamp();
+        assertEquals("getValue", 12345, ts.getValue());
+        assertEquals("getscale",     2, ts.getScale());
+        assertEquals("getPrecision", 5, ts.getPrecision());
+
+        // Check the original event timestamp
+        ts = event.getOriginalTimestamp();
+        assertEquals("getValue", 12345, ts.getValue());
+        assertEquals("getscale",     2, ts.getScale());
+        assertEquals("getPrecision", 5, ts.getPrecision());
+
+        // Check the event source
+        TmfEventSource src = event.getSource();
+        assertEquals("getValue", "Source", src.getSourceId());
+
+        // Check the event type
+        TmfEventType tp = event.getType();
+        assertEquals("getValue", "Type", tp.getTypeId());
+        assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]);
+        assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]);
+
+        // Check the event content
+        TmfEventContent cnt = event.getContent();
+        assertEquals("getField", 1, cnt.getFields().length);
+        assertEquals("getField", "Some content", cnt.getField(0).toString());
+
+        // Check the event reference
+        TmfEventReference ref = event.getReference();
+        assertEquals("getValue", "Reference", ref.getValue());
+    }
+
+    @Test
+    public void testTmfEvent2() {
+        TmfTimestamp      original  = new TmfTimestamp(12345, (byte) 2, 5);
+        TmfTimestamp      effective = new TmfTimestamp(12350, (byte) 2, 5);
+        TmfEventSource    source    = new TmfEventSource("Source");
+        TmfEventFormat    format    = new TmfEventFormat(new String[] { "field1", "field2" });
+        TmfEventType      type      = new TmfEventType("Type", format);
+        TmfEventContent   content   = new TmfEventContent("Some content", format);
+        TmfEventReference reference = new TmfEventReference("Reference");
+
+        // Create the event
+        TmfEvent event = new TmfEvent(original, effective, source, type, content, reference);
+
+        // Check the event timestamp
+        TmfTimestamp ts = event.getTimestamp();
+        assertEquals("getValue", 12350, ts.getValue());
+        assertEquals("getscale",     2, ts.getScale());
+        assertEquals("getPrecision", 5, ts.getPrecision());
+
+        // Check the original event timestamp
+        ts = event.getOriginalTimestamp();
+        assertEquals("getValue", 12345, ts.getValue());
+        assertEquals("getscale",     2, ts.getScale());
+        assertEquals("getPrecision", 5, ts.getPrecision());
 
         // Check the event source
-        TmfEventSource evSrc = event.getSource();
-        assertEquals("getValue", "Source", evSrc.getSourceId());
+        TmfEventSource src = event.getSource();
+        assertEquals("getValue", "Source", src.getSourceId());
 
         // Check the event type
-        TmfEventType evType = event.getType();
-        assertEquals("getValue", "Type", evType.getTypeId());
-        assertEquals("getFormat", "field1", evType.getFormat().getLabels()[0]);
-        assertEquals("getFormat", "field2", evType.getFormat().getLabels()[1]);
+        TmfEventType tp = event.getType();
+        assertEquals("getValue", "Type", tp.getTypeId());
+        assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]);
+        assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]);
 
         // Check the event content
-        TmfEventContent evContent = event.getContent();
-        assertEquals("getField", 1, evContent.getFields().length);
-        assertEquals("getField", "Some content", evContent.getField(0).toString());
+        TmfEventContent cnt = event.getContent();
+        assertEquals("getField", 1, cnt.getFields().length);
+        assertEquals("getField", "Some content", cnt.getField(0).toString());
 
         // Check the event reference
-        TmfEventReference evRef = event.getReference();
-        assertEquals("getValue", "Reference", evRef.getValue());
+        TmfEventReference ref = event.getReference();
+        assertEquals("getValue", "Reference", ref.getValue());
     }
 
 }
index 5a2044906eb17ae2a3aa222a4642d14766aa6cae..76eba2ba506a0fa7fc36fa4673210a17a1a628ea 100644 (file)
@@ -19,7 +19,7 @@ import org.junit.Test;
 /**
  * <b><u>TmfEventTypeTest</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfEventType class.
  */
 public class TmfEventTypeTest {
 
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimeRangeTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimeRangeTest.java
new file mode 100644 (file)
index 0000000..a2f7524
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.event;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Test;
+
+/**
+ * <b><u>TmfTimeRangeTest</u></b>
+ * <p>
+ * JUnit test suite for the TmfTimeRange class.
+ */
+public class TmfTimeRangeTest {
+
+    // ========================================================================
+    // Constructors
+    // ========================================================================
+
+    @Test
+    public void testConstructor() throws Exception {
+        TmfTimestamp ts1   = new TmfTimestamp(12345);
+        TmfTimestamp ts2   = new TmfTimestamp(12350);
+        TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+        assertEquals("startTime", ts1, range.getStartTime());
+        assertEquals("endTime",   ts2, range.getEndTime());
+    }
+
+    @Test
+    public void testOpenRange1() throws Exception {
+        TmfTimestamp ts2    = new TmfTimestamp(12350);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, ts2);
+        assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
+        assertEquals("endTime",   ts2, range.getEndTime());
+    }
+
+    @Test
+    public void testOpenRange2() throws Exception {
+        TmfTimestamp ts1   = new TmfTimestamp(12345);
+        TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BigCrunch);
+        assertEquals("startTime", ts1, range.getStartTime());
+        assertEquals("endTime",   TmfTimestamp.BigCrunch, range.getEndTime());
+    }
+
+    @Test
+    public void testOpenRange3() throws Exception {
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        assertEquals("startTime", TmfTimestamp.BigBang,   range.getStartTime());
+        assertEquals("endTime",   TmfTimestamp.BigCrunch, range.getEndTime());
+    }
+
+    // ========================================================================
+    // Constructors
+    // ========================================================================
+
+    @Test
+    public void testContains() throws Exception {
+        TmfTimestamp ts1   = new TmfTimestamp(12345);
+        TmfTimestamp ts2   = new TmfTimestamp(12350);
+        TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+
+        assertTrue("contains (lower bound)",   range.contains(new TmfTimestamp(12345)));
+        assertTrue("contains (higher bound)",  range.contains(new TmfTimestamp(12350)));
+        assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
+
+        assertFalse("contains (low value)",   range.contains(new TmfTimestamp(12340)));
+        assertFalse("contains (high value)",  range.contains(new TmfTimestamp(12351)));
+    }
+
+}
index 9d443664b3fe62f41b39c0aa698aaf12e626be3d..67470399bc20c8f419a83b1bb26c7992ecb01c80 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -19,7 +19,7 @@ import org.junit.Test;
 /**
  * <b><u>TmfTimestampTest</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfTimestamp class.
  */
 public class TmfTimestampTest {
 
@@ -37,6 +37,14 @@ public class TmfTimestampTest {
 
     @Test
     public void testSimpleConstructor() throws Exception {
+        TmfTimestamp ts = new TmfTimestamp(12345);
+        assertEquals("getValue", 12345, ts.getValue());
+        assertEquals("getscale",     0, ts.getScale());
+        assertEquals("getPrecision", 0, ts.getPrecision());
+    }
+
+    @Test
+    public void testSimpleConstructor2() throws Exception {
         TmfTimestamp ts = new TmfTimestamp(12345, (byte) -1);
         assertEquals("getValue", 12345, ts.getValue());
         assertEquals("getscale",    -1, ts.getScale());
index 3cec8e589afa942089eeb2e89cf64eb81cbbdb48..dee1fba659462fd1c0192d43e39a6c5da5071960 100644 (file)
@@ -7,10 +7,9 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
-
 package org.eclipse.linuxtools.tmf.event;
 
 import static org.junit.Assert.assertEquals;
@@ -20,7 +19,7 @@ import org.junit.Test;
 /**
  * <b><u>TmfTraceEventTest</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfTraceEvent class.
  */
 public class TmfTraceEventTest {
 
index e1a8ab3b9f0a90989947b9b46dda12bb50626b65..9b99e820c3bf8d79e95ea980c65dedf049ca4a42 100644 (file)
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue;
 import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -54,7 +54,7 @@ public class TmfEventLogTest {
         assertEquals("GetEpoch", TmfTimestamp.BigBang, eventLog.getEpoch());
         assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
 
-        TmfTimeWindow timeRange = eventLog.getTimeRange();
+        TmfTimeRange timeRange = eventLog.getTimeRange();
         assertEquals("GetTimeRange", 0, timeRange.getStartTime().getValue());
         assertEquals("GetTimeRange", fTotalNbEvents - 1, timeRange.getEndTime().getValue());
        }
@@ -68,7 +68,7 @@ public class TmfEventLogTest {
         assertEquals("GetEpoch", epoch, eventLog.getEpoch());
         assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
 
-        TmfTimeWindow timeRange = eventLog.getTimeRange();
+        TmfTimeRange timeRange = eventLog.getTimeRange();
         assertEquals("GetTimeRange", 0, timeRange.getStartTime().getValue());
         assertEquals("GetTimeRange", fTotalNbEvents - 1, timeRange.getEndTime().getValue());
        }
@@ -86,7 +86,7 @@ public class TmfEventLogTest {
         final int BLOCK_SIZE = 100;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -118,7 +118,7 @@ public class TmfEventLogTest {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
         int nbExpectedEvents = eventLog.getNbEvents();
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -151,7 +151,7 @@ public class TmfEventLogTest {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
         int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -184,7 +184,7 @@ public class TmfEventLogTest {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
         int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -219,7 +219,7 @@ public class TmfEventLogTest {
         final int BLOCK_SIZE = 100;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
index 0901611fd8bca9bdd256dd2d99dfae7c2228f595..8e2b2ed55f6fcd29fcc6d525fb79ad4685b85424 100644 (file)
@@ -17,7 +17,7 @@ import static org.junit.Assert.*;
 import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -42,7 +42,7 @@ public class TmfEventRequestTest {
 
     @Test
     public void testConstructorForRange() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         TmfEventRequest request = new TmfEventRequest(range, 0, -1, 1);
 
         assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
@@ -53,7 +53,7 @@ public class TmfEventRequestTest {
 
     @Test
     public void testConstructorForNbEvents() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         TmfEventRequest request = new TmfEventRequest(range, 0, 10, 1);
 
         assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
@@ -64,7 +64,7 @@ public class TmfEventRequestTest {
 
     @Test
     public void testConstructorWithOffset() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         TmfEventRequest request = new TmfEventRequest(range, 5, 10, 1);
 
         assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
@@ -75,7 +75,7 @@ public class TmfEventRequestTest {
 
     @Test
     public void testConstructorWithNegativeOffset() throws Exception {
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         TmfEventRequest request = new TmfEventRequest(range, -5, 10, 1);
 
         assertEquals("StartTime", TmfTimestamp.BigBang,   request.getRange().getStartTime());
@@ -95,7 +95,7 @@ public class TmfEventRequestTest {
         final int BLOCK_SIZE = 100;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -125,7 +125,7 @@ public class TmfEventRequestTest {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
         int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -156,7 +156,7 @@ public class TmfEventRequestTest {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
         int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -187,7 +187,7 @@ public class TmfEventRequestTest {
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
         int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
@@ -220,7 +220,7 @@ public class TmfEventRequestTest {
         final int BLOCK_SIZE = 100;
         final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
 
-        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
         final TmfEventRequest request = new TmfEventRequest(range, 0, NB_EVENTS, BLOCK_SIZE) {
             @Override
             public void newEvents(Vector<TmfEvent> events) {
index b097f764c1b5c0c825b929d6dad12e768efd0ef9..bde67a2098b5c2ca1bdc3f5d73c73479b48ed0ae 100644 (file)
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
 Bundle-Name: TMF
 Bundle-SymbolicName: org.eclipse.linuxtools.tmf
 Bundle-Version: 0.0.1
-Bundle-Activator: org.eclipse.linuxtools.tmf.Activator
+Bundle-Activator: org.eclipse.linuxtools.tmf.TmfCorePlugin
 Bundle-Vendor: Eclipse
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
@@ -11,5 +11,6 @@ Require-Bundle: org.eclipse.ui,
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Import-Package: org.junit.runner
-Export-Package: org.eclipse.linuxtools.tmf.event,
+Export-Package: org.eclipse.linuxtools.tmf,
+ org.eclipse.linuxtools.tmf.event,
  org.eclipse.linuxtools.tmf.eventlog
index 16378a895b34a43c26859bae95829c3d67f8d28c..e7af05213fa359460de03e27ef1b47d1abd85f6e 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * 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
 
 package org.eclipse.linuxtools.tmf;
 
-import org.eclipse.core.runtime.Plugin;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
 /**
  * <b><u>TmfCorePlugin</u></b>
  * <p>
- * The activator class controls the plug-in life cycle. No more than one such
- * plug-in can exist at any time.
+ * The activator class controls the plug-in life cycle
  */
-public class TmfCorePlugin extends Plugin {
+public class TmfCorePlugin extends AbstractUIPlugin {
 
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Attributes
-       // ------------------------------------------------------------------------
+    // ========================================================================
 
        // The plug-in ID
        public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf";
 
        // The shared instance
-       private static TmfCorePlugin fPlugin;
+       private static TmfCorePlugin plugin;
        
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Constructors
-       // ------------------------------------------------------------------------
+    // ========================================================================
 
        /**
         * The constructor
         */
        public TmfCorePlugin() {
-               setDefault(this);
        }
 
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Accessors
-       // ------------------------------------------------------------------------
+    // ========================================================================
 
     /**
      * @return the shared instance
      */
     public static TmfCorePlugin getDefault() {
-        return fPlugin;
+        return plugin;
     }
 
-       /**
-        * @param plugin the shared instance
-        */
-       private static void setDefault(TmfCorePlugin plugin) {
-               fPlugin = plugin;
-       }
+    // ========================================================================
+    // Operators
+    // ========================================================================
 
-       // ------------------------------------------------------------------------
-    // Operations
-       // ------------------------------------------------------------------------
-
-       @Override
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+        */
        public void start(BundleContext context) throws Exception {
                super.start(context);
-               setDefault(this);
-               Tracer.init();
+               plugin = this;
        }
 
-       @Override
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+        */
        public void stop(BundleContext context) throws Exception {
-               setDefault(null);
+               plugin = null;
                super.stop(context);
        }
 
index ed012a052e66395f6227fa5f40f7f98336864230..0128da4b9d4ea395f214309010d5b7d556749bdb 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
index 1e5896cb652c48c844e7f9dadd9db5f3c87e7707..a60790f7e4a0390e16509d74fdeb1244bc5729be 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -15,9 +15,7 @@ package org.eclipse.linuxtools.tmf.event;
 /**
  * <b><u>TmfEvent</u></b>
  * <p>
- * The basic event structure in the TMF.
- * <p>
- * In its canonical form, an event has:
+ * The basic event structure in the TMF. In its canonical form, an event has:
  * <ul>
  * <li> a normalized timestamp
  * <li> a source (reporter)
@@ -34,7 +32,8 @@ public class TmfEvent {
     // Attributes
     // ========================================================================
 
-       private final TmfTimestamp fTimestamp;
+       private final TmfTimestamp fEffectiveTimestamp;
+       private final TmfTimestamp fOriginalTimestamp;
        private final TmfEventSource fSource;
        private final TmfEventType fType;
        private final TmfEventContent fContent;
@@ -51,10 +50,28 @@ public class TmfEvent {
         * @param content
         * @param reference
         */
-       public TmfEvent(TmfTimestamp timestamp, TmfEventSource source, TmfEventType type,
-                       TmfEventContent content, TmfEventReference reference)
+       public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
+                       TmfEventType type, TmfEventContent content, TmfEventReference reference)
        {
-               fTimestamp = timestamp;
+               fOriginalTimestamp = originalTS;
+               fEffectiveTimestamp = effectiveTS;
+               fSource = source;
+               fType = type;
+               fContent = content;
+               fReference = reference;
+       }
+
+       /**
+        * @param timestamp
+        * @param source
+        * @param type
+        * @param content
+        * @param reference
+        */
+       public TmfEvent(TmfTimestamp timestamp, TmfEventSource source,
+                       TmfEventType type, TmfEventContent content, TmfEventReference reference)
+       {
+               fOriginalTimestamp = fEffectiveTimestamp = timestamp;
                fSource = source;
                fType = type;
                fContent = content;
@@ -69,7 +86,14 @@ public class TmfEvent {
         * @return
         */
        public TmfTimestamp getTimestamp() {
-               return fTimestamp;
+               return fEffectiveTimestamp;
+       }
+
+       /**
+        * @return
+        */
+       public TmfTimestamp getOriginalTimestamp() {
+               return fOriginalTimestamp;
        }
 
        /**
@@ -99,4 +123,5 @@ public class TmfEvent {
        public TmfEventReference getReference() {
                return fReference;
        }
+
 }
index c89c03d4dbc2d44bbef3d91bf6fd6c8b3ae85c05..1b37e7758d52dd9dea091a1d9c8d4218da319b2d 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
index 5cac0bd9f244e1ac7415895e48c52312d911e974..1eb2cb4c7b21e0eb748c2e69fbcce2edbd904277 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -57,4 +57,5 @@ public class TmfEventField {
     public String toString() {
         return fValue.toString();
     }
+
 }
index 783c5f60f76a179220de0ea53046de19cb2c9b7c..6d26b20666dbc9f66a49343612a6df08e3adb4ee 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -68,4 +68,5 @@ public class TmfEventFormat implements ITmfContentParser {
        public TmfEventField[] parse(Object content) {
         return new TmfEventField[] { new TmfEventField(content.toString()) };
     }
+
 }
index aee25f051c35b686fc02c1dfba8e680d402f6189..e06cccc46551b9ad4f03a1dddd19801d08d3e96e 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -46,4 +46,14 @@ public class TmfEventReference {
        public Object getValue() {
                return fReference;
        }
+
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+    @Override
+    public String toString() {
+        return fReference.toString();
+    }
+
 }
index 6bcc4768e5c7e953d26595d9ef3e79bfeeec2422..d827477fbdb891e981483e1993dde85291e2fd8a 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -53,4 +53,14 @@ public class TmfEventSource {
        public Object getSourceId() {
                return fSourceId;
        }
+
+       // ========================================================================
+    // Operators
+    // ========================================================================
+
+    @Override
+    public String toString() {
+        return fSourceId.toString();
+    }
+
 }
index db5f453447a68ece910587bd7236699528e9cd30..56a50d103e9b73a4810050ccc50ef91dbe7d2538 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -57,4 +57,13 @@ public class TmfEventType {
         return fFormat;
     }
 
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+    @Override
+    public String toString() {
+        return fTypeId.toString();
+    }
+
 }
index 4f0c6c8d50025ebb88f9e8a485f37c08cbb2b81a..549ba3d858ec40c612b22d537c54e1d463c459d0 100644 (file)
 package org.eclipse.linuxtools.tmf.event;
 
 /**
- * <b><u>TmfTimeRange</u></b>
+ * <b><u>TmfTimeWindow</u></b>
  * <p>
  * A utility class to define time ranges.
  */
 public class TmfTimeRange {
 
-       // ------------------------------------------------------------------------
-    // Constants
-       // ------------------------------------------------------------------------
-
-       public static final TmfTimeRange Eternity = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-       
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Attributes
-       // ------------------------------------------------------------------------
+    // ========================================================================
 
        private final TmfTimestamp fStartTime;
        private final TmfTimestamp fEndTime;
 
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Constructors
-       // ------------------------------------------------------------------------
-
-       @SuppressWarnings("unused")
-       private TmfTimeRange() {
-               throw new AssertionError();
-       }
+    // ========================================================================
 
        /**
         * @param startTime
         * @param endTime
         */
        public TmfTimeRange(TmfTimestamp startTime, TmfTimestamp endTime) {
-               if (startTime == null || endTime == null) {
-               throw new IllegalArgumentException();
-               }
-               fStartTime =  new TmfTimestamp(startTime);
-               fEndTime   =  new TmfTimestamp(endTime);
-       }
-       
-       /**
-        * Copy constructor
-        * @param other
-        */
-       public TmfTimeRange(TmfTimeRange other) {
-       if (other == null) {
-               throw new IllegalArgumentException();
-       }
-               fStartTime = new TmfTimestamp(other.fStartTime);
-               fEndTime   = new TmfTimestamp(other.fEndTime);
+               fStartTime = startTime;
+               fEndTime   = endTime;
        }
 
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Accessors
-       // ------------------------------------------------------------------------
+    // ========================================================================
 
        /**
         * @return The time range start time
         */
        public TmfTimestamp getStartTime() {
-               return new TmfTimestamp(fStartTime);
+               return fStartTime;
        }
 
        /**
         * @return The time range end time
         */
        public TmfTimestamp getEndTime() {
-               return new TmfTimestamp(fEndTime);
+               return fEndTime;
        }
 
-       // ------------------------------------------------------------------------
+    // ========================================================================
     // Predicates
-       // ------------------------------------------------------------------------
+    // ========================================================================
 
        /**
         * Check if the timestamp is within the time range
@@ -94,44 +68,8 @@ public class TmfTimeRange {
         * @return
         */
        public boolean contains(TmfTimestamp ts) {
-               return (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
-       }
-
-       /**
-        * Check if the time range is within the time range
-        * 
-        * @param range
-        * @return
-        */
-       public boolean contains(TmfTimeRange range) {
-               TmfTimestamp startTime = range.getStartTime();
-               TmfTimestamp endTime   = range.getEndTime();
-               return (fStartTime.compareTo(startTime, true) <= 0) && (fEndTime.compareTo(endTime, true) >= 0);
-       }
-
-       // ------------------------------------------------------------------------
-    // Object
-       // ------------------------------------------------------------------------
-
-       @Override
-    public int hashCode() {
-               int result = 17;
-               result = 37 * result + fStartTime.hashCode();
-               result = 37 * result + fEndTime.hashCode();
-        return result;
-    }
-
-       @Override
-    public boolean equals(Object other) {
-       if (!(other instanceof TmfTimeRange))
-               return false;
-               TmfTimeRange range = (TmfTimeRange) other;
-               return range.fStartTime.equals(fStartTime) && range.fEndTime.equals(fEndTime);
-    }
-
-       @Override
-       public String toString() {
-               return "[TmfTimeRange(" + fStartTime + ":" + fEndTime + ")]";
+               boolean result = (fStartTime.compareTo(ts, true) <= 0) && (fEndTime.compareTo(ts, true) >= 0);
+               return result;
        }
 
 }
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimeWindow.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimeWindow.java
deleted file mode 100644 (file)
index a9064d3..0000000
+++ /dev/null
@@ -1,59 +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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.event;
-
-/**
- * <b><u>TmfTimeWindow</u></b>
- * <p>
- * A utility class to define time ranges.
- */
-public class TmfTimeWindow {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-       private final TmfTimestamp fStartTime;
-       private final TmfTimestamp fEndTime;
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-       /**
-        * @param startTime
-        * @param endTime
-        */
-       public TmfTimeWindow(TmfTimestamp startTime, TmfTimestamp endTime) {
-               fStartTime = startTime;
-               fEndTime   = endTime;
-       }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-       /**
-        * @return The time range start time
-        */
-       public TmfTimestamp getStartTime() {
-               return fStartTime;
-       }
-
-       /**
-        * @return The time range end time
-        */
-       public TmfTimestamp getEndTime() {
-               return fEndTime;
-       }
-}
index aefe658d9df640ed6e0c30b044f4dfe816f4b569..447b2b5184ea107f2b4b0acb7d5ce9fbbb3dc623 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -19,20 +19,20 @@ package org.eclipse.linuxtools.tmf.event;
  * <p>
  * It provides a generic timestamp implementation in its most basic form:
  * <ul>
- * <li> an unstructured integer value
- * <li> a time scale corresponding to the magnitude of the value wrt some
- *      application-specific base unit (e.g. the second)
- * <li> a precision to indicate the error on the value (useful for comparing
- *      timestamps in different scales). Default: 0.
+ * <li>an unstructured integer value
+ * <li>a time scale corresponding to the magnitude of the value wrt some
+ * application-specific base unit (e.g. the second)
+ * <li>a precision to indicate the error on the value (useful for comparing
+ * timestamps in different scales). Default: 0.
  * </ul>
- * To allow synchronization of timestamps from different reference clocks,
- * there is a possibility to "adjust" the timestamp both by changing its
- * scale (traces of different scale) and by adding an offset to its value
- * (clock drift between traces). 
+ * To allow synchronization of timestamps from different reference clocks, there
+ * is a possibility to "adjust" the timestamp both by changing its scale (traces
+ * of different scale) and by adding an offset to its value (clock drift between
+ * traces).
  * <p>
- * Note that the adjusted timestamp value could be negative e.g. for events
- * that occurred before t0 of the reference clock.
- *
+ * Note that the adjusted timestamp value could be negative e.g. for events that
+ * occurred before t0 of the reference clock.
+ * 
  */
 public class TmfTimestamp {
 
@@ -40,16 +40,16 @@ public class TmfTimestamp {
     // Attributes
     // ========================================================================
 
-    private final long fValue;       // The timestamp value
-    private final byte fScale;       // The time scale 
-    private final long fPrecision;   // The value precision (tolerance)
+    protected final long fValue; // The timestamp value
+    protected final byte fScale; // The time scale
+    protected final long fPrecision; // The value precision (tolerance)
 
     // ========================================================================
     // Constants
     // ========================================================================
 
     // The beginning and end of time
-    public static final TmfTimestamp BigBang   = new TmfTimestamp(0, (byte) 0, 0);
+    public static final TmfTimestamp BigBang = new TmfTimestamp(0, (byte) 0, 0);
     public static final TmfTimestamp BigCrunch = new TmfTimestamp(Long.MAX_VALUE, Byte.MAX_VALUE, 0);
 
     // ========================================================================
@@ -57,17 +57,24 @@ public class TmfTimestamp {
     // ========================================================================
 
     /**
-     * Default constructor. 
+     * Default constructor.
      */
     public TmfTimestamp() {
         this(0, (byte) 0, 0);
     }
 
+    /**
+     * Simple constructor.
+     */
+    public TmfTimestamp(long value) {
+        this(value, (byte) 0, 0);
+    }
+
     /**
      * Simple constructor with default error value
      * 
-     * @param value - the original time value
-     * @param scale - the time scale
+     * @param value
+     * @param scale
      */
     public TmfTimestamp(long value, byte scale) {
         this(value, scale, 0);
@@ -76,9 +83,9 @@ public class TmfTimestamp {
     /**
      * Constructor with measurement error.
      * 
-     * @param value - the time value
-     * @param scale - the time scale
-     * @param precision - the value precision (tolerance)
+     * @param value
+     * @param scale
+     * @param precision
      */
     public TmfTimestamp(long value, byte scale, long precision) {
         fValue = value;
@@ -89,7 +96,7 @@ public class TmfTimestamp {
     /**
      * Copy constructor.
      * 
-     * @param other - the timestamp to clone
+     * @param other
      */
     public TmfTimestamp(TmfTimestamp other) {
         this(other.fValue, other.fScale, other.fPrecision);
@@ -124,11 +131,6 @@ public class TmfTimestamp {
     // Operators
     // ========================================================================
 
-    @Override
-    public String toString() {
-        return "[TmfTimestamp:" + fValue + "," + fScale + "," + fPrecision + "]";
-    }
-
     /**
      * Return a shifted and scaled timestamp.
      * 
@@ -137,9 +139,11 @@ public class TmfTimestamp {
      * meaning beyond that scale difference and it's not even worth the trouble
      * to switch to BigDecimal arithmetics.
      * 
-     * @param offset - the shift value (in the same scale as newScale)
-     * @param newScale - the new scale
-     * @return The synchronized timestamp 
+     * @param offset
+     *            - the shift value (in the same scale as newScale)
+     * @param newScale
+     *            - the new scale
+     * @return The synchronized timestamp
      */
 
     /*
@@ -150,6 +154,7 @@ public class TmfTimestamp {
      * difference in scale exceeds that value.
      */
     private static int MAX_SCALING = 19;
+
     public TmfTimestamp synchronize(long offset, byte newScale) throws ArithmeticException {
         long newValue = fValue;
         long newPrecision = fPrecision;
@@ -161,8 +166,9 @@ public class TmfTimestamp {
             if (scaleDiff > MAX_SCALING) {
                 throw new ArithmeticException("Scaling exception");
             }
+            // Not pretty...
             long scalingFactor = 1;
-            for (int i = 0; i < Math.abs(fScale - newScale); i++) {
+            for (int i = 0; i < scaleDiff; i++) {
                 scalingFactor *= 10;
             }
             if (newScale < fScale) {
@@ -179,9 +185,10 @@ public class TmfTimestamp {
 
     /**
      * Compute the adjustment, in the reference scale, needed to synchronize
-     *  this timestamp with a reference timestamp.
+     * this timestamp with a reference timestamp.
      * 
-     * @param reference - the reference timestamp to synchronize with
+     * @param reference
+     *            - the reference timestamp to synchronize with
      * @return The adjustment term in the reference time scale
      * @throws TmfNumericalException
      */
@@ -193,11 +200,12 @@ public class TmfTimestamp {
     /**
      * Compare with another timestamp
      * 
-     * @param other - the otehr timestamp
-     * @param withinPrecision - indicates if precision is to be take into consideration
-     * @return <li> -1: this timestamp is lower
-     *         <li>  0: timestamps are equal (within precision if requested)
-     *         <li>  1: this timestamp is higher 
+     * @param other
+     *            - the other timestamp
+     * @param withinPrecision
+     *            - indicates if precision is to be take into consideration
+     * @return <li>-1: this timestamp is lower <li>0: timestamps are equal
+     *         (within precision if requested) <li>1: this timestamp is higher
      * @throws TmfNumericalException
      */
     public int compareTo(final TmfTimestamp other, boolean withinPrecision) {
@@ -211,8 +219,8 @@ public class TmfTimestamp {
                     return 1;
                 return 0;
             }
-            return (fValue == other.fValue) ?  0 :
-                   (fValue  < other.fValue) ? -1 : 1;
+            return (fValue == other.fValue) ? 0 : (fValue < other.fValue) ? -1
+                    : 1;
         }
 
         // If values have different time scales, adjust to the finest one and
@@ -226,7 +234,8 @@ public class TmfTimestamp {
             return ts1.compareTo(ts2, withinPrecision);
         } catch (ArithmeticException e) {
             if ((fValue == 0) || (other.fValue == 0)) {
-                return (fValue == other.fValue) ? 0 : (fValue < other.fValue) ? -1 : 1;
+                return (fValue == other.fValue) ? 0
+                        : (fValue < other.fValue) ? -1 : 1;
             }
             if ((fValue > 0) && (other.fValue > 0)) {
                 return (fScale < other.fScale) ? -1 : 1;
@@ -238,7 +247,9 @@ public class TmfTimestamp {
         }
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see java.lang.Object#equals(java.lang.Object)
      */
     @Override
@@ -248,4 +259,12 @@ public class TmfTimestamp {
         return super.equals(other);
     }
 
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+       return "[TmfTimestamp:" + fValue + "," + fScale + "," + fPrecision + "]";
+    }
+
 }
\ No newline at end of file
index c755c0d9b57c4ba7a9b68e2d3926bbd917a2b112..90e4ef956999e8cb9813e5e598a01b34d9fce3c1 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -36,6 +36,25 @@ public class TmfTraceEvent extends TmfEvent {
     // Constructors
     // ========================================================================
 
+       /**
+        * The constructor.
+        * 
+        * @param timestamp
+        * @param source
+        * @param type
+        * @param content
+        * @param reference
+        */
+       public TmfTraceEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
+                       TmfEventType type, TmfEventContent content, TmfEventReference reference,
+                       String path, String file, int line)
+       {
+               super(originalTS, effectiveTS, source, type,content, reference);
+               fSourcePath = path;
+               fFileName = file;
+               fLineNumber = line;
+       }
+
        /**
         * The constructor.
         * 
index e647a5e7f11902a5f38a0cbf5899cb4a529e9e60..2513160c20733f4cc4719b1603d92e3436d0c841 100644 (file)
@@ -15,7 +15,7 @@ package org.eclipse.linuxtools.tmf.eventlog;
 import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 
 /**
  * <b><u>TmfEventRequest</u></b>
@@ -68,7 +68,7 @@ public class TmfEventRequest {
     // Attributes
     // ========================================================================
 
-    private final TmfTimeWindow fRange;     // The requested events timestamp range
+    private final TmfTimeRange fRange;     // The requested events timestamp range
     private final long fOffset;             // The synchronization offset to apply
     private final int  fNbRequestedEvents;  // The number of events to read (-1 == the whole range)
     private final int  fBlockSize;          // The maximum number of events per chunk
@@ -86,7 +86,7 @@ public class TmfEventRequest {
      * @param offset
      * @param nbEvents
      */
-    public TmfEventRequest(TmfTimeWindow range, long offset, int nbEvents) {
+    public TmfEventRequest(TmfTimeRange range, long offset, int nbEvents) {
         this(range, offset, nbEvents, DEFAULT_BLOCK_SIZE);
     }
 
@@ -96,7 +96,7 @@ public class TmfEventRequest {
      * @param nbEvents
      * @param maxBlockSize Size of the largest blocks expected
      */
-    public TmfEventRequest(TmfTimeWindow range, long offset, int nbEvents, int maxBlockSize) {
+    public TmfEventRequest(TmfTimeRange range, long offset, int nbEvents, int maxBlockSize) {
         fRange = range;
         fOffset = offset;
         fNbRequestedEvents = nbEvents;
@@ -110,7 +110,7 @@ public class TmfEventRequest {
     /**
      * @return the requested time range
      */
-    public TmfTimeWindow getRange() {
+    public TmfTimeRange getRange() {
         return fRange;
     }
 
index ccb540f456bb7d1d0f0c2346509401cfb5eb92ab..30deb8e349b93af112320aec4514547b8283f935 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Collections;
 import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
@@ -55,7 +55,7 @@ public abstract class TmfEventStream extends RandomAccessFile implements ITmfStr
     private int fNbEvents = 0;
 
     // The time span of the event stream 
-    private TmfTimeWindow fTimeRange = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigBang);
+    private TmfTimeRange fTimeRange = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigBang);
     
     // ========================================================================
     // Constructors
@@ -105,7 +105,7 @@ public abstract class TmfEventStream extends RandomAccessFile implements ITmfStr
     /**
      * @return
      */
-    public TmfTimeWindow getTimeRange() {
+    public TmfTimeRange getTimeRange() {
         return fTimeRange;
     }
 
@@ -184,7 +184,7 @@ public abstract class TmfEventStream extends RandomAccessFile implements ITmfStr
                     location = getCurrentLocation();
                     event = getNextEvent();
                 }
-                fTimeRange = new TmfTimeWindow(startTime, lastTime);
+                fTimeRange = new TmfTimeRange(startTime, lastTime);
             }
             seek(0);
         } catch (IOException e) {
index 570f5316ce2033f7b8158f7e8f8f230045aff916..4b7845d5f17b1396e9076721a3ee404465524d2a 100644 (file)
@@ -16,7 +16,7 @@ import java.io.IOException;
 import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeWindow;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
@@ -79,7 +79,7 @@ public class TmfTrace implements ITmfRequestHandler {
        return fEpoch;
     }
 
-    public TmfTimeWindow getTimeRange() {
+    public TmfTimeRange getTimeRange() {
        return fStream.getTimeRange();
     }
 
This page took 0.050183 seconds and 5 git commands to generate.