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"
* 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;
@RunWith(Suite.class)
@Suite.SuiteClasses({
TmfTimestampTest.class,
+ TmfTimeRangeTest.class,
TmfEventTypeTest.class,
TmfEventFormatTest.class,
TmfEventContentTest.class,
* 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;
/**
* <b><u>TmfEventContentTest</u></b>
* <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfEventContent class.
*/
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());
@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());
}
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());
}
}
* 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;
/**
* <b><u>TmfEventFormatTest</u></b>
* <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfEventFormat class.
*/
public class TmfEventFormatTest {
* 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;
/**
* <b><u>TmfEventTest</u></b>
* <p>
- * TODO: Implement me. Please.
+ * JUNit test suite for the TmfEvent class.
*/
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());
}
}
/**
* <b><u>TmfEventTypeTest</u></b>
* <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfEventType class.
*/
public class TmfEventTypeTest {
--- /dev/null
+/*******************************************************************************
+ * 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)));
+ }
+
+}
* 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;
/**
* <b><u>TmfTimestampTest</u></b>
* <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfTimestamp class.
*/
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());
* 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;
/**
* <b><u>TmfTraceEventTest</u></b>
* <p>
- * TODO: Implement me. Please.
+ * JUnit test suite for the TmfTraceEvent class.
*/
public class TmfTraceEventTest {
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;
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());
}
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());
}
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) {
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) {
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) {
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) {
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) {
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;
@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());
@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());
@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());
@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());
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) {
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) {
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) {
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) {
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) {
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,
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
/*******************************************************************************
- * 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);
}
* 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;
* 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;
/**
* <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)
// 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;
* @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;
* @return
*/
public TmfTimestamp getTimestamp() {
- return fTimestamp;
+ return fEffectiveTimestamp;
+ }
+
+ /**
+ * @return
+ */
+ public TmfTimestamp getOriginalTimestamp() {
+ return fOriginalTimestamp;
}
/**
public TmfEventReference getReference() {
return fReference;
}
+
}
* 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;
* 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;
public String toString() {
return fValue.toString();
}
+
}
* 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;
public TmfEventField[] parse(Object content) {
return new TmfEventField[] { new TmfEventField(content.toString()) };
}
+
}
* 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;
public Object getValue() {
return fReference;
}
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ @Override
+ public String toString() {
+ return fReference.toString();
+ }
+
}
* 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;
public Object getSourceId() {
return fSourceId;
}
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ @Override
+ public String toString() {
+ return fSourceId.toString();
+ }
+
}
* 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;
return fFormat;
}
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ @Override
+ public String toString() {
+ return fTypeId.toString();
+ }
+
}
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
* @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;
}
}
+++ /dev/null
-/*******************************************************************************
- * 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;
- }
-}
* 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;
* <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 {
// 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);
// ========================================================================
// ========================================================================
/**
- * 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);
/**
* 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;
/**
* Copy constructor.
*
- * @param other - the timestamp to clone
+ * @param other
*/
public TmfTimestamp(TmfTimestamp other) {
this(other.fValue, other.fScale, other.fPrecision);
// Operators
// ========================================================================
- @Override
- public String toString() {
- return "[TmfTimestamp:" + fValue + "," + fScale + "," + fPrecision + "]";
- }
-
/**
* Return a shifted and scaled timestamp.
*
* 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
*/
/*
* 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;
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) {
/**
* 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
*/
/**
* 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) {
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
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;
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
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
* 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;
// 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.
*
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>
// 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
* @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);
}
* @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;
/**
* @return the requested time range
*/
- public TmfTimeWindow getRange() {
+ public TmfTimeRange getRange() {
return fRange;
}
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;
/**
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
/**
* @return
*/
- public TmfTimeWindow getTimeRange() {
+ public TmfTimeRange getTimeRange() {
return fTimeRange;
}
location = getCurrentLocation();
event = getNextEvent();
}
- fTimeRange = new TmfTimeWindow(startTime, lastTime);
+ fTimeRange = new TmfTimeRange(startTime, lastTime);
}
seek(0);
} catch (IOException e) {
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;
/**
return fEpoch;
}
- public TmfTimeWindow getTimeRange() {
+ public TmfTimeRange getTimeRange() {
return fStream.getTimeRange();
}