From b2c971ecac12f2de7314bbc59c5b0ee4391e70f0 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Sun, 28 Feb 2016 09:59:03 -0500 Subject: [PATCH] tmf.core: Introduce TmfTimestamp factory methods Often times, a TmfTimestamp will be created using a scale of -9 or 0. The result is a less efficient timestamp that takes more memory than the nano or simple timestamp and is slower to compare. This patch makes timestamps created always return the more efficient type. At the moment, the factory will either create a new TmfNanoTimestamp if the scale is NANOSECOND_SCALE, TmfSecondTimestamp if the scale is SECOND_SCALE, or a plain old TmfTimestamp (TmfRealTimestamp). This patch adds the following helper methods: * create(value, scale) - create a timestamp with an arbitrary scale and value * fromNanos(value) - create a nanosecond based timestamp (more efficient) * fromMicros(value) - create a microsecond based timestamp * fromMillis(value) - create a millisecond based timestamp * fromSeconds(value) - create a second based timestamp (more efficient) Also, TmfTimestamp is converted to an abstract class with "getScale()" and "getValue()" needing to be implemented. This allows a timestamp like TmfNanoTimestamp or TmfSecondTimestamp to not store an extra integer and save 33% of their sizes. Change-Id: I0996c9b4f626a70436b58e82446ed69d2e50af98 Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/65312 Reviewed-by: Patrick Tasse Tested-by: Patrick Tasse Reviewed-by: Hudson CI --- .../graph/core/tests/graph/TmfGraphTest.java | 16 +- .../SystemCallLatencyDensityViewTest.java | 5 +- .../segmentstore/density/ZoomOutAction.java | 2 +- .../AbstractSegmentStoreTableViewer.java | 10 +- ...gmentStoreScatterGraphTooltipProvider.java | 3 +- .../btf/core/tests/trace/BtfTraceTest.java | 4 +- .../btf/core/trace/BtfTimestampFormat.java | 2 +- .../trace/CTFTraceGrowingStreamTest.java | 4 +- .../tests/types/ArrayDefinition2Test.java | 2 +- .../tracecompass/ctf/parser/CTFLexer.java | 13 +- .../tracecompass/ctf/parser/CTFParser.java | 31 ++- .../core/tests/context/CtfLocationTest.java | 2 +- .../tests/event/CtfTmfLostEventsTest.java | 16 +- .../core/tests/event/EventContextTest.java | 3 +- .../tests/temp/request/TmfSchedulerTest.java | 19 +- .../tracemanager/TmfTraceManagerTest.java | 78 +++--- .../ctf/core/tests/trace/CtfTmfTraceTest.java | 5 +- .../tmf/ctf/core/event/CtfTmfEvent.java | 7 +- .../ctf/core/event/CtfTmfEventFactory.java | 8 +- .../tmf/ctf/core/event/CtfTmfLostEvent.java | 3 +- .../tmf/ctf/core/trace/CtfTmfTrace.java | 7 +- .../doc/Developer-Guide.mediawiki | 14 +- .../gdbtrace/core/trace/DsfGdbAdaptor.java | 61 ++--- .../ui/views/events/GdbEventsTable.java | 2 +- .../common/core/tests/ActivatorTest.java | 1 - .../tests/model/impl/BaseEventInfoTest.java | 5 +- .../tests/model/impl/ChannelInfoTest.java | 6 +- .../core/tests/model/impl/DomainInfoTest.java | 5 +- .../core/tests/model/impl/FieldInfoTest.java | 6 +- .../tests/model/impl/ProbeEventInfoTest.java | 6 +- .../tests/model/impl/SessionInfoTest.java | 7 +- .../tests/model/impl/UstProviderInfoTest.java | 5 +- .../ui/relayd/LttngRelaydConsumer.java | 7 +- .../kernel/core/tests/ActivatorTest.java | 4 +- .../tests/ControlFlowViewSortingTest.java | 2 +- .../ui/swtbot/tests/ControlFlowViewTest.java | 26 +- .../ui/swtbot/tests/ResourcesViewTest.java | 26 +- .../lttng2/ust/core/tests/ActivatorTest.java | 4 +- .../lttng2/ust/core/trace/LttngUstEvent.java | 4 +- .../ust/core/trace/LttngUstEventFactory.java | 4 +- .../ui/swtbot/tests/CallStackViewTest.java | 4 +- .../pcap/core/tests/event/PcapEventTest.java | 3 +- .../tmf/pcap/core/event/TmfPacketStream.java | 4 +- .../tmf/pcap/core/util/PcapEventFactory.java | 4 +- .../stubs/PatternSegmentFactoryStub.java | 4 +- .../core/segment/TmfXmlPatternSegment.java | 4 +- .../AnalysisRequirementHelperTest.java | 2 +- .../requirements/AnalysisRequirementTest.java | 13 +- .../tests/component/TmfEventProviderTest.java | 11 +- .../tmf/core/tests/event/TmfEventTest.java | 5 +- .../tests/event/TmfNanoTimestampTest.java | 75 +++--- ...pTest.java => TmfSecondTimestampTest.java} | 133 ++++------ .../core/tests/event/TmfTimeRangeTest.java | 110 ++++----- .../tests/event/TmfTimestampDeltaTest.java | 9 +- .../core/tests/event/TmfTimestampTest.java | 191 +++++++-------- .../tests/filter/TmfCollapseFilterTest.java | 4 +- .../tests/filter/TmfFilterAndNodeTest.java | 4 +- .../filter/TmfFilterCompareNodeTest.java | 8 +- .../filter/TmfFilterContainsNodeTest.java | 6 +- .../tests/filter/TmfFilterEqualsNodeTest.java | 6 +- .../filter/TmfFilterMatchesNodeTest.java | 6 +- .../core/tests/filter/TmfFilterNodeTest.java | 4 +- .../tests/filter/TmfFilterOrNodeTest.java | 4 +- .../tests/filter/TmfFilterRootNodeTest.java | 4 +- .../filter/TmfFilterTraceTypeNodeTest.java | 8 +- .../request/TmfCoalescedEventRequestTest.java | 5 +- .../tests/request/TmfEventRequestTest.java | 14 +- .../mipmap/TmfMipmapStateProviderStub.java | 4 +- .../TmfMipmapStateProviderWeightedTest.java | 2 +- .../core/tests/synchronization/SyncTest.java | 4 +- .../TsTransformFactoryTest.java | 27 +- .../synchronization/TsTransformTest.java | 2 +- .../tmf/core/tests/trace/TmfContextTest.java | 3 +- .../core/tests/trace/TmfExperimentTest.java | 42 ++-- .../trace/TmfMultiTraceExperimentTest.java | 56 ++--- .../tmf/core/tests/trace/TmfTraceTest.java | 58 ++--- .../AbstractCheckpointCollectionTest.java | 32 +-- .../core/tests/trace/indexer/AllBench.java | 8 +- .../core/tests/trace/indexer/BTreeTest.java | 6 +- .../tests/trace/indexer/FlatArrayTest.java | 6 +- .../trace/indexer/TmfMemoryIndexTest.java | 6 +- .../checkpoint/TmfCheckpointIndexTest2.java | 15 +- .../indexer/checkpoint/TmfCheckpointTest.java | 4 +- .../TmfExperimentCheckpointIndexTest.java | 2 +- .../tests/trace/location/TmfLocationTest.java | 5 +- .../core/tests/trace/text/TextTraceTest.java | 4 +- .../TmfAsyncSequenceDiagramEventTest.java | 5 +- .../TmfSyncSequenceDiagramEventTest.java | 3 +- .../TmfSyntheticEventProviderStub.java | 2 +- .../tmf/tests/stubs/trace/TmfTraceStub.java | 4 +- .../tests/stubs/trace/text/SyslogTrace.java | 4 +- .../stubs/trace/xml/TmfXmlTraceStub.java | 4 +- .../partial/PartialHistoryBackend.java | 5 +- .../statesystem/mipmap/AvgMipmapFeature.java | 2 +- .../synchronization/TmfConstantTransform.java | 3 +- .../TmfTimestampTransformLinear.java | 2 +- .../TmfTimestampTransformLinearFast.java | 2 +- .../AbstractFileCheckpointCollection.java | 6 +- .../tmf/core/trace/indexer/BTreeNode.java | 2 +- .../tmf/core/trace/indexer/FlatArray.java | 2 +- .../filter/model/TmfFilterCompareNode.java | 4 +- .../tmf/core/parsers/custom/CustomEvent.java | 5 +- .../core/statistics/TmfEventsStatistics.java | 12 +- .../tmf/core/timestamp/TmfNanoTimestamp.java | 26 +- .../tmf/core/timestamp/TmfRealTimestamp.java | 60 +++++ ...Timestamp.java => TmfSecondTimestamp.java} | 43 ++-- .../tmf/core/timestamp/TmfTimestamp.java | 231 +++++++++--------- .../tmf/core/timestamp/TmfTimestampDelta.java | 27 +- .../tracecompass/tmf/core/trace/TmfTrace.java | 5 +- .../tmf/core/trace/TmfTraceManager.java | 2 +- .../indexer/checkpoint/TmfCheckpoint.java | 3 +- .../trace/location/TmfTimestampLocation.java | 5 +- .../core/tests/shell/CommandShellTest.java | 2 +- .../histogram/HistogramDataModelTest.java | 41 ++-- .../TmfBaseColumnDataProviderTest.java | 9 +- .../statistics/TmfBaseColumnDataTest.java | 2 +- .../statistics/TmfBaseStatisticsDataTest.java | 7 +- .../TmfTreeContentProviderTest.java | 5 +- .../uml2sd/loader/IUml2SdSignalValidator.java | 6 +- .../loader/TmfUml2SDSyncLoaderSignalTest.java | 2 +- .../loader/TmfUml2SDSyncLoaderTimeTest.java | 2 +- .../uml2sd/loader/Uml2SDSignalValidator.java | 14 +- .../uml2sd/loader/Uml2SDTestTimestamp.java | 17 +- .../tmf/ui/tests/uml2sd/load/TestLoaders.java | 6 +- .../uml2sd/trace/TmfUml2SDTestTrace.java | 2 +- .../LostEventsMarkerEventSourceFactory.java | 2 +- .../CustomXmlParserInputWizardPage.java | 2 +- .../project/dialogs/offset/OffsetDialog.java | 30 +-- .../ui/views/TmfAlignmentSynchronizer.java | 2 +- .../tmf/ui/viewers/TmfTimeViewer.java | 8 +- .../tmf/ui/viewers/events/TmfEventsTable.java | 70 +++--- .../viewers/tree/AbstractTmfTreeViewer.java | 4 +- .../TmfClosestDataPointTooltipProvider.java | 15 +- .../xycharts/TmfSimpleTooltipProvider.java | 3 +- .../TmfHistogramTooltipProvider.java | 5 +- .../TmfCommonXLineChartTooltipProvider.java | 3 +- .../tmf/ui/views/callstack/CallStackView.java | 11 +- .../tmf/ui/views/histogram/Histogram.java | 6 +- .../HistogramCurrentTimeControl.java | 3 +- .../histogram/HistogramTimeRangeControl.java | 2 +- .../tmf/ui/views/histogram/HistogramView.java | 16 +- .../statesystem/TmfStateSystemViewer.java | 16 +- .../tmf/ui/views/timechart/TimeChartView.java | 9 +- .../timegraph/AbstractTimeGraphView.java | 15 +- .../ui/views/uml2sd/TimeCompressionBar.java | 4 +- .../ui/views/uml2sd/core/AsyncMessage.java | 4 +- .../tmf/ui/views/uml2sd/core/BasicFrame.java | 10 +- .../tmf/ui/views/uml2sd/core/SyncMessage.java | 2 +- .../ui/views/uml2sd/dialogs/MinMaxDialog.java | 4 +- .../uml2sd/loader/TmfUml2SDSyncLoader.java | 2 +- 150 files changed, 1130 insertions(+), 1068 deletions(-) rename tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/{TmfSimpleTimestampTest.java => TmfSecondTimestampTest.java} (60%) create mode 100644 tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfRealTimestamp.java rename tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/{TmfSimpleTimestamp.java => TmfSecondTimestamp.java} (73%) diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphTest.java b/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphTest.java index 8d7c0e62f5..d064026bb7 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphTest.java @@ -284,14 +284,14 @@ public class TmfGraphTest { vertices[i] = v; fGraph.append(WORKER1, v); } - assertEquals(vertices[0], fGraph.getVertexAt(new TmfTimestamp(5), WORKER1)); - assertEquals(vertices[0], fGraph.getVertexAt(new TmfTimestamp(0), WORKER1)); - assertEquals(vertices[1], fGraph.getVertexAt(new TmfTimestamp(6), WORKER1)); - assertEquals(vertices[3], fGraph.getVertexAt(new TmfTimestamp(19), WORKER1)); - assertNull(fGraph.getVertexAt(new TmfTimestamp(19), WORKER2)); - assertEquals(vertices[3], fGraph.getVertexAt(new TmfTimestamp(20), WORKER1)); - assertEquals(vertices[4], fGraph.getVertexAt(new TmfTimestamp(21), WORKER1)); - assertNull(fGraph.getVertexAt(new TmfTimestamp(26), WORKER1)); + assertEquals(vertices[0], fGraph.getVertexAt(TmfTimestamp.fromSeconds(5), WORKER1)); + assertEquals(vertices[0], fGraph.getVertexAt(TmfTimestamp.fromSeconds(0), WORKER1)); + assertEquals(vertices[1], fGraph.getVertexAt(TmfTimestamp.fromSeconds(6), WORKER1)); + assertEquals(vertices[3], fGraph.getVertexAt(TmfTimestamp.fromSeconds(19), WORKER1)); + assertNull(fGraph.getVertexAt(TmfTimestamp.fromSeconds(19), WORKER2)); + assertEquals(vertices[3], fGraph.getVertexAt(TmfTimestamp.fromSeconds(20), WORKER1)); + assertEquals(vertices[4], fGraph.getVertexAt(TmfTimestamp.fromSeconds(21), WORKER1)); + assertNull(fGraph.getVertexAt(TmfTimestamp.fromSeconds(26), WORKER1)); } /** diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyDensityViewTest.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyDensityViewTest.java index 1a825a406d..eeccab6635 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyDensityViewTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyDensityViewTest.java @@ -13,7 +13,10 @@ package org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests.latency; import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertVisible; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.lang.reflect.Field; diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/ZoomOutAction.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/ZoomOutAction.java index 9f5c01d45b..43f6e2594f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/ZoomOutAction.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/ZoomOutAction.java @@ -13,8 +13,8 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.AnalysisTimingImageConstants; import org.eclipse.tracecompass.common.core.NonNullUtils; -import org.swtchart.Range; import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator; +import org.swtchart.Range; /** * Zoom action for the density view diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java index 60fb8fb22c..43693b5a6a 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java @@ -45,7 +45,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; @@ -104,8 +104,8 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView @Override public void widgetSelected(@Nullable SelectionEvent e) { ISegment selectedSegment = ((ISegment) NonNullUtils.checkNotNull(e).item.getData()); - ITmfTimestamp start = new TmfNanoTimestamp(selectedSegment.getStart()); - ITmfTimestamp end = new TmfNanoTimestamp(selectedSegment.getEnd()); + ITmfTimestamp start = TmfTimestamp.fromNanos(selectedSegment.getStart()); + ITmfTimestamp end = TmfTimestamp.fromNanos(selectedSegment.getEnd()); TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, start, end)); } } @@ -279,14 +279,14 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView IAction gotoStartTime = new Action(Messages.SegmentStoreTableViewer_goToStartEvent) { @Override public void run() { - broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, new TmfNanoTimestamp(segment.getStart()))); + broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getStart()))); } }; IAction gotoEndTime = new Action(Messages.SegmentStoreTableViewer_goToEndEvent) { @Override public void run() { - broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, new TmfNanoTimestamp(segment.getEnd()))); + broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getEnd()))); } }; diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java index 50d22ce38c..395b11847f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/views/segmentstore/scatter/SegmentStoreScatterGraphTooltipProvider.java @@ -14,7 +14,6 @@ package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore. import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfClosestDataPointTooltipProvider; @@ -57,7 +56,7 @@ public class SegmentStoreScatterGraphTooltipProvider extends TmfClosestDataPoint if ((xS != null) && (yS != null) && (dataIndex < xS.length) && (dataIndex < yS.length)) { StringBuffer buffer = new StringBuffer(); buffer.append(checkNotNull(Messages.SegmentStoreScatterGraphViewer_xAxis)).append('='); - buffer.append(new TmfTimestamp((long) xS[dataIndex] + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString()); + buffer.append(TmfTimestamp.fromNanos((long) xS[dataIndex] + getChartViewer().getTimeOffset()).toString()); buffer.append('\n'); buffer.append(Messages.SegmentStoreScatterGraphViewer_yAxis).append('='); buffer.append((long) yS[dataIndex]); diff --git a/btf/org.eclipse.tracecompass.btf.core.tests/src/org/eclipse/tracecompass/btf/core/tests/trace/BtfTraceTest.java b/btf/org.eclipse.tracecompass.btf.core.tests/src/org/eclipse/tracecompass/btf/core/tests/trace/BtfTraceTest.java index f7afd0084f..a5adae9449 100644 --- a/btf/org.eclipse.tracecompass.btf.core.tests/src/org/eclipse/tracecompass/btf/core/tests/trace/BtfTraceTest.java +++ b/btf/org.eclipse.tracecompass.btf.core.tests/src/org/eclipse/tracecompass/btf/core/tests/trace/BtfTraceTest.java @@ -11,7 +11,9 @@ *******************************************************************************/ package org.eclipse.tracecompass.btf.core.tests.trace; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.util.Map; diff --git a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfTimestampFormat.java b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfTimestampFormat.java index 8953f62be0..f02819a0a2 100644 --- a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfTimestampFormat.java +++ b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfTimestampFormat.java @@ -100,6 +100,6 @@ public enum BtfTimestampFormat { * @return TmfTimestamp with proper scale */ public @NonNull ITmfTimestamp createTimestamp(long timestamp) { - return new TmfTimestamp(timestamp, fScale); + return TmfTimestamp.create(timestamp, fScale); } } diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceGrowingStreamTest.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceGrowingStreamTest.java index f7342b54e5..86f73d8db8 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceGrowingStreamTest.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFTraceGrowingStreamTest.java @@ -11,7 +11,9 @@ package org.eclipse.tracecompass.ctf.core.tests.trace; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.io.File; import java.io.FileNotFoundException; diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java index df04f5c282..8f632a5781 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java @@ -11,7 +11,7 @@ package org.eclipse.tracecompass.ctf.core.tests.types; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFLexer.java b/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFLexer.java index 0ac655c64a..47246c2b6b 100644 --- a/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFLexer.java +++ b/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFLexer.java @@ -17,10 +17,15 @@ package org.eclipse.tracecompass.ctf.parser; -import org.antlr.runtime.*; -import java.util.Stack; -import java.util.List; -import java.util.ArrayList; +import org.antlr.runtime.BaseRecognizer; +import org.antlr.runtime.CharStream; +import org.antlr.runtime.DFA; +import org.antlr.runtime.EarlyExitException; +import org.antlr.runtime.Lexer; +import org.antlr.runtime.MismatchedSetException; +import org.antlr.runtime.NoViableAltException; +import org.antlr.runtime.RecognitionException; +import org.antlr.runtime.RecognizerSharedState; @SuppressWarnings("all") public class CTFLexer extends Lexer { diff --git a/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFParser.java b/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFParser.java index bf256e0923..70c4e1dae7 100644 --- a/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFParser.java +++ b/ctf/org.eclipse.tracecompass.ctf.parser/target/generated-sources/antlr3/org/eclipse/tracecompass/ctf/parser/CTFParser.java @@ -16,18 +16,31 @@ package org.eclipse.tracecompass.ctf.parser; -import java.util.Set; import java.util.HashSet; - - -import org.antlr.runtime.*; +import java.util.Set; import java.util.Stack; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import org.antlr.runtime.tree.*; +import org.antlr.runtime.BaseRecognizer; +import org.antlr.runtime.BitSet; +import org.antlr.runtime.DFA; +import org.antlr.runtime.EarlyExitException; +import org.antlr.runtime.FailedPredicateException; +import org.antlr.runtime.IntStream; +import org.antlr.runtime.MismatchedSetException; +import org.antlr.runtime.MismatchedTokenException; +import org.antlr.runtime.NoViableAltException; +import org.antlr.runtime.Parser; +import org.antlr.runtime.ParserRuleReturnScope; +import org.antlr.runtime.RecognitionException; +import org.antlr.runtime.RecognizerSharedState; +import org.antlr.runtime.Token; +import org.antlr.runtime.TokenStream; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.tree.CommonTreeAdaptor; +import org.antlr.runtime.tree.RewriteEarlyExitException; +import org.antlr.runtime.tree.RewriteRuleSubtreeStream; +import org.antlr.runtime.tree.RewriteRuleTokenStream; +import org.antlr.runtime.tree.TreeAdaptor; @SuppressWarnings("all") diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/context/CtfLocationTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/context/CtfLocationTest.java index fd7067495f..b62517d7cf 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/context/CtfLocationTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/context/CtfLocationTest.java @@ -59,7 +59,7 @@ public class CtfLocationTest { */ @Test public void testCtfLocation_timestamp() { - ITmfTimestamp timestamp = new TmfTimestamp(); + ITmfTimestamp timestamp = TmfTimestamp.fromSeconds(0); CtfLocation result = new CtfLocation(timestamp); assertNotNull(result); diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java index 81c1d67695..48e0193155 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java @@ -24,8 +24,8 @@ import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils; @@ -131,8 +131,8 @@ public class CtfTmfLostEventsTest { public void testFirstLostEvent() { final long rank = 190; final long startTime = 1376592664828900165L; - final ITmfTimestamp start = new TmfNanoTimestamp(startTime); - final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 502911L); + final ITmfTimestamp start = TmfTimestamp.fromNanos(startTime); + final ITmfTimestamp end = TmfTimestamp.fromNanos(startTime + 502911L); final long nbLost = 859; validateLostEvent(rank, start, end, nbLost); @@ -145,8 +145,8 @@ public class CtfTmfLostEventsTest { public void testSecondLostEvent() { final long rank = 229; final long startTime = 1376592664829477058L; - final ITmfTimestamp start = new TmfNanoTimestamp(startTime); - final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 347456L); + final ITmfTimestamp start = TmfTimestamp.fromNanos(startTime); + final ITmfTimestamp end = TmfTimestamp.fromNanos(startTime + 347456L); final long nbLost = 488; validateLostEvent(rank, start, end, nbLost); @@ -174,7 +174,7 @@ public class CtfTmfLostEventsTest { @Test public void testNormalEvent() { final long rank = 200; - final ITmfTimestamp ts = new TmfNanoTimestamp(1376592664829425780L); + final ITmfTimestamp ts = TmfTimestamp.fromNanos(1376592664829425780L); final CtfTmfEvent event = getOneEventTime(ts); /* Make sure seeking by rank yields the same event */ @@ -196,8 +196,8 @@ public class CtfTmfLostEventsTest { trace.indexTrace(true); final long rank = 190; - final ITmfTimestamp start = new TmfNanoTimestamp(1376592664828900165L + offset); - final ITmfTimestamp end = new TmfNanoTimestamp(1376592664828900165L + 502911L + offset); + final ITmfTimestamp start = TmfTimestamp.fromNanos(1376592664828900165L + offset); + final ITmfTimestamp end = TmfTimestamp.fromNanos(1376592664828900165L + 502911L + offset); final long nbLost = 859; ITmfContext context = trace.seekEvent(rank); diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/EventContextTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/EventContextTest.java index 1e49e5230c..6c92b2037b 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/EventContextTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/EventContextTest.java @@ -18,7 +18,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; @@ -218,7 +217,7 @@ public class EventContextTest { public EventContextTestRequest(long timestamp) { super(CtfTmfEvent.class, - new TmfTimeRange(new TmfNanoTimestamp(timestamp), TmfTimestamp.BIG_CRUNCH), + new TmfTimeRange(TmfTimestamp.fromNanos(timestamp), TmfTimestamp.BIG_CRUNCH), 0, 1, ExecutionType.FOREGROUND); } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/request/TmfSchedulerTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/request/TmfSchedulerTest.java index d9966bf09f..30098925ef 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/request/TmfSchedulerTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/request/TmfSchedulerTest.java @@ -28,7 +28,6 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils; @@ -48,7 +47,7 @@ public class TmfSchedulerTest { /** Time-out tests after 60 seconds */ @Rule - public TestRule globalTimeout= new Timeout(1, TimeUnit.MINUTES); + public TestRule globalTimeout = new Timeout(1, TimeUnit.MINUTES); // ------------------------------------------------------------------------ // Constants @@ -84,8 +83,8 @@ public class TmfSchedulerTest { long foregroundStartTime = fStartTime + ((fEndTime - fStartTime) / 4); long foregroundEndTime = fStartTime + ((fEndTime - fStartTime) / 2); - fForegroundTimeRange = new TmfTimeRange(new TmfTimestamp(foregroundStartTime, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(foregroundEndTime, ITmfTimestamp.NANOSECOND_SCALE)); + fForegroundTimeRange = new TmfTimeRange(TmfTimestamp.fromNanos(foregroundStartTime), + TmfTimestamp.fromNanos(foregroundEndTime)); } /** @@ -185,7 +184,7 @@ public class TmfSchedulerTest { ForegroundRequest foreground3 = new ForegroundRequest(TmfTimeRange.ETERNITY); fixture.sendRequest(foreground3); - TmfSelectionRangeUpdatedSignal signal3 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fForegroundTimeRange.getStartTime())); + TmfSelectionRangeUpdatedSignal signal3 = new TmfSelectionRangeUpdatedSignal(this, fForegroundTimeRange.getStartTime()); fixture.broadcast(signal3); try { @@ -205,7 +204,7 @@ public class TmfSchedulerTest { public void TestMultiRequest4() { ForegroundRequest foreground4 = new ForegroundRequest(fForegroundTimeRange); fixture.sendRequest(foreground4); - TmfSelectionRangeUpdatedSignal signal4 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fStartTime + ((fEndTime - fStartTime) / 8))); + TmfSelectionRangeUpdatedSignal signal4 = new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromSeconds(fStartTime + ((fEndTime - fStartTime) / 8))); fixture.broadcast(signal4); try { @@ -225,7 +224,7 @@ public class TmfSchedulerTest { public void TestMultiRequest5() { ForegroundRequest foreground5 = new ForegroundRequest(fForegroundTimeRange); fixture.sendRequest(foreground5); - TmfSelectionRangeUpdatedSignal signal5 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fEndTime - ((fEndTime - fStartTime) / 4))); + TmfSelectionRangeUpdatedSignal signal5 = new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromSeconds(fEndTime - ((fEndTime - fStartTime) / 4))); fixture.broadcast(signal5); try { @@ -249,7 +248,7 @@ public class TmfSchedulerTest { fixture.sendRequest(background6); fixture.sendRequest(foreground6); - TmfSelectionRangeUpdatedSignal signal6 = new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(fStartTime + ((fEndTime - fStartTime) / 8))); + TmfSelectionRangeUpdatedSignal signal6 = new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromSeconds(fStartTime + ((fEndTime - fStartTime) / 8))); fixture.broadcast(signal6); try { @@ -297,8 +296,8 @@ public class TmfSchedulerTest { @Test public void preemptedForegroundRequest() { ForegroundRequest foreground9 = new ForegroundRequest(TmfTimeRange.ETERNITY); - TmfTimeRange shortTimeRange = new TmfTimeRange(new TmfTimestamp(fStartTime, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(fStartTime + ((fEndTime - fStartTime) / 16), ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimeRange shortTimeRange = new TmfTimeRange(TmfTimestamp.fromNanos(fStartTime), + TmfTimestamp.fromNanos(fStartTime + ((fEndTime - fStartTime) / 16))); ForegroundRequest shortForeground = new ForegroundRequest(shortTimeRange); fixture.sendRequest(foreground9); try { diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java index 5c552b688f..7c7721916e 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java @@ -61,8 +61,6 @@ public class TmfTraceManagerTest { @Rule public TestRule globalTimeout = new Timeout(1, TimeUnit.MINUTES); - private static final int SCALE = ITmfTimestamp.NANOSECOND_SCALE; - private static ITmfTrace trace1; private static final long t1start = 1331668247314038062L; private static final long t1end = 1331668259054285979L; @@ -275,7 +273,7 @@ public class TmfTraceManagerTest { @Test public void testNewTimestamp() { openTrace(trace2); - ITmfTimestamp ts = new TmfTimestamp(t2start + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t2start + ONE_SECOND); selectTimestamp(ts); TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange(); @@ -291,7 +289,7 @@ public class TmfTraceManagerTest { public void testTimestampBefore() { openTrace(trace2); TmfTimeRange beforeTr = tm.getCurrentTraceContext().getSelectionRange(); - ITmfTimestamp ts = new TmfTimestamp(t2start - ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t2start - ONE_SECOND); selectTimestamp(ts); TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange(); @@ -306,7 +304,7 @@ public class TmfTraceManagerTest { public void testTimestampAfter() { openTrace(trace2); TmfTimeRange beforeTr = tm.getCurrentTraceContext().getSelectionRange(); - ITmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t2end + ONE_SECOND); selectTimestamp(ts); TmfTimeRange selection = tm.getCurrentTraceContext().getSelectionRange(); @@ -320,8 +318,8 @@ public class TmfTraceManagerTest { public void testTraceNewTimeRange() { openTrace(trace2); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t2start + ONE_SECOND, SCALE), - new TmfTimestamp(t2end - ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t2start + ONE_SECOND), + TmfTimestamp.fromNanos(t2end - ONE_SECOND)); selectWindowRange(range); TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange(); @@ -336,8 +334,8 @@ public class TmfTraceManagerTest { public void testTraceTimeRangeClampingStart() { openTrace(trace2); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t2start - ONE_SECOND, SCALE), // minus here - new TmfTimestamp(t2end - ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t2start - ONE_SECOND), // minus here + TmfTimestamp.fromNanos(t2end - ONE_SECOND)); selectWindowRange(range); TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange(); @@ -353,8 +351,8 @@ public class TmfTraceManagerTest { public void testTraceTimeRangeClampingEnd() { openTrace(trace2); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t2start + ONE_SECOND, SCALE), - new TmfTimestamp(t2end + ONE_SECOND, SCALE)); // plus here + TmfTimestamp.fromNanos(t2start + ONE_SECOND), + TmfTimestamp.fromNanos(t2end + ONE_SECOND)); // plus here selectWindowRange(range); TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange(); @@ -371,8 +369,8 @@ public class TmfTraceManagerTest { public void testTraceTimeRangeClampingBoth() { openTrace(trace2); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t2start - ONE_SECOND, SCALE), // minus here - new TmfTimestamp(t2end + ONE_SECOND, SCALE)); // plus here + TmfTimestamp.fromNanos(t2start - ONE_SECOND), // minus here + TmfTimestamp.fromNanos(t2end + ONE_SECOND)); // plus here selectWindowRange(range); TmfTimeRange curRange = tm.getCurrentTraceContext().getWindowRange(); @@ -396,7 +394,7 @@ public class TmfTraceManagerTest { openTrace(trace1); openTrace(trace2); selectTrace(trace1); - TmfTimestamp ts = new TmfTimestamp(t1start + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t1start + ONE_SECOND); selectTimestamp(ts); /* Timestamp of trace1 should have been updated */ @@ -423,7 +421,7 @@ public class TmfTraceManagerTest { openTrace(trace1); openTrace(trace2); selectTrace(trace1); - TmfTimestamp ts = new TmfTimestamp(t1end + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t1end + ONE_SECOND); selectTimestamp(ts); /* Timestamp of trace1 should not have changed */ @@ -449,7 +447,7 @@ public class TmfTraceManagerTest { openTrace(trace1); openTrace(trace2); selectTrace(trace1); - TmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t2end + ONE_SECOND); selectTimestamp(ts); /* Timestamp of trace1 should not have changed */ @@ -475,8 +473,8 @@ public class TmfTraceManagerTest { openTrace(trace2); selectTrace(trace1); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1start + ONE_SECOND, SCALE), - new TmfTimestamp(t1end - ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1start + ONE_SECOND), + TmfTimestamp.fromNanos(t1end - ONE_SECOND)); selectWindowRange(range); /* Range of trace1 should be equal to the requested one */ @@ -500,14 +498,14 @@ public class TmfTraceManagerTest { openTrace(trace2); selectTrace(trace1); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1start + ONE_SECOND, SCALE), - new TmfTimestamp(t1end + ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1start + ONE_SECOND), + TmfTimestamp.fromNanos(t1end + ONE_SECOND)); selectWindowRange(range); /* Range of trace1 should get clamped to its end time */ TmfTimeRange expectedRange = new TmfTimeRange( - new TmfTimestamp(t1start + ONE_SECOND, SCALE), - new TmfTimestamp(t1end, SCALE)); + TmfTimestamp.fromNanos(t1start + ONE_SECOND), + TmfTimestamp.fromNanos(t1end)); assertEquals(expectedRange, tm.getCurrentTraceContext().getWindowRange()); /* Range of trace2 should not have changed */ @@ -527,21 +525,21 @@ public class TmfTraceManagerTest { openTrace(trace2); selectTrace(trace1); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1end - ONE_SECOND, SCALE), - new TmfTimestamp(t2start + ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1end - ONE_SECOND), + TmfTimestamp.fromNanos(t2start + ONE_SECOND)); selectWindowRange(range); /* Range of trace1 should be clamped to its end time */ TmfTimeRange expectedRange = new TmfTimeRange( - new TmfTimestamp(t1end - ONE_SECOND, SCALE), - new TmfTimestamp(t1end, SCALE)); + TmfTimestamp.fromNanos(t1end - ONE_SECOND), + TmfTimestamp.fromNanos(t1end)); assertEquals(expectedRange, tm.getCurrentTraceContext().getWindowRange()); /* Range of trace2 should be clamped to its start time */ selectTrace(trace2); expectedRange = new TmfTimeRange( - new TmfTimestamp(t2start, SCALE), - new TmfTimestamp(t2start + ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t2start), + TmfTimestamp.fromNanos(t2start + ONE_SECOND)); assertEquals(expectedRange, tm.getCurrentTraceContext().getWindowRange()); } @@ -557,8 +555,8 @@ public class TmfTraceManagerTest { openTrace(trace2); selectTrace(trace1); TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1end + ONE_SECOND, SCALE), - new TmfTimestamp(t1end - ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1end + ONE_SECOND), + TmfTimestamp.fromNanos(t1end - ONE_SECOND)); selectWindowRange(range); /* Range of trace1 should not have changed */ @@ -589,7 +587,7 @@ public class TmfTraceManagerTest { public void testExperimentTimestampInTrace() { TmfExperiment exp = createExperiment(trace1, trace2); openTrace(exp); - TmfTimestamp ts = new TmfTimestamp(t1start + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t1start + ONE_SECOND); selectTimestamp(ts); /* The experiment's current time should be updated. */ @@ -609,7 +607,7 @@ public class TmfTraceManagerTest { public void testExperimentTimestampInBetween() { TmfExperiment exp = createExperiment(trace1, trace2); openTrace(exp); - TmfTimestamp ts = new TmfTimestamp(t1end + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t1end + ONE_SECOND); selectTimestamp(ts); /* The experiment's current time should be updated. */ @@ -628,7 +626,7 @@ public class TmfTraceManagerTest { public void testExperimentTimestampInvalid() { TmfExperiment exp = createExperiment(trace1, trace2); openTrace(exp); - TmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(t2end + ONE_SECOND); selectTimestamp(ts); /* The experiment's current time should NOT be updated. */ @@ -664,8 +662,8 @@ public class TmfTraceManagerTest { openTrace(exp); final TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1start - ONE_SECOND, SCALE), - new TmfTimestamp(t1end - ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1start - ONE_SECOND), + TmfTimestamp.fromNanos(t1end - ONE_SECOND)); selectWindowRange(range); TmfTimeRange actualRange = tm.getCurrentTraceContext().getWindowRange(); @@ -684,8 +682,8 @@ public class TmfTraceManagerTest { openTrace(exp); final TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1start - ONE_SECOND, SCALE), - new TmfTimestamp(t2end + ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1start - ONE_SECOND), + TmfTimestamp.fromNanos(t2end + ONE_SECOND)); selectWindowRange(range); TmfTimeRange actualRange = tm.getCurrentTraceContext().getWindowRange(); @@ -704,8 +702,8 @@ public class TmfTraceManagerTest { openTrace(exp); final TmfTimeRange range = new TmfTimeRange( - new TmfTimestamp(t1end + ONE_SECOND, SCALE), - new TmfTimestamp(t2start - ONE_SECOND, SCALE)); + TmfTimestamp.fromNanos(t1end + ONE_SECOND), + TmfTimestamp.fromNanos(t2start - ONE_SECOND)); selectWindowRange(range); TmfTimeRange actualRange = tm.getCurrentTraceContext().getWindowRange(); @@ -739,6 +737,6 @@ public class TmfTraceManagerTest { private static @NonNull ITmfTimestamp calculateOffset(ITmfTimestamp initialTs, ITmfTimestamp offsetTs) { long start = initialTs.toNanos(); long offset = offsetTs.toNanos(); - return new TmfTimestamp(start + offset, SCALE); + return TmfTimestamp.fromNanos(start + offset); } } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java index 5f079dc688..c96f221756 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/CtfTmfTraceTest.java @@ -33,7 +33,6 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; @@ -161,7 +160,7 @@ public class CtfTmfTraceTest { */ @Test public void testSeekEventLoc_timetamp() { - CtfLocation loc = new CtfLocation(new TmfNanoTimestamp(0L)); + CtfLocation loc = new CtfLocation(TmfTimestamp.fromNanos(0L)); fixture.seekEvent(loc); assertNotNull(fixture); } @@ -361,7 +360,7 @@ public class CtfTmfTraceTest { */ @Test public void testSeekEvent_timestamp() { - ITmfTimestamp timestamp = new TmfTimestamp(); + ITmfTimestamp timestamp = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE); ITmfContext result = fixture.seekEvent(timestamp); assertNotNull(result); result.dispose(); diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java index 32e7d8ed1a..596ae423d4 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java @@ -36,7 +36,8 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfModelLookup; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.ctf.core.CtfConstants; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; @@ -117,7 +118,7 @@ public class CtfTmfEvent extends TmfEvent */ protected CtfTmfEvent(CtfTmfTrace trace, long rank, - TmfNanoTimestamp timestamp, + ITmfTimestamp timestamp, String channel, int cpu, IEventDeclaration declaration, @@ -159,7 +160,7 @@ public class CtfTmfEvent extends TmfEvent CtfTmfEvent(CtfTmfTrace trace) { super(trace, ITmfContext.UNKNOWN_RANK, - new TmfNanoTimestamp(-1), + TmfTimestamp.fromNanos(-1), null, new TmfEventField("", null, new CtfTmfEventField[0])); //$NON-NLS-1$ fSourceCpu = -1; diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java index 292870b712..e27e6b6324 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java @@ -19,7 +19,7 @@ import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration; import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; import org.eclipse.tracecompass.ctf.core.event.types.IDefinition; import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; @@ -81,7 +81,7 @@ public class CtfTmfEventFactory { /* Prepare what to pass to CtfTmfEvent's constructor */ final IEventDeclaration eventDecl = eventDef.getDeclaration(); final long ts = eventDef.getTimestamp(); - final TmfNanoTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts)); + final ITmfTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts)); int sourceCPU = eventDef.getCPU(); @@ -126,7 +126,7 @@ public class CtfTmfEventFactory { IEventDefinition eventDef, final IEventDeclaration eventDecl, final long ts, - final TmfNanoTimestamp timestamp, + final ITmfTimestamp timestamp, int sourceCPU, String fileName) { @@ -142,7 +142,7 @@ public class CtfTmfEventFactory { } long nbLostEvents = ((IntegerDefinition) nbLostEventsDef).getValue(); long duration = ((IntegerDefinition) durationDef).getValue(); - TmfNanoTimestamp timestampEnd = trace.createTimestamp( + ITmfTimestamp timestampEnd = trace.createTimestamp( trace.timestampCyclesToNanos(ts) + duration); CtfTmfLostEvent lostEvent = new CtfTmfLostEvent(trace, diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfLostEvent.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfLostEvent.java index ccd505ee64..4fdf6bbfa5 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfLostEvent.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfLostEvent.java @@ -19,7 +19,6 @@ import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration; import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; @@ -68,7 +67,7 @@ public class CtfTmfLostEvent extends CtfTmfEvent implements ITmfLostEvent { * Only the factory should call this method, the cast to * (TmfNanoTimestamp) should be safe. */ - super(trace, rank, (TmfNanoTimestamp) timeRange.getStartTime(), fileName, cpu, declaration, def); + super(trace, rank, timeRange.getStartTime(), fileName, cpu, declaration, def); fTimeRange = timeRange; fNbLost = nbLost; } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java index 03bb239088..9ed272eaa9 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java @@ -50,7 +50,6 @@ import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceWithPreDefinedEvents; @@ -626,8 +625,8 @@ public class CtfTmfTrace extends TmfTrace * @since 1.0 */ @Override - public @NonNull TmfNanoTimestamp createTimestamp(long ts) { - return new TmfNanoTimestamp(getTimestampTransform().transform(ts)); + public @NonNull ITmfTimestamp createTimestamp(long ts) { + return TmfTimestamp.fromNanos(getTimestampTransform().transform(ts)); } private static int fCheckpointSize = -1; @@ -635,7 +634,7 @@ public class CtfTmfTrace extends TmfTrace @Override public synchronized int getCheckpointSize() { if (fCheckpointSize == -1) { - TmfCheckpoint c = new TmfCheckpoint(new TmfNanoTimestamp(0), new CtfLocation(0, 0), 0); + TmfCheckpoint c = new TmfCheckpoint(TmfTimestamp.fromNanos(0), new CtfLocation(0, 0), 0); ByteBuffer b = ByteBuffer.allocate(ITmfCheckpoint.MAX_SERIALIZE_SIZE); b.clear(); c.serialize(b); diff --git a/doc/org.eclipse.tracecompass.doc.dev/doc/Developer-Guide.mediawiki b/doc/org.eclipse.tracecompass.doc.dev/doc/Developer-Guide.mediawiki index e0ed0d4a19..9d43c85fa4 100644 --- a/doc/org.eclipse.tracecompass.doc.dev/doc/Developer-Guide.mediawiki +++ b/doc/org.eclipse.tracecompass.doc.dev/doc/Developer-Guide.mediawiki @@ -2220,13 +2220,13 @@ To add time information in sequence diagram the timestamp has to be set for each
     private void createFrame() {
         //...
-        start.setTime(new TmfTimestamp(1000, -3));
-        syn1.setTime(new TmfTimestamp(1005, -3));
-        synReturn1.setTime(new TmfTimestamp(1050, -3));
-        asyn1.setStartTime(new TmfTimestamp(1060, -3));
-        asyn1.setEndTime(new TmfTimestamp(1070, -3));
-        asynReturn1.setStartTime(new TmfTimestamp(1060, -3));
-        asynReturn1.setEndTime(new TmfTimestamp(1070, -3));
+        start.setTime(TmfTimestamp.create(1000, -3));
+        syn1.setTime(TmfTimestamp.create(1005, -3));
+        synReturn1.setTime(TmfTimestamp.create(1050, -3));
+        asyn1.setStartTime(TmfTimestamp.create(1060, -3));
+        asyn1.setEndTime(TmfTimestamp.create(1070, -3));
+        asynReturn1.setStartTime(TmfTimestamp.create(1060, -3));
+        asynReturn1.setEndTime(TmfTimestamp.create(1070, -3));
         //...
     }
 
diff --git a/gdbtrace/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java b/gdbtrace/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java index 8fe74a5e7e..b45f794184 100644 --- a/gdbtrace/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java +++ b/gdbtrace/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java @@ -102,7 +102,7 @@ import org.eclipse.ui.ide.IDE; /** * Adaptor to access GDB Tracepoint frames, previously collected and saved in a - * file by GDB. One instance of this maps to a single DSF-GDB session. + * file by GDB. One instance of this maps to a single DSF-GDB session. *

* This class offers the functions of starting a post-mortem GDB session with a * tracepoint data file, navigate the data frames and return the data contained @@ -140,9 +140,9 @@ public class DsfGdbAdaptor { private String fTraceFile = ""; //$NON-NLS-1$ private String sourceLocator = ""; //$NON-NLS-1$ - // To save tracepoints detailed info. The key is the rank of the + // To save tracepoints detailed info. The key is the rank of the // breakpoint (tracepoint is a kind of breakpoint) - private Map fTpInfo = new HashMap<>(); + private Map fTpInfo = new HashMap<>(); private TmfEventType tmfEventType = new TmfEventType("GDB Tracepoint", TmfEventField.makeRoot(new String[] { "Content" })); //$NON-NLS-1$ //$NON-NLS-2$ @@ -157,10 +157,11 @@ public class DsfGdbAdaptor { * about the launchers or a change in debug context that we might need to * react-to. *

+ * * @author Francois Chouinard */ private class DsfGdbPlatformEventListener implements - ILaunchesListener2, IDebugContextListener { + ILaunchesListener2, IDebugContextListener { /** * @@ -209,7 +210,7 @@ public class DsfGdbAdaptor { IDMContext context = (IDMContext) contextObject; if (context != null) { String sessionId; - synchronized(SESSION_LOCK) { + synchronized (SESSION_LOCK) { sessionId = context.getSessionId(); if (sessionId.equals(fCurrentSessionId)) { return; @@ -226,7 +227,7 @@ public class DsfGdbAdaptor { final ICommandControlService commandControl = tracker.getService(ICommandControlService.class); if (traceControl != null && commandControl != null) { ITraceTargetDMContext traceContext = (ITraceTargetDMContext) commandControl.getContext(); - traceControl.getCurrentTraceRecordContext(traceContext, queryRm); + traceControl.getCurrentTraceRecordContext(traceContext, queryRm); } else { queryRm.done(); } @@ -368,23 +369,23 @@ public class DsfGdbAdaptor { return fNumberOfFrames; } - /** * Wrapper around the selecting of a frame and the reading of its * information. this is a work-around for the potential problem of - * concurrent access to these functions by more than one thread, - * where two clients might interfere with each other. + * concurrent access to these functions by more than one thread, where two + * clients might interfere with each other. *

- * Note: We also try to get the tracepoint info here, if it's not - * already filled-in. + * Note: We also try to get the tracepoint info here, if it's not already + * filled-in. * - * @param rank a long corresponding to the number of the frame to be - * selected and read + * @param rank + * a long corresponding to the number of the frame to be selected + * and read * @return A GdbTraceEvent object, or null in case of failure. */ public synchronized GdbTraceEvent selectAndReadFrame(final long rank) { // lazy init of tracepoints info - if(fTpInfo.isEmpty()) { + if (fTpInfo.isEmpty()) { getTracepointInfo(); } if (selectDataFrame(rank, false)) { @@ -397,7 +398,6 @@ public class DsfGdbAdaptor { return null; } - /** * This class implements a best-effort look-up of the detailed tracepoint * information (source code filename, line number, etc...). @@ -568,11 +568,13 @@ public class DsfGdbAdaptor { } /** - * This method uses the DSF-GDB interface to select a given frame number - * in the current GDB tracepoint session. + * This method uses the DSF-GDB interface to select a given frame number in + * the current GDB tracepoint session. * - * @param rank the rank of the tracepoint frame to select. - * @param update true if visualization should be updated + * @param rank + * the rank of the tracepoint frame to select. + * @param update + * true if visualization should be updated * @return boolean true if select worked. */ public boolean selectDataFrame(final long rank, final boolean update) { @@ -728,11 +730,10 @@ public class DsfGdbAdaptor { // get corresponding TP data String tmfEventRef; - MIBreakpointDMData bp = fTpInfo.get(Integer.valueOf(data.getTracepointNumber())); + MIBreakpointDMData bp = fTpInfo.get(Integer.valueOf(data.getTracepointNumber())); if (bp != null) { tmfEventRef = bp.getFileName() + ":" + bp.getLineNumber() + " :: " + bp.getFunctionName(); //$NON-NLS-1$ //$NON-NLS-2$ - } - else { + } else { tmfEventRef = tracedExecutable; } @@ -742,7 +743,7 @@ public class DsfGdbAdaptor { Integer.parseInt(data.getRecordId())); GdbTraceEvent ev = new GdbTraceEvent(fGdbTrace, - new TmfTimestamp(Integer.parseInt(data.getRecordId())), + TmfTimestamp.fromSeconds(Integer.parseInt(data.getRecordId())), "Tracepoint: " + data.getTracepointNumber() + ", Frame: " + data.getRecordId(), //$NON-NLS-1$ //$NON-NLS-2$ tmfEventType, evContent, @@ -769,20 +770,22 @@ public class DsfGdbAdaptor { * This is a helper method for getTraceFrameData, to create for it a * "best effort" GdbTraceEvent when a problem occurs during the reading. * - * @param rank long containing the number of the frame where the problem occurred - * @param message String containing a brief explanation of problem. + * @param rank + * long containing the number of the frame where the problem + * occurred + * @param message + * String containing a brief explanation of problem. * @return a GdbTraceEvent object, filled as best as possible */ private GdbTraceEvent createExceptionEvent(final long rank, final String message) { // get corresponding TP data String tmfEventRef; String tmfEventSrc; - MIBreakpointDMData bp = fTpInfo.get(rank); + MIBreakpointDMData bp = fTpInfo.get(rank); if (bp != null) { tmfEventRef = bp.getFileName() + ":" + bp.getLineNumber() + " :: " + bp.getFunctionName(); //$NON-NLS-1$ //$NON-NLS-2$ tmfEventSrc = bp.getFileName() + " :: " + bp.getFunctionName() + ", line: " + bp.getLineNumber(); //$NON-NLS-1$ //$NON-NLS-2$ - } - else { + } else { tmfEventRef = tracedExecutable; tmfEventSrc = "Tracepoint: n/a"; //$NON-NLS-1$ } @@ -790,7 +793,7 @@ public class DsfGdbAdaptor { GdbTraceEventContent evContent = new GdbTraceEventContent("ERROR: " + message, 0, 0); //$NON-NLS-1$ GdbTraceEvent ev = new GdbTraceEvent(fGdbTrace, - new TmfTimestamp(rank), + TmfTimestamp.fromSeconds(rank), tmfEventSrc, tmfEventType, evContent, diff --git a/gdbtrace/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java b/gdbtrace/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java index 588fd48bf3..0562a5ded7 100644 --- a/gdbtrace/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java +++ b/gdbtrace/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java @@ -27,8 +27,8 @@ import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent; import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent; import org.eclipse.tracecompass.internal.gdbtrace.core.trace.GdbEventAspects; import org.eclipse.tracecompass.internal.gdbtrace.core.trace.GdbTrace; -import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; diff --git a/lttng/org.eclipse.tracecompass.lttng2.common.core.tests/src/org/eclipse/tracecompass/lttng2/common/core/tests/ActivatorTest.java b/lttng/org.eclipse.tracecompass.lttng2.common.core.tests/src/org/eclipse/tracecompass/lttng2/common/core/tests/ActivatorTest.java index 3ee3f1ee39..edbc389fa7 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.common.core.tests/src/org/eclipse/tracecompass/lttng2/common/core/tests/ActivatorTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.common.core.tests/src/org/eclipse/tracecompass/lttng2/common/core/tests/ActivatorTest.java @@ -11,7 +11,6 @@ package org.eclipse.tracecompass.lttng2.common.core.tests; import static org.junit.Assert.assertNotNull; -import org.eclipse.tracecompass.internal.lttng2.common.core.Activator; import org.junit.Test; /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseEventInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseEventInfoTest.java index 8199b315ea..96971926f9 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseEventInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/BaseEventInfoTest.java @@ -13,7 +13,10 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.LinkedList; import java.util.List; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ChannelInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ChannelInfoTest.java index 0e3b24728e..64eb6fd72f 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ChannelInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ChannelInfoTest.java @@ -13,7 +13,11 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.LinkedList; import java.util.List; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/DomainInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/DomainInfoTest.java index 13ddb54bda..9d6366150b 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/DomainInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/DomainInfoTest.java @@ -13,7 +13,10 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.LinkedList; import java.util.List; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/FieldInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/FieldInfoTest.java index 22f37ecf50..9182a18b42 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/FieldInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/FieldInfoTest.java @@ -13,7 +13,11 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.eclipse.tracecompass.internal.lttng2.control.core.model.IFieldInfo; import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.FieldInfo; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java index caa8d519cd..af311ff626 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/ProbeEventInfoTest.java @@ -13,7 +13,11 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import org.eclipse.tracecompass.internal.lttng2.control.core.model.IProbeEventInfo; import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceEnablement; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/SessionInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/SessionInfoTest.java index 3d50aa5a77..bb25c07f0f 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/SessionInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/SessionInfoTest.java @@ -13,7 +13,12 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.LinkedList; import java.util.List; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/UstProviderInfoTest.java b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/UstProviderInfoTest.java index 0099c8a564..b812049aab 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/UstProviderInfoTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.core.tests/src/org/eclipse/tracecompass/lttng2/control/core/tests/model/impl/UstProviderInfoTest.java @@ -13,7 +13,10 @@ package org.eclipse.tracecompass.lttng2.control.core.tests.model.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.LinkedList; import java.util.List; diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/relayd/LttngRelaydConsumer.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/relayd/LttngRelaydConsumer.java index de65c38fdd..caa3cf9607 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/relayd/LttngRelaydConsumer.java +++ b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/relayd/LttngRelaydConsumer.java @@ -36,8 +36,9 @@ import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.Str import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.impl.LttngRelaydConnectorFactory; import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; /** @@ -184,7 +185,7 @@ public final class LttngRelaydConsumer { if (indexReply.getStatus() == NextIndexReturnCode.VIEWER_INDEX_OK) { long nanoTimeStamp = fCtfTmfTrace.timestampCyclesToNanos(indexReply.getTimestampEnd()); if (nanoTimeStamp > fTimestampEnd) { - TmfNanoTimestamp endTime = new TmfNanoTimestamp(nanoTimeStamp); + ITmfTimestamp endTime = TmfTimestamp.fromNanos(nanoTimeStamp); TmfTimeRange range = new TmfTimeRange(fCtfTmfTrace.getStartTime(), endTime); long currentTime = System.nanoTime(); @@ -198,7 +199,7 @@ public final class LttngRelaydConsumer { } else if (indexReply.getStatus() == NextIndexReturnCode.VIEWER_INDEX_HUP) { // The trace is now complete because the trace session was destroyed fCtfTmfTrace.setComplete(true); - TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(LttngRelaydConsumer.this, fCtfTmfTrace, new TmfTimeRange(fCtfTmfTrace.getStartTime(), new TmfNanoTimestamp(fTimestampEnd))); + TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(LttngRelaydConsumer.this, fCtfTmfTrace, new TmfTimeRange(fCtfTmfTrace.getStartTime(), TmfTimestamp.fromNanos(fTimestampEnd))); fCtfTmfTrace.broadcastAsync(signal); return Status.OK_STATUS; } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/ActivatorTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/ActivatorTest.java index 12b265c18a..f148900e83 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/ActivatorTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/ActivatorTest.java @@ -12,14 +12,14 @@ package org.eclipse.tracecompass.lttng2.kernel.core.tests; -import junit.framework.TestCase; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import junit.framework.TestCase; + /** * ActivatorTest *

diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewSortingTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewSortingTest.java index 3f9d876fb7..f83d219fe4 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewSortingTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewSortingTest.java @@ -86,7 +86,7 @@ public class ControlFlowViewSortingTest extends KernelTestBase { private static final long LTTNG_CONSUMER_BIRTHTIME = 1361214078963717040L; private static final String LTTNG_CONSUMER_TID = "4034"; - private static final @NonNull TmfTimestamp TRACE_START_TIME = new TmfTimestamp(1361214078963711320L, ITmfTimestamp.NANOSECOND_SCALE); + private static final @NonNull ITmfTimestamp TRACE_START_TIME = TmfTimestamp.create(1361214078963711320L, ITmfTimestamp.NANOSECOND_SCALE); // ------------------------------------------------------------------------ // Attributes diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java index af93327d18..1e7bca28a0 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ControlFlowViewTest.java @@ -34,8 +34,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView; @@ -68,18 +68,18 @@ public class ControlFlowViewTest extends KernelTestBase { private static final String SELECT_PREVIOUS_EVENT = "Select Previous Event"; private static final String SELECT_NEXT_EVENT = "Select Next Event"; private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard(); - private static final @NonNull ITmfTimestamp START_TIME = new TmfNanoTimestamp(1368000272650993664L); - private static final @NonNull ITmfTimestamp TID1_TIME1 = new TmfNanoTimestamp(1368000272651208412L); - private static final @NonNull ITmfTimestamp TID1_TIME2 = new TmfNanoTimestamp(1368000272656147616L); - private static final @NonNull ITmfTimestamp TID1_TIME3 = new TmfNanoTimestamp(1368000272656362364L); - private static final @NonNull ITmfTimestamp TID1_TIME4 = new TmfNanoTimestamp(1368000272663234300L); - private static final @NonNull ITmfTimestamp TID1_TIME5 = new TmfNanoTimestamp(1368000272663449048L); - private static final @NonNull ITmfTimestamp TID1_TIME6 = new TmfNanoTimestamp(1368000272665596528L); - private static final @NonNull ITmfTimestamp TID2_TIME1 = new TmfNanoTimestamp(1368000272651852656L); - private static final @NonNull ITmfTimestamp TID2_TIME2 = new TmfNanoTimestamp(1368000272652067404L); - private static final @NonNull ITmfTimestamp TID2_TIME3 = new TmfNanoTimestamp(1368000272652282152L); - private static final @NonNull ITmfTimestamp TID2_TIME4 = new TmfNanoTimestamp(1368000272652496900L); - private static final @NonNull ITmfTimestamp TID5_TIME1 = new TmfNanoTimestamp(1368000272652496900L); + private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L); + private static final @NonNull ITmfTimestamp TID1_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L); + private static final @NonNull ITmfTimestamp TID1_TIME2 = TmfTimestamp.fromNanos(1368000272656147616L); + private static final @NonNull ITmfTimestamp TID1_TIME3 = TmfTimestamp.fromNanos(1368000272656362364L); + private static final @NonNull ITmfTimestamp TID1_TIME4 = TmfTimestamp.fromNanos(1368000272663234300L); + private static final @NonNull ITmfTimestamp TID1_TIME5 = TmfTimestamp.fromNanos(1368000272663449048L); + private static final @NonNull ITmfTimestamp TID1_TIME6 = TmfTimestamp.fromNanos(1368000272665596528L); + private static final @NonNull ITmfTimestamp TID2_TIME1 = TmfTimestamp.fromNanos(1368000272651852656L); + private static final @NonNull ITmfTimestamp TID2_TIME2 = TmfTimestamp.fromNanos(1368000272652067404L); + private static final @NonNull ITmfTimestamp TID2_TIME3 = TmfTimestamp.fromNanos(1368000272652282152L); + private static final @NonNull ITmfTimestamp TID2_TIME4 = TmfTimestamp.fromNanos(1368000272652496900L); + private static final @NonNull ITmfTimestamp TID5_TIME1 = TmfTimestamp.fromNanos(1368000272652496900L); private SWTBotView fViewBot; diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesViewTest.java index 2075db3604..c3fa7469c6 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/kernel/ui/swtbot/tests/ResourcesViewTest.java @@ -34,8 +34,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl; @@ -62,18 +62,18 @@ public class ResourcesViewTest extends KernelTestBase { private static final String LOST_EVENTS = "Lost Events"; private static final String OK = "OK"; private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard(); - private static final @NonNull ITmfTimestamp START_TIME = new TmfNanoTimestamp(1368000272650993664L); - private static final @NonNull ITmfTimestamp LOST_EVENT_TIME1 = new TmfNanoTimestamp(1368000272681793477L); - private static final @NonNull ITmfTimestamp LOST_EVENT_END1 = new TmfNanoTimestamp(1368000272681793477L + 7425331L); - private static final @NonNull ITmfTimestamp LOST_EVENT_TIME2 = new TmfNanoTimestamp(1368000272820875850L); - private static final @NonNull ITmfTimestamp LOST_EVENT_END2 = new TmfNanoTimestamp(1368000272820875850L + 6640670L); - private static final @NonNull ITmfTimestamp LOST_EVENT_TIME3 = new TmfNanoTimestamp(1368000272882715015L); - private static final @NonNull ITmfTimestamp LOST_EVENT_END3 = new TmfNanoTimestamp(1368000272882715015L + 11373385L); - private static final @NonNull ITmfTimestamp CPU0_TIME1 = new TmfNanoTimestamp(1368000272651208412L); - private static final @NonNull ITmfTimestamp CPU0_TIME2 = new TmfNanoTimestamp(1368000272651852656L); - private static final @NonNull ITmfTimestamp CPU0_TIME3 = new TmfNanoTimestamp(1368000272652067404L); - private static final @NonNull ITmfTimestamp CPU0_TIME4 = new TmfNanoTimestamp(1368000272652282152L); - private static final @NonNull ITmfTimestamp CPU0_TIME5 = new TmfNanoTimestamp(1368000272653141144L); + private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L); + private static final @NonNull ITmfTimestamp LOST_EVENT_TIME1 = TmfTimestamp.fromNanos(1368000272681793477L); + private static final @NonNull ITmfTimestamp LOST_EVENT_END1 = TmfTimestamp.fromNanos(1368000272681793477L + 7425331L); + private static final @NonNull ITmfTimestamp LOST_EVENT_TIME2 = TmfTimestamp.fromNanos(1368000272820875850L); + private static final @NonNull ITmfTimestamp LOST_EVENT_END2 = TmfTimestamp.fromNanos(1368000272820875850L + 6640670L); + private static final @NonNull ITmfTimestamp LOST_EVENT_TIME3 = TmfTimestamp.fromNanos(1368000272882715015L); + private static final @NonNull ITmfTimestamp LOST_EVENT_END3 = TmfTimestamp.fromNanos(1368000272882715015L + 11373385L); + private static final @NonNull ITmfTimestamp CPU0_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L); + private static final @NonNull ITmfTimestamp CPU0_TIME2 = TmfTimestamp.fromNanos(1368000272651852656L); + private static final @NonNull ITmfTimestamp CPU0_TIME3 = TmfTimestamp.fromNanos(1368000272652067404L); + private static final @NonNull ITmfTimestamp CPU0_TIME4 = TmfTimestamp.fromNanos(1368000272652282152L); + private static final @NonNull ITmfTimestamp CPU0_TIME5 = TmfTimestamp.fromNanos(1368000272653141144L); private static final int TOP_MARGIN = 1; private static final Point TOGGLE_SIZE = new Point(7, 8); private static final Point HIDE_SIZE = new Point(16, 16); diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/ActivatorTest.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/ActivatorTest.java index 53dbe91a7a..aa7ec43ac7 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/ActivatorTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/src/org/eclipse/tracecompass/lttng2/ust/core/tests/ActivatorTest.java @@ -12,14 +12,14 @@ package org.eclipse.tracecompass.lttng2.ust.core.tests; -import junit.framework.TestCase; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import junit.framework.TestCase; + /** * ActivatorTest *

diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java index e823405bca..38fa890a7e 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEvent.java @@ -16,7 +16,7 @@ import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect; import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite; import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; @@ -56,7 +56,7 @@ public class LttngUstEvent extends CtfTmfEvent implements ITmfSourceLookup { * @param eventDefinition * The event definition */ - protected LttngUstEvent(CtfTmfTrace trace, long rank, TmfNanoTimestamp timestamp, + protected LttngUstEvent(CtfTmfTrace trace, long rank, ITmfTimestamp timestamp, String channel, int cpu, IEventDeclaration declaration, IEventDefinition eventDefinition) { super(trace, rank, timestamp, channel, cpu, declaration, eventDefinition); } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java index 4e8dd9c456..bfc658016e 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java @@ -14,7 +14,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.ctf.core.CTFStrings; import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration; import org.eclipse.tracecompass.ctf.core.event.IEventDefinition; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventFactory; @@ -47,7 +47,7 @@ public class LttngUstEventFactory extends CtfTmfEventFactory { /* Prepare what to pass to CtfTmfEvent's constructor */ final IEventDeclaration eventDecl = eventDef.getDeclaration(); final long ts = eventDef.getTimestamp(); - final TmfNanoTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts)); + final ITmfTimestamp timestamp = trace.createTimestamp(trace.timestampCyclesToNanos(ts)); int sourceCPU = eventDef.getCPU(); diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java index 0e517f8132..50fe209b93 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java @@ -35,7 +35,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; @@ -287,7 +287,7 @@ public class CallStackViewTest { private static void goToTime(long timestamp) { SWTBotTable table = fBot.activeEditor().bot().table(); table.setFocus(); - TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, new TmfNanoTimestamp(timestamp))); + TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(table.widget, TmfTimestamp.fromNanos(timestamp))); fBot.waitUntil(ConditionHelpers.selectionInEventsTable(fBot, timestamp)); } diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventTest.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventTest.java index 2a2b3dcef3..0b7cf434b7 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventTest.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core.tests/src/org/eclipse/tracecompass/tmf/pcap/core/tests/event/PcapEventTest.java @@ -12,7 +12,8 @@ package org.eclipse.tracecompass.tmf.pcap.core.tests.event; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; import java.io.IOException; diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStream.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStream.java index b4809ea3ae..6fdd39beb5 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStream.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/TmfPacketStream.java @@ -133,7 +133,7 @@ public class TmfPacketStream { * @return The start time. */ public synchronized ITmfTimestamp getStartTime() { - return new TmfTimestamp(fPacketStream.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE); + return TmfTimestamp.fromNanos(fPacketStream.getStartTime()); } /** @@ -142,7 +142,7 @@ public class TmfPacketStream { * @return The stop time. */ public synchronized ITmfTimestamp getStopTime() { - return new TmfTimestamp(fPacketStream.getStopTime(), ITmfTimestamp.NANOSECOND_SCALE); + return TmfTimestamp.fromNanos(fPacketStream.getStopTime()); } /** diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java index 5bbac26769..f5efb7c075 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java @@ -72,11 +72,11 @@ public class PcapEventFactory { switch (scale) { case MICROSECOND: long us = trace.getTimestampTransform().transform(timestamp * 1000) / 1000; - tmfTimestamp = new TmfTimestamp(us, ITmfTimestamp.MICROSECOND_SCALE); + tmfTimestamp = TmfTimestamp.fromMicros(us); break; case NANOSECOND: long ns = trace.getTimestampTransform().transform(timestamp); - tmfTimestamp = new TmfTimestamp(ns, ITmfTimestamp.NANOSECOND_SCALE); + tmfTimestamp = TmfTimestamp.fromNanos(ns); break; default: throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$ diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java index ee5922cc27..e38b28caaf 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/stubs/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/stubs/PatternSegmentFactoryStub.java @@ -44,11 +44,11 @@ public class PatternSegmentFactoryStub { /** * Start event for pattern segment TEST_2 */ - public static final @NonNull ITmfEvent TEST_2_START_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, new TmfTimestamp(1, ITmfTimestamp.NANOSECOND_SCALE), null, null); + public static final @NonNull ITmfEvent TEST_2_START_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, TmfTimestamp.fromNanos(1), null, null); /** * end event for pattern segment TEST_2 */ - public static final @NonNull ITmfEvent TEST_2_END_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, new TmfTimestamp(10, ITmfTimestamp.NANOSECOND_SCALE), null, null); + public static final @NonNull ITmfEvent TEST_2_END_EVENT = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, TmfTimestamp.fromNanos(10), null, null); /** * The pattern segment TEST_2 diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java index 78c3edf1fb..b80f0095ff 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java @@ -77,7 +77,7 @@ public class TmfXmlPatternSegment implements ISegment { * @return The start timestamp */ public @NonNull ITmfTimestamp getTimestampStart() { - return new TmfTimestamp(fStart, fScale); + return TmfTimestamp.create(fStart, fScale); } /** @@ -86,7 +86,7 @@ public class TmfXmlPatternSegment implements ISegment { * @return The end timestamp */ public @NonNull ITmfTimestamp getTimestampEnd() { - return new TmfTimestamp(fEnd, fScale); + return TmfTimestamp.create(fEnd, fScale); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementHelperTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementHelperTest.java index 4bc3f9b756..cec6c26594 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementHelperTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementHelperTest.java @@ -21,8 +21,8 @@ import java.util.HashSet; import java.util.Set; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement.ValuePriorityLevel; import org.eclipse.tracecompass.tmf.core.analysis.requirements.IAnalysisRequirementProvider; +import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement.ValuePriorityLevel; import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirementHelper; import org.eclipse.tracecompass.tmf.tests.stubs.analysis.AnalysisModuleTestHelper; import org.eclipse.tracecompass.tmf.tests.stubs.analysis.AnalysisModuleTestHelper.moduleStubEnum; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementTest.java index 4daf2a9109..fcf708aea4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/analysis/requirements/AnalysisRequirementTest.java @@ -13,6 +13,12 @@ package org.eclipse.tracecompass.tmf.core.tests.analysis.requirements; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -20,13 +26,6 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement; import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement.ValuePriorityLevel; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import org.junit.Test; /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/component/TmfEventProviderTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/component/TmfEventProviderTest.java index 0321c5e346..895e71f169 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/component/TmfEventProviderTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/component/TmfEventProviderTest.java @@ -24,10 +24,11 @@ import java.util.Vector; import org.eclipse.tracecompass.internal.tmf.core.component.TmfProviderManager; import org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; -import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType; +import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfStartSynchSignal; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.tests.stubs.component.TmfEventProviderStub; @@ -303,8 +304,8 @@ public class TmfEventProviderTest { */ @Test public void testGetSyntheticEvents_TimeRange() { - TmfTimestamp start = new TmfTimestamp(1, (byte) -3); - TmfTimestamp end = new TmfTimestamp(1000, (byte) -3); + ITmfTimestamp start = TmfTimestamp.create(1, (byte) -3); + ITmfTimestamp end = TmfTimestamp.create(1000, (byte) -3); TmfTimeRange range = new TmfTimeRange(start, end); try { getSyntheticData(range, -1); @@ -315,7 +316,7 @@ public class TmfEventProviderTest { // public void testGetSyntheticEvents_WeirdTimeRange1() { // TmfTimestamp start = TmfTimestamp.BigBang; -// TmfTimestamp end = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte) -3, +// TmfTimestamp end = TmfTimestamp.Zero; // TmfTimestamp.create(0, (byte) -3, // // 0); // TmfTimeRange range = new TmfTimeRange(start, end); // try { @@ -326,7 +327,7 @@ public class TmfEventProviderTest { // } // public void testGetSyntheticEvents_WeirdTimeRange2() { -// TmfTimestamp start = TmfTimestamp.Zero; // new TmfTimestamp(0, (byte) +// TmfTimestamp start = TmfTimestamp.Zero; // TmfTimestamp.create(0, (byte) // // -3, 0); // TmfTimestamp end = TmfTimestamp.BigCrunch; // TmfTimeRange range = new TmfTimeRange(start, end); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java index b335b3f25d..3d66ed4e0c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java @@ -27,6 +27,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; @@ -61,7 +62,7 @@ public class TmfEventTest { private final ITmfEventField[] fFields1 = new ITmfEventField[] { fField1a, fField1b }; private final @NonNull String fRawContent1 = fField1a.toString() + fField1b.toString(); private final ITmfEventField fContent1 = new TmfEventField(fRawContent1, null, fFields1); - private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, 2); + private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, 2); private final @NonNull ITmfEvent fEvent1 = new TmfEvent(fTrace, 0, fTimestamp1, fType, fContent1); private final Object fValue2a = "Another string"; @@ -71,7 +72,7 @@ public class TmfEventTest { private final ITmfEventField[] fFields2 = new ITmfEventField[] { fField2a, fField2b }; private final @NonNull String fRawContent2 = fField2a.toString() + fField2b.toString(); private final ITmfEventField fContent2 = new TmfEventField(fRawContent2, null, fFields2); - private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, 2); + private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, 2); private final @NonNull ITmfEvent fEvent2 = new TmfEvent(fTrace, 1, fTimestamp2, fType, fContent2); // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfNanoTimestampTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfNanoTimestampTest.java index 77fb2bb35d..998c1f24a3 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfNanoTimestampTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfNanoTimestampTest.java @@ -16,7 +16,6 @@ package org.eclipse.tracecompass.tmf.core.tests.event; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -37,7 +36,7 @@ public class TmfNanoTimestampTest { // Variables // ------------------------------------------------------------------------ - private final ITmfTimestamp ts0 = new TmfNanoTimestamp(); + private final ITmfTimestamp ts0 = new TmfNanoTimestamp(0); private final ITmfTimestamp ts1 = new TmfNanoTimestamp(12345); private final ITmfTimestamp ts2 = new TmfNanoTimestamp(-1234); @@ -59,22 +58,12 @@ public class TmfNanoTimestampTest { @Test public void testCopyConstructor() { - final ITmfTimestamp copy = new TmfNanoTimestamp(ts1); + final long copy = ts1.toNanos(); - assertEquals("getValue", ts1.getValue(), copy.getValue()); - assertEquals("getscale", ts1.getScale(), copy.getScale()); + assertEquals("getValue", ts1.getValue(), copy); + assertEquals("getscale", ts1.getScale(), -9); - assertEquals("getValue", 12345, copy.getValue()); - assertEquals("getscale", -9, copy.getScale()); - } - - @Test - public void testCopyBadTimestamp() { - try { - new TmfNanoTimestamp(null); - fail("TmfNanoTimestamp: null argument"); - } catch (final NullPointerException e) { - } + assertEquals("getValue", 12345, copy); } // ------------------------------------------------------------------------ @@ -99,25 +88,25 @@ public class TmfNanoTimestampTest { @Test public void testEqualsSymmetry() { - final ITmfTimestamp ts0copy = new TmfNanoTimestamp(ts0); + final ITmfTimestamp ts0copy = TmfTimestamp.fromNanos(ts0.toNanos()); assertTrue("equals", ts0.equals(ts0copy)); assertTrue("equals", ts0copy.equals(ts0)); - final ITmfTimestamp ts1copy = new TmfNanoTimestamp(ts1); + final ITmfTimestamp ts1copy = TmfTimestamp.fromNanos(ts1.toNanos()); assertTrue("equals", ts1.equals(ts1copy)); assertTrue("equals", ts1copy.equals(ts1)); } @Test public void testEqualsTransivity() { - final ITmfTimestamp ts0copy1 = new TmfNanoTimestamp(ts0); - final ITmfTimestamp ts0copy2 = new TmfNanoTimestamp(ts0copy1); + final ITmfTimestamp ts0copy1 = TmfTimestamp.fromNanos(ts0.toNanos()); + final ITmfTimestamp ts0copy2 = TmfTimestamp.fromNanos(ts0copy1.toNanos()); assertTrue("equals", ts0.equals(ts0copy1)); assertTrue("equals", ts0copy1.equals(ts0copy2)); assertTrue("equals", ts0.equals(ts0copy2)); - final ITmfTimestamp ts1copy1 = new TmfNanoTimestamp(ts1); - final ITmfTimestamp ts1copy2 = new TmfNanoTimestamp(ts1copy1); + final ITmfTimestamp ts1copy1 = TmfTimestamp.fromNanos(ts1.toNanos()); + final ITmfTimestamp ts1copy2 = TmfTimestamp.fromNanos(ts1copy1.toNanos()); assertTrue("equals", ts1.equals(ts1copy1)); assertTrue("equals", ts1copy1.equals(ts1copy2)); assertTrue("equals", ts1.equals(ts1copy2)); @@ -156,13 +145,13 @@ public class TmfNanoTimestampTest { @Test public void testHashCode() { - final ITmfTimestamp ts0copy = new TmfTimestamp(ts0); - final ITmfTimestamp ts1copy = new TmfTimestamp(ts1); - final ITmfTimestamp ts2copy = new TmfTimestamp(ts2); + final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale()); + final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale()); + final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale()); - assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode()); - assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode()); - assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode()); + assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode()); + assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode()); + assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode()); assertTrue("hashCode", ts0.hashCode() != ts1.hashCode()); } @@ -215,9 +204,9 @@ public class TmfNanoTimestampTest { @Test public void testBasicCompareTo() { - final ITmfTimestamp tstamp1 = new TmfNanoTimestamp(900); - final ITmfTimestamp tstamp2 = new TmfNanoTimestamp(1000); - final ITmfTimestamp tstamp3 = new TmfNanoTimestamp(1100); + final ITmfTimestamp tstamp1 = TmfTimestamp.fromNanos(900); + final ITmfTimestamp tstamp2 = TmfTimestamp.fromNanos(1000); + final ITmfTimestamp tstamp3 = TmfTimestamp.fromNanos(1100); assertTrue(tstamp1.compareTo(tstamp1) == 0); @@ -233,9 +222,9 @@ public class TmfNanoTimestampTest { @Test public void testCompareTo() { - final ITmfTimestamp ts0a = new TmfTimestamp(0, 2); - final ITmfTimestamp ts1a = new TmfTimestamp(123450, -10); - final ITmfTimestamp ts2a = new TmfTimestamp(-12340, -10); + final ITmfTimestamp ts0a = TmfTimestamp.create(0, 2); + final ITmfTimestamp ts1a = TmfTimestamp.create(123450, -10); + final ITmfTimestamp ts2a = TmfTimestamp.create(-12340, -10); assertTrue(ts1.compareTo(ts1) == 0); @@ -251,17 +240,17 @@ public class TmfNanoTimestampTest { @Test public void testDelta() { // Delta for same scale and precision (delta > 0) - TmfTimestamp tstamp0 = new TmfNanoTimestamp(10); - TmfTimestamp tstamp1 = new TmfNanoTimestamp(5); - TmfTimestamp expectd = new TmfNanoTimestamp(5); + ITmfTimestamp tstamp0 = TmfTimestamp.fromNanos(10); + ITmfTimestamp tstamp1 = TmfTimestamp.fromNanos(5); + ITmfTimestamp expectd = TmfTimestamp.fromNanos(5); ITmfTimestamp delta = tstamp0.getDelta(tstamp1); assertEquals("getDelta", 0, delta.compareTo(expectd)); // Delta for same scale and precision (delta < 0) - tstamp0 = new TmfTimestamp(5); - tstamp1 = new TmfTimestamp(10); - expectd = new TmfTimestamp(-5); + tstamp0 = TmfTimestamp.fromSeconds(5); + tstamp1 = TmfTimestamp.fromSeconds(10); + expectd = TmfTimestamp.fromSeconds(-5); delta = tstamp0.getDelta(tstamp1); assertEquals("getDelta", 0, delta.compareTo(expectd)); @@ -270,9 +259,9 @@ public class TmfNanoTimestampTest { @Test public void testDelta2() { // Delta for different scale and same precision (delta > 0) - final TmfTimestamp tstamp0 = new TmfNanoTimestamp(10); - final TmfTimestamp tstamp1 = new TmfTimestamp(1, -8); - final TmfTimestamp expectd = new TmfTimestamp(0, 0); + final ITmfTimestamp tstamp0 = TmfTimestamp.fromNanos(10); + final ITmfTimestamp tstamp1 = TmfTimestamp.create(1, -8); + final ITmfTimestamp expectd = TmfTimestamp.create(0, 0); final ITmfTimestamp delta = tstamp0.getDelta(tstamp1); assertEquals("getDelta", 0, delta.compareTo(expectd)); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfSimpleTimestampTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfSecondTimestampTest.java similarity index 60% rename from tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfSimpleTimestampTest.java rename to tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfSecondTimestampTest.java index bec7720744..838b1b202f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfSimpleTimestampTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfSecondTimestampTest.java @@ -16,30 +16,29 @@ package org.eclipse.tracecompass.tmf.core.tests.event; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfSimpleTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfSecondTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Test; /** - * Test suite for the TmfSimpleTimestampTest class. + * Test suite for the {@link TmfSecondTimestamp} class. */ @SuppressWarnings("javadoc") -public class TmfSimpleTimestampTest { +public class TmfSecondTimestampTest { // ------------------------------------------------------------------------ // Variables // ------------------------------------------------------------------------ - private final ITmfTimestamp ts0 = new TmfSimpleTimestamp(); - private final ITmfTimestamp ts1 = new TmfSimpleTimestamp(12345); - private final ITmfTimestamp ts2 = new TmfSimpleTimestamp(-1234); + private final ITmfTimestamp ts0 = new TmfSecondTimestamp(0); + private final ITmfTimestamp ts1 = new TmfSecondTimestamp(12345); + private final ITmfTimestamp ts2 = new TmfSecondTimestamp(-1234); // ------------------------------------------------------------------------ // Constructors @@ -57,77 +56,31 @@ public class TmfSimpleTimestampTest { assertEquals("getscale", 0, ts1.getScale()); } - @Test - public void testCopyConstructor() { - final ITmfTimestamp copy = new TmfSimpleTimestamp(ts1); - - assertEquals("getValue", ts1.getValue(), copy.getValue()); - assertEquals("getscale", ts1.getScale(), copy.getScale()); - - assertEquals("getValue", 12345, copy.getValue()); - assertEquals("getscale", 0, copy.getScale()); - } - - @Test - public void testCopyBadTimestamp() { - try { - new TmfSimpleTimestamp(null); - fail("TmfSimpleTimestamp: null argument"); - } catch (final NullPointerException e) { - } - } - // ------------------------------------------------------------------------ // equals // ------------------------------------------------------------------------ @Test public void testEqualsReflexivity() { - assertTrue("equals", ts0.equals(ts0)); - assertTrue("equals", ts1.equals(ts1)); - assertTrue("equals", ts2.equals(ts2)); + assertEquals("equals", ts0, ts0); + assertEquals("equals", ts1, ts1); + assertEquals("equals", ts2, ts2); - assertTrue("equals", !ts0.equals(ts1)); - assertTrue("equals", !ts0.equals(ts2)); + assertFalse("different", ts0.equals(ts1)); + assertFalse("different", ts0.equals(ts2)); - assertTrue("equals", !ts1.equals(ts0)); - assertTrue("equals", !ts1.equals(ts2)); + assertFalse("different", ts1.equals(ts0)); + assertFalse("different", ts1.equals(ts2)); - assertTrue("equals", !ts2.equals(ts0)); - assertTrue("equals", !ts2.equals(ts1)); - } - - @Test - public void testEqualsSymmetry() { - final ITmfTimestamp ts0copy = new TmfSimpleTimestamp(ts0); - assertTrue("equals", ts0.equals(ts0copy)); - assertTrue("equals", ts0copy.equals(ts0)); - - final ITmfTimestamp ts1copy = new TmfSimpleTimestamp(ts1); - assertTrue("equals", ts1.equals(ts1copy)); - assertTrue("equals", ts1copy.equals(ts1)); - } - - @Test - public void testEqualsTransivity() { - final ITmfTimestamp ts0copy1 = new TmfSimpleTimestamp(ts0); - final ITmfTimestamp ts0copy2 = new TmfSimpleTimestamp(ts0copy1); - assertTrue("equals", ts0.equals(ts0copy1)); - assertTrue("equals", ts0copy1.equals(ts0copy2)); - assertTrue("equals", ts0.equals(ts0copy2)); - - final ITmfTimestamp ts1copy1 = new TmfSimpleTimestamp(ts1); - final ITmfTimestamp ts1copy2 = new TmfSimpleTimestamp(ts1copy1); - assertTrue("equals", ts1.equals(ts1copy1)); - assertTrue("equals", ts1copy1.equals(ts1copy2)); - assertTrue("equals", ts1.equals(ts1copy2)); + assertFalse("different", ts2.equals(ts0)); + assertFalse("different", ts2.equals(ts1)); } @Test public void testEqualsNull() { - assertTrue("equals", !ts0.equals(null)); - assertTrue("equals", !ts1.equals(null)); - assertTrue("equals", !ts2.equals(null)); + assertTrue("different", !ts0.equals(null)); + assertTrue("different", !ts1.equals(null)); + assertTrue("different", !ts2.equals(null)); } @Test @@ -142,9 +95,9 @@ public class TmfSimpleTimestampTest { @Test public void testToString() { DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS"); - Date d0 = new Date(ts0.getValue()*1000); - Date d1 = new Date(ts1.getValue()*1000); - Date d2 = new Date(ts2.getValue()*1000); + Date d0 = new Date(ts0.getValue() * 1000); + Date d1 = new Date(ts1.getValue() * 1000); + Date d2 = new Date(ts2.getValue() * 1000); assertEquals("toString", df.format(d0) + " 000 000", ts0.toString()); assertEquals("toString", df.format(d1) + " 000 000", ts1.toString()); assertEquals("toString", df.format(d2) + " 000 000", ts2.toString()); @@ -156,15 +109,13 @@ public class TmfSimpleTimestampTest { @Test public void testHashCode() { - final ITmfTimestamp ts0copy = new TmfTimestamp(ts0); - final ITmfTimestamp ts1copy = new TmfTimestamp(ts1); - final ITmfTimestamp ts2copy = new TmfTimestamp(ts2); - - assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode()); - assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode()); - assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode()); + final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale()); + final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale()); + final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale()); - assertTrue("hashCode", ts0.hashCode() != ts1.hashCode()); + assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode()); + assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode()); + assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode()); } // ------------------------------------------------------------------------ @@ -215,9 +166,9 @@ public class TmfSimpleTimestampTest { @Test public void testBasicCompareTo() { - final ITmfTimestamp tstamp1 = new TmfSimpleTimestamp(900); - final ITmfTimestamp tstamp2 = new TmfSimpleTimestamp(1000); - final ITmfTimestamp tstamp3 = new TmfSimpleTimestamp(1100); + final ITmfTimestamp tstamp1 = TmfTimestamp.fromSeconds(900); + final ITmfTimestamp tstamp2 = TmfTimestamp.fromSeconds(1000); + final ITmfTimestamp tstamp3 = TmfTimestamp.fromSeconds(1100); assertTrue(tstamp1.compareTo(tstamp1) == 0); @@ -233,9 +184,9 @@ public class TmfSimpleTimestampTest { @Test public void testCompareTo() { - final ITmfTimestamp ts0a = new TmfTimestamp(0, 2); - final ITmfTimestamp ts1a = new TmfTimestamp(123450, -1); - final ITmfTimestamp ts2a = new TmfTimestamp(-12340, -1); + final ITmfTimestamp ts0a = TmfTimestamp.create(0, 2); + final ITmfTimestamp ts1a = TmfTimestamp.create(123450, -1); + final ITmfTimestamp ts2a = TmfTimestamp.create(-12340, -1); assertTrue(ts1.compareTo(ts1) == 0); @@ -251,17 +202,17 @@ public class TmfSimpleTimestampTest { @Test public void testDelta() { // Delta for same scale and precision (delta > 0) - TmfTimestamp tstamp0 = new TmfSimpleTimestamp(10); - TmfTimestamp tstamp1 = new TmfSimpleTimestamp(5); - TmfTimestamp expectd = new TmfSimpleTimestamp(5); + ITmfTimestamp tstamp0 = TmfTimestamp.fromSeconds(10); + ITmfTimestamp tstamp1 = TmfTimestamp.fromSeconds(5); + ITmfTimestamp expectd = TmfTimestamp.fromSeconds(5); ITmfTimestamp delta = tstamp0.getDelta(tstamp1); assertEquals("getDelta", 0, delta.compareTo(expectd)); // Delta for same scale and precision (delta < 0) - tstamp0 = new TmfTimestamp(5); - tstamp1 = new TmfTimestamp(10); - expectd = new TmfTimestamp(-5); + tstamp0 = TmfTimestamp.fromSeconds(5); + tstamp1 = TmfTimestamp.fromSeconds(10); + expectd = TmfTimestamp.fromSeconds(-5); delta = tstamp0.getDelta(tstamp1); assertEquals("getDelta", 0, delta.compareTo(expectd)); @@ -270,9 +221,9 @@ public class TmfSimpleTimestampTest { @Test public void testDelta2() { // Delta for different scale and same precision (delta > 0) - final TmfTimestamp tstamp0 = new TmfSimpleTimestamp(10); - final TmfTimestamp tstamp1 = new TmfTimestamp(1, 1); - final TmfTimestamp expectd = new TmfTimestamp(0, 0); + final ITmfTimestamp tstamp0 = TmfTimestamp.fromSeconds(10); + final ITmfTimestamp tstamp1 = TmfTimestamp.create(1, 1); + final ITmfTimestamp expectd = TmfTimestamp.create(0, 0); final ITmfTimestamp delta = tstamp0.getDelta(tstamp1); assertEquals("getDelta", 0, delta.compareTo(expectd)); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimeRangeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimeRangeTest.java index 32bea617d3..b5daba3c42 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimeRangeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimeRangeTest.java @@ -35,8 +35,8 @@ public class TmfTimeRangeTest { @Test public void testConstructor() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range = new TmfTimeRange(ts1, ts2); assertEquals("startTime", ts1, range.getStartTime()); @@ -45,7 +45,7 @@ public class TmfTimeRangeTest { @Test public void testOpenRange1() { - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, ts2); assertEquals("startTime", TmfTimestamp.BIG_BANG, range.getStartTime()); @@ -54,7 +54,7 @@ public class TmfTimeRangeTest { @Test public void testOpenRange2() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH); assertEquals("startTime", ts1, range.getStartTime()); @@ -75,8 +75,8 @@ public class TmfTimeRangeTest { @Test public void testHashCode() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2); final TmfTimeRange range1b =new TmfTimeRange(ts1, ts2); final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); @@ -94,8 +94,8 @@ public class TmfTimeRangeTest { @Test public void testEqualsReflexivity() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2); final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH); @@ -108,8 +108,8 @@ public class TmfTimeRangeTest { @Test public void testEqualsSymmetry() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2); final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2); @@ -125,8 +125,8 @@ public class TmfTimeRangeTest { @Test public void testEqualsTransivity() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range1a = new TmfTimeRange(ts1, ts2); final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2); final TmfTimeRange range1c = new TmfTimeRange(ts1, ts2); @@ -138,8 +138,8 @@ public class TmfTimeRangeTest { @Test public void testEqualsNull() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2); assertTrue("equals", !range1.equals(null)); @@ -147,8 +147,8 @@ public class TmfTimeRangeTest { @Test public void testEqualsBadType() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2); assertTrue("equals", !range1.equals(ts1)); @@ -156,9 +156,9 @@ public class TmfTimeRangeTest { @Test public void testEqualStartTime() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); - final ITmfTimestamp ts3 = new TmfTimestamp(12355); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); + final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(12355); final TmfTimeRange range1 = new TmfTimeRange(ts1, ts3); final TmfTimeRange range2 = new TmfTimeRange(ts2, ts3); @@ -170,9 +170,9 @@ public class TmfTimeRangeTest { @Test public void testEqualsEndTime() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); - final ITmfTimestamp ts3 = new TmfTimestamp(12355); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); + final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(12355); final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2); final TmfTimeRange range2 = new TmfTimeRange(ts1, ts3); @@ -188,8 +188,8 @@ public class TmfTimeRangeTest { @Test public void testToString() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final TmfTimeRange range = new TmfTimeRange(ts1, ts2); final String expected = "TmfTimeRange [fStartTime=" + ts1 + ", fEndTime=" + ts2 + "]"; @@ -202,28 +202,28 @@ public class TmfTimeRangeTest { @Test public void testContainsTimestamp() { - final ITmfTimestamp ts1 = new TmfTimestamp(12345); - final ITmfTimestamp ts2 = new TmfTimestamp(12350); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350); final 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))); + assertTrue("contains (lower bound)", range.contains(TmfTimestamp.fromSeconds(12345))); + assertTrue("contains (higher bound)", range.contains(TmfTimestamp.fromSeconds(12350))); + assertTrue("contains (within bounds)", range.contains(TmfTimestamp.fromSeconds(12346))); - assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340))); - assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351))); + assertFalse("contains (low value)", range.contains(TmfTimestamp.fromSeconds(12340))); + assertFalse("contains (high value)", range.contains(TmfTimestamp.fromSeconds(12351))); } @Test public void testContainsRange() { - final ITmfTimestamp ts1 = new TmfTimestamp(10); - final ITmfTimestamp ts2 = new TmfTimestamp(20); - final ITmfTimestamp ts3 = new TmfTimestamp(30); - final ITmfTimestamp ts4 = new TmfTimestamp(40); - final ITmfTimestamp ts5 = new TmfTimestamp(50); - final ITmfTimestamp ts6 = new TmfTimestamp(60); - final ITmfTimestamp ts7 = new TmfTimestamp(70); - final ITmfTimestamp ts8 = new TmfTimestamp(80); + final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(10); + final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(20); + final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(30); + final ITmfTimestamp ts4 = TmfTimestamp.fromSeconds(40); + final ITmfTimestamp ts5 = TmfTimestamp.fromSeconds(50); + final ITmfTimestamp ts6 = TmfTimestamp.fromSeconds(60); + final ITmfTimestamp ts7 = TmfTimestamp.fromSeconds(70); + final ITmfTimestamp ts8 = TmfTimestamp.fromSeconds(80); // Reference range final TmfTimeRange range0 = new TmfTimeRange(ts3, ts6); @@ -271,36 +271,36 @@ public class TmfTimeRangeTest { @Test public void testGetIntersection() { - final ITmfTimestamp ts1a = new TmfTimestamp(1000); - final ITmfTimestamp ts1b = new TmfTimestamp(2000); + final ITmfTimestamp ts1a = TmfTimestamp.fromSeconds(1000); + final ITmfTimestamp ts1b = TmfTimestamp.fromSeconds(2000); final TmfTimeRange range1 = new TmfTimeRange(ts1a, ts1b); - final ITmfTimestamp ts2a = new TmfTimestamp(2000); - final ITmfTimestamp ts2b = new TmfTimestamp(3000); + final ITmfTimestamp ts2a = TmfTimestamp.fromSeconds(2000); + final ITmfTimestamp ts2b = TmfTimestamp.fromSeconds(3000); final TmfTimeRange range2 = new TmfTimeRange(ts2a, ts2b); - final ITmfTimestamp ts3a = new TmfTimestamp(3000); - final ITmfTimestamp ts3b = new TmfTimestamp(4000); + final ITmfTimestamp ts3a = TmfTimestamp.fromSeconds(3000); + final ITmfTimestamp ts3b = TmfTimestamp.fromSeconds(4000); final TmfTimeRange range3 = new TmfTimeRange(ts3a, ts3b); - final ITmfTimestamp ts4a = new TmfTimestamp(1500); - final ITmfTimestamp ts4b = new TmfTimestamp(2500); + final ITmfTimestamp ts4a = TmfTimestamp.fromSeconds(1500); + final ITmfTimestamp ts4b = TmfTimestamp.fromSeconds(2500); final TmfTimeRange range4 = new TmfTimeRange(ts4a, ts4b); - final ITmfTimestamp ts5a = new TmfTimestamp(1500); - final ITmfTimestamp ts5b = new TmfTimestamp(2000); + final ITmfTimestamp ts5a = TmfTimestamp.fromSeconds(1500); + final ITmfTimestamp ts5b = TmfTimestamp.fromSeconds(2000); final TmfTimeRange range5 = new TmfTimeRange(ts5a, ts5b); - final ITmfTimestamp ts6a = new TmfTimestamp(2000); - final ITmfTimestamp ts6b = new TmfTimestamp(2500); + final ITmfTimestamp ts6a = TmfTimestamp.fromSeconds(2000); + final ITmfTimestamp ts6b = TmfTimestamp.fromSeconds(2500); final TmfTimeRange range6 = new TmfTimeRange(ts6a, ts6b); - final ITmfTimestamp ts7a = new TmfTimestamp(1500); - final ITmfTimestamp ts7b = new TmfTimestamp(3500); + final ITmfTimestamp ts7a = TmfTimestamp.fromSeconds(1500); + final ITmfTimestamp ts7b = TmfTimestamp.fromSeconds(3500); final TmfTimeRange range7 = new TmfTimeRange(ts7a, ts7b); - final ITmfTimestamp ts8a = new TmfTimestamp(2250); - final ITmfTimestamp ts8b = new TmfTimestamp(2750); + final ITmfTimestamp ts8a = TmfTimestamp.fromSeconds(2250); + final ITmfTimestamp ts8b = TmfTimestamp.fromSeconds(2750); final TmfTimeRange range8 = new TmfTimeRange(ts8a, ts8b); assertEquals("getIntersection (below - not contiguous)", null, range1.getIntersection(range3)); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampDeltaTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampDeltaTest.java index 86223ee8c3..67f2f3039c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampDeltaTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampDeltaTest.java @@ -71,8 +71,8 @@ public class TmfTimestampDeltaTest { @Test public void testCopyConstructor() { - final ITmfTimestamp ts = new TmfTimestamp(12345, 2); - final ITmfTimestamp copy = new TmfTimestamp(ts); + final ITmfTimestamp ts = TmfTimestamp.create(12345, 2); + final ITmfTimestamp copy = TmfTimestamp.create(12345, 2); assertEquals("getValue", ts.getValue(), copy.getValue()); assertEquals("getscale", ts.getScale(), copy.getScale()); @@ -81,11 +81,6 @@ public class TmfTimestampDeltaTest { assertEquals("getscale", 2, copy.getScale()); } - @Test(expected=IllegalArgumentException.class) - public void testCopyNullConstructor() { - new TmfTimestamp((TmfTimestamp) null); - } - // ------------------------------------------------------------------------ // normalize // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampTest.java index 3212b35fd8..1a0c1333ee 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfTimestampTest.java @@ -38,18 +38,18 @@ public class TmfTimestampTest { // Variables // ------------------------------------------------------------------------ - private final ITmfTimestamp ts0 = new TmfTimestamp(); - private final ITmfTimestamp ts1 = new TmfTimestamp(12345, 0); - private final ITmfTimestamp ts2 = new TmfTimestamp(12345, -1); - private final ITmfTimestamp ts3 = new TmfTimestamp(12345, 2); - private final ITmfTimestamp ts4 = new TmfTimestamp(12345, -3); - private final ITmfTimestamp ts5 = new TmfTimestamp(12345, -6); - private final ITmfTimestamp ts6 = new TmfTimestamp(12345, -9); - private final ITmfTimestamp ts7 = new TmfTimestamp(-12345, -3); - private final ITmfTimestamp ts8 = new TmfTimestamp(-12345, -6); - private final ITmfTimestamp ts9 = new TmfTimestamp(-12345, -9); - private final ITmfTimestamp ts10 = new TmfTimestamp(Long.MAX_VALUE / 100, -6); - private final ITmfTimestamp ts11 = new TmfTimestamp(Long.MIN_VALUE / 100, -6); + private final ITmfTimestamp ts0 = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE); + private final ITmfTimestamp ts1 = TmfTimestamp.create(12345, 0); + private final ITmfTimestamp ts2 = TmfTimestamp.create(12345, -1); + private final ITmfTimestamp ts3 = TmfTimestamp.create(12345, 2); + private final ITmfTimestamp ts4 = TmfTimestamp.create(12345, -3); + private final ITmfTimestamp ts5 = TmfTimestamp.create(12345, -6); + private final ITmfTimestamp ts6 = TmfTimestamp.create(12345, -9); + private final ITmfTimestamp ts7 = TmfTimestamp.create(-12345, -3); + private final ITmfTimestamp ts8 = TmfTimestamp.create(-12345, -6); + private final ITmfTimestamp ts9 = TmfTimestamp.create(-12345, -9); + private final ITmfTimestamp ts10 = TmfTimestamp.create(Long.MAX_VALUE / 100, -6); + private final ITmfTimestamp ts11 = TmfTimestamp.create(Long.MIN_VALUE / 100, -6); // ------------------------------------------------------------------------ // Constructors @@ -81,8 +81,8 @@ public class TmfTimestampTest { @Test public void testCopyConstructor() { - final ITmfTimestamp ts = new TmfTimestamp(12345, 2); - final ITmfTimestamp copy = new TmfTimestamp(ts); + final ITmfTimestamp ts = TmfTimestamp.create(12345, 2); + final ITmfTimestamp copy = TmfTimestamp.create(ts.getValue(), ts.getScale()); assertEquals("getValue", ts.getValue(), copy.getValue()); assertEquals("getscale", ts.getScale(), copy.getScale()); @@ -91,28 +91,23 @@ public class TmfTimestampTest { assertEquals("getscale", 2, copy.getScale()); } - @Test(expected = IllegalArgumentException.class) - public void testCopyNullConstructor() { - new TmfTimestamp((TmfTimestamp) null); - } - @Test public void testCopyConstructorBigBang() { - final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BIG_BANG); + final ITmfTimestamp ts = TmfTimestamp.create(TmfTimestamp.BIG_BANG.getValue(), TmfTimestamp.BIG_BANG.getScale()); assertEquals("getValue", TmfTimestamp.BIG_BANG.getValue(), ts.getValue()); assertEquals("getscale", TmfTimestamp.BIG_BANG.getScale(), ts.getScale()); } @Test public void testCopyConstructorBigCrunch() { - final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BIG_CRUNCH); + final ITmfTimestamp ts = TmfTimestamp.create(TmfTimestamp.BIG_CRUNCH.getValue(), TmfTimestamp.BIG_CRUNCH.getScale()); assertEquals("getValue", TmfTimestamp.BIG_CRUNCH.getValue(), ts.getValue()); assertEquals("getscale", TmfTimestamp.BIG_CRUNCH.getScale(), ts.getScale()); } @Test public void testCopyConstructorZero() { - final ITmfTimestamp ts = new TmfTimestamp(TmfTimestamp.ZERO); + final ITmfTimestamp ts = TmfTimestamp.create(TmfTimestamp.ZERO.getValue(), TmfTimestamp.ZERO.getScale()); assertEquals("getValue", TmfTimestamp.ZERO.getValue(), ts.getValue()); assertEquals("getscale", TmfTimestamp.ZERO.getScale(), ts.getScale()); } @@ -123,13 +118,13 @@ public class TmfTimestampTest { @Test public void testHashCode() { - final ITmfTimestamp ts0copy = new TmfTimestamp(ts0); - final ITmfTimestamp ts1copy = new TmfTimestamp(ts1); - final ITmfTimestamp ts2copy = new TmfTimestamp(ts2); + final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale()); + final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale()); + final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale()); - assertTrue("hashCode", ts0.hashCode() == ts0copy.hashCode()); - assertTrue("hashCode", ts1.hashCode() == ts1copy.hashCode()); - assertTrue("hashCode", ts2.hashCode() == ts2copy.hashCode()); + assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode()); + assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode()); + assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode()); assertTrue("hashCode", ts0.hashCode() != ts1.hashCode()); } @@ -140,44 +135,44 @@ public class TmfTimestampTest { @Test public void testEqualsReflexivity() { - assertTrue("equals", ts0.equals(ts0)); - assertTrue("equals", ts1.equals(ts1)); + assertEquals("equals", ts0, ts0); + assertEquals("equals", ts1, ts1); - assertTrue("equals", !ts0.equals(ts1)); - assertTrue("equals", !ts1.equals(ts0)); + assertFalse("Different", ts0.equals(ts1)); + assertFalse("Different", ts1.equals(ts0)); } @Test public void testEqualsSymmetry() { - final ITmfTimestamp ts0copy = new TmfTimestamp(ts0); - assertTrue("equals", ts0.equals(ts0copy)); - assertTrue("equals", ts0copy.equals(ts0)); + final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale()); + assertEquals("equals", ts0, ts0copy); + assertEquals("equals", ts0copy, ts0); - final ITmfTimestamp ts1copy = new TmfTimestamp(ts1); - assertTrue("equals", ts1.equals(ts1copy)); - assertTrue("equals", ts1copy.equals(ts1)); + final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale()); + assertEquals("equals", ts1, ts1copy); + assertEquals("equals", ts1copy, ts1); - final ITmfTimestamp ts2copy = new TmfTimestamp(ts2); - assertTrue("equals", ts2.equals(ts2copy)); - assertTrue("equals", ts2copy.equals(ts2)); + final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale()); + assertEquals("equals", ts2, ts2copy); + assertEquals("equals", ts2copy, ts2); } @Test public void testEqualsTransivity() { - final ITmfTimestamp ts0copy1 = new TmfTimestamp(ts0); - final ITmfTimestamp ts0copy2 = new TmfTimestamp(ts0copy1); + final ITmfTimestamp ts0copy1 = TmfTimestamp.create(ts0.getValue(), ts0.getScale()); + final ITmfTimestamp ts0copy2 = TmfTimestamp.create(ts0copy1.getValue(), ts0copy1.getScale()); assertTrue("equals", ts0.equals(ts0copy1)); assertTrue("equals", ts0copy1.equals(ts0copy2)); assertTrue("equals", ts0.equals(ts0copy2)); - final ITmfTimestamp ts1copy1 = new TmfTimestamp(ts1); - final ITmfTimestamp ts1copy2 = new TmfTimestamp(ts1copy1); + final ITmfTimestamp ts1copy1 = TmfTimestamp.create(ts1.getValue(), ts1.getScale()); + final ITmfTimestamp ts1copy2 = TmfTimestamp.create(ts1copy1.getValue(), ts1copy1.getScale()); assertTrue("equals", ts1.equals(ts1copy1)); assertTrue("equals", ts1copy1.equals(ts1copy2)); assertTrue("equals", ts1.equals(ts1copy2)); - final ITmfTimestamp ts2copy1 = new TmfTimestamp(ts2); - final ITmfTimestamp ts2copy2 = new TmfTimestamp(ts2copy1); + final ITmfTimestamp ts2copy1 = TmfTimestamp.create(ts2.getValue(), ts2.getScale()); + final ITmfTimestamp ts2copy2 = TmfTimestamp.create(ts2copy1.getValue(), ts2copy1.getScale()); assertTrue("equals", ts2.equals(ts2copy1)); assertTrue("equals", ts2copy1.equals(ts2copy2)); assertTrue("equals", ts2.equals(ts2copy2)); @@ -262,7 +257,7 @@ public class TmfTimestampTest { @Test public void testNormalizeOffsetLowerLimits() { - final ITmfTimestamp ref = new TmfTimestamp(Long.MIN_VALUE + 5, 0); + final ITmfTimestamp ref = TmfTimestamp.create(Long.MIN_VALUE + 5, 0); ITmfTimestamp ts = ref.normalize(-4, 0); assertEquals("getValue", Long.MIN_VALUE + 1, ts.getValue()); @@ -279,7 +274,7 @@ public class TmfTimestampTest { @Test public void testNormalizeOffsetUpperLimits() { - final ITmfTimestamp ref = new TmfTimestamp(Long.MAX_VALUE - 5, 0); + final ITmfTimestamp ref = TmfTimestamp.create(Long.MAX_VALUE - 5, 0); ITmfTimestamp ts = ref.normalize(4, 0); assertEquals("getValue", Long.MAX_VALUE - 1, ts.getValue()); @@ -385,10 +380,10 @@ public class TmfTimestampTest { @Test public void testBasicCompareTo() { - final ITmfTimestamp t1 = new TmfTimestamp(900, 0); - final ITmfTimestamp t2 = new TmfTimestamp(1000, 0); - final ITmfTimestamp t3 = new TmfTimestamp(1100, 0); - final ITmfTimestamp t4 = new TmfTimestamp(1000, 0); + final ITmfTimestamp t1 = TmfTimestamp.create(900, 0); + final ITmfTimestamp t2 = TmfTimestamp.create(1000, 0); + final ITmfTimestamp t3 = TmfTimestamp.create(1100, 0); + final ITmfTimestamp t4 = TmfTimestamp.create(1000, 0); assertTrue(t1.compareTo(t1) == 0); @@ -407,10 +402,10 @@ public class TmfTimestampTest { @Test public void testCompareToCornerCases1() { - final ITmfTimestamp ts0a = new TmfTimestamp(ts0); - final ITmfTimestamp ts0b = new TmfTimestamp(ts0.getValue(), ts0.getScale() + 1); - final ITmfTimestamp ts0c = new TmfTimestamp(ts0.getValue() + 1, ts0.getScale()); - final ITmfTimestamp ts0d = new TmfTimestamp(ts0.getValue() + 1, ts0.getScale() + 1); + final ITmfTimestamp ts0a = TmfTimestamp.create(ts0.getValue(), ts0.getScale()); + final ITmfTimestamp ts0b = TmfTimestamp.create(ts0.getValue(), ts0.getScale() + 1); + final ITmfTimestamp ts0c = TmfTimestamp.create(ts0.getValue() + 1, ts0.getScale()); + final ITmfTimestamp ts0d = TmfTimestamp.create(ts0.getValue() + 1, ts0.getScale() + 1); assertTrue("compareTo", ts0.compareTo(ts0) == 0); assertTrue("compareTo", ts0.compareTo(ts0a) == 0); @@ -421,9 +416,9 @@ public class TmfTimestampTest { @Test public void testCompareToCornerCases2() { - final ITmfTimestamp ts0a = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE - 1); - final ITmfTimestamp ts0b = new TmfTimestamp(0, Integer.MAX_VALUE); - final ITmfTimestamp ts0c = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE); + final ITmfTimestamp ts0a = TmfTimestamp.create(Long.MAX_VALUE, Integer.MAX_VALUE - 1); + final ITmfTimestamp ts0b = TmfTimestamp.create(0, Integer.MAX_VALUE); + final ITmfTimestamp ts0c = TmfTimestamp.create(Long.MAX_VALUE, Integer.MAX_VALUE); assertEquals("compareTo", 1, ts0a.compareTo(ts0b)); assertEquals("compareTo", -1, ts0a.compareTo(ts0c)); @@ -437,9 +432,9 @@ public class TmfTimestampTest { @Test public void testCompareToCornerCases3() { - final ITmfTimestamp ts0a = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE - 1); - final ITmfTimestamp ts0b = new TmfTimestamp(0, Integer.MAX_VALUE); - final ITmfTimestamp ts0c = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE); + final ITmfTimestamp ts0a = TmfTimestamp.create(Long.MIN_VALUE, Integer.MAX_VALUE - 1); + final ITmfTimestamp ts0b = TmfTimestamp.create(0, Integer.MAX_VALUE); + final ITmfTimestamp ts0c = TmfTimestamp.create(Long.MIN_VALUE, Integer.MAX_VALUE); assertEquals("compareTo", -1, ts0a.compareTo(ts0b)); assertEquals("compareTo", 1, ts0a.compareTo(ts0c)); @@ -458,10 +453,10 @@ public class TmfTimestampTest { @Test public void testCompareToSameScale() { - final ITmfTimestamp t1 = new TmfTimestamp(900, 0); - final ITmfTimestamp t2 = new TmfTimestamp(1000, 0); - final ITmfTimestamp t3 = new TmfTimestamp(1100, 0); - final ITmfTimestamp t4 = new TmfTimestamp(1000, 0); + final ITmfTimestamp t1 = TmfTimestamp.create(900, 0); + final ITmfTimestamp t2 = TmfTimestamp.create(1000, 0); + final ITmfTimestamp t3 = TmfTimestamp.create(1100, 0); + final ITmfTimestamp t4 = TmfTimestamp.create(1000, 0); assertEquals(0, t1.compareTo(t1)); @@ -480,10 +475,10 @@ public class TmfTimestampTest { @Test public void testCompareToDifferentScale() { - final ITmfTimestamp t1 = new TmfTimestamp(9000, -1); - final ITmfTimestamp t2 = new TmfTimestamp(1000, 0); - final ITmfTimestamp t3 = new TmfTimestamp(110, 1); - final ITmfTimestamp t4 = new TmfTimestamp(1, 3); + final ITmfTimestamp t1 = TmfTimestamp.create(9000, -1); + final ITmfTimestamp t2 = TmfTimestamp.create(1000, 0); + final ITmfTimestamp t3 = TmfTimestamp.create(110, 1); + final ITmfTimestamp t4 = TmfTimestamp.create(1, 3); assertTrue("CompareTo", t1.compareTo(t1) == 0); @@ -502,10 +497,10 @@ public class TmfTimestampTest { @Test public void testCompareToLargeScale1() { - final ITmfTimestamp t1 = new TmfTimestamp(-1, 100); - final ITmfTimestamp t2 = new TmfTimestamp(-1000, -100); - final ITmfTimestamp t3 = new TmfTimestamp(1, 100); - final ITmfTimestamp t4 = new TmfTimestamp(1000, -100); + final ITmfTimestamp t1 = TmfTimestamp.create(-1, 100); + final ITmfTimestamp t2 = TmfTimestamp.create(-1000, -100); + final ITmfTimestamp t3 = TmfTimestamp.create(1, 100); + final ITmfTimestamp t4 = TmfTimestamp.create(1000, -100); assertEquals("CompareTo", -1, t1.compareTo(t2)); assertTrue("CompareTo", t1.compareTo(t3) < 0); @@ -526,8 +521,8 @@ public class TmfTimestampTest { @Test public void testCompareToLargeScale2() { - final ITmfTimestamp ts0a = new TmfTimestamp(0, Integer.MAX_VALUE); - final ITmfTimestamp ts0b = new TmfTimestamp(1, Integer.MAX_VALUE); + final ITmfTimestamp ts0a = TmfTimestamp.create(0, Integer.MAX_VALUE); + final ITmfTimestamp ts0b = TmfTimestamp.create(1, Integer.MAX_VALUE); assertEquals("CompareTo", 0, ts0a.compareTo(ts0)); assertEquals("CompareTo", 0, ts0.compareTo(ts0a)); @@ -543,57 +538,57 @@ public class TmfTimestampTest { @Test public void testDelta() { // Delta for same scale and precision (delta > 0) - ITmfTimestamp t0 = new TmfTimestamp(10, 9); - ITmfTimestamp t1 = new TmfTimestamp(5, 9); - ITmfTimestamp exp = new TmfTimestamp(5, 9); + ITmfTimestamp t0 = TmfTimestamp.create(10, 9); + ITmfTimestamp t1 = TmfTimestamp.create(5, 9); + ITmfTimestamp exp = TmfTimestamp.create(5, 9); ITmfTimestamp delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); // Delta for same scale and precision (delta < 0) - t0 = new TmfTimestamp(5, 9); - t1 = new TmfTimestamp(10, 9); - exp = new TmfTimestamp(-5, 9); + t0 = TmfTimestamp.create(5, 9); + t1 = TmfTimestamp.create(10, 9); + exp = TmfTimestamp.create(-5, 9); delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); // Delta for different scale and same precision (delta > 0) - t0 = new TmfTimestamp(5, 9); - t1 = new TmfTimestamp(10, 8); - exp = new TmfTimestamp(4, 9); + t0 = TmfTimestamp.create(5, 9); + t1 = TmfTimestamp.create(10, 8); + exp = TmfTimestamp.create(4, 9); delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); // Delta for different scale and same precision (delta > 0) - t0 = new TmfTimestamp(5, 9); - t1 = new TmfTimestamp(10, 7); - exp = new TmfTimestamp(5, 9); + t0 = TmfTimestamp.create(5, 9); + t1 = TmfTimestamp.create(10, 7); + exp = TmfTimestamp.create(5, 9); delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); // Delta for different scale and same precision - t0 = new TmfTimestamp(10, 9); - t1 = new TmfTimestamp(5, 8); - exp = new TmfTimestamp(10, 9); + t0 = TmfTimestamp.create(10, 9); + t1 = TmfTimestamp.create(5, 8); + exp = TmfTimestamp.create(10, 9); delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); // Delta for same scale - t0 = new TmfTimestamp(10, 9); - t1 = new TmfTimestamp(5, 9); - exp = new TmfTimestamp(5, 9); + t0 = TmfTimestamp.create(10, 9); + t1 = TmfTimestamp.create(5, 9); + exp = TmfTimestamp.create(5, 9); delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); // Delta for different scale - t0 = new TmfTimestamp(5, 9); - t1 = new TmfTimestamp(10, 8); - exp = new TmfTimestamp(4, 9); + t0 = TmfTimestamp.create(5, 9); + t1 = TmfTimestamp.create(10, 8); + exp = TmfTimestamp.create(4, 9); delta = t0.getDelta(t1); assertEquals("getDelta", 0, delta.compareTo(exp)); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfCollapseFilterTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfCollapseFilterTest.java index b7ebc41a4a..03a10620c5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfCollapseFilterTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfCollapseFilterTest.java @@ -30,7 +30,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventType; import org.eclipse.tracecompass.tmf.core.event.collapse.ITmfCollapsibleEvent; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.junit.After; @@ -159,7 +159,7 @@ public class TmfCollapseFilterTest { @Override public ITmfTimestamp getTimestamp() { - return new TmfNanoTimestamp(100); + return TmfTimestamp.fromNanos(100); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterAndNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterAndNodeTest.java index 0e9193b490..b0cdc92028 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterAndNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterAndNodeTest.java @@ -30,7 +30,7 @@ import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterEqualsNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -47,7 +47,7 @@ public class TmfFilterAndNodeTest extends TmfFilterTreeNodeTestBase { // ------------------------------------------------------------------------ private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null); - private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent); + private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent); private TmfFilterAndNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterCompareNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterCompareNodeTest.java index 670202a976..fc109f7533 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterCompareNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterCompareNodeTest.java @@ -24,7 +24,7 @@ import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterCompareNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterCompareNode.Type; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -46,9 +46,9 @@ public class TmfFilterCompareNodeTest extends TmfFilterTreeNodeTestBase { private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1); private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2); private ITmfEventField fContent3 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields3); - private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1); - private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2); - private TmfEvent fEvent3 = new TmfEvent(TRACE, 2, new TmfNanoTimestamp(3), EVENT_TYPE, fContent3); + private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1); + private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2); + private TmfEvent fEvent3 = new TmfEvent(TRACE, 2, TmfTimestamp.fromNanos(3), EVENT_TYPE, fContent3); private TmfFilterCompareNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterContainsNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterContainsNodeTest.java index 123614feb6..34ccdaa300 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterContainsNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterContainsNodeTest.java @@ -22,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterContainsNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -42,8 +42,8 @@ public class TmfFilterContainsNodeTest extends TmfFilterTreeNodeTestBase { private ITmfEventField[] fFields2 = new ITmfEventField[] { new TmfEventField(FIELD, "value 2", null) }; private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1); private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2); - private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1); - private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2); + private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1); + private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2); private TmfFilterContainsNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterEqualsNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterEqualsNodeTest.java index 33051722f7..b0e250d08e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterEqualsNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterEqualsNodeTest.java @@ -22,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterEqualsNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -42,8 +42,8 @@ public class TmfFilterEqualsNodeTest extends TmfFilterTreeNodeTestBase { private ITmfEventField[] fFields2 = new ITmfEventField[] { new TmfEventField(FIELD, "value 2", null) }; private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1); private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2); - private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1); - private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2); + private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1); + private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2); private TmfFilterEqualsNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterMatchesNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterMatchesNodeTest.java index c16e08e5f9..8210567b50 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterMatchesNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterMatchesNodeTest.java @@ -22,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -42,8 +42,8 @@ public class TmfFilterMatchesNodeTest extends TmfFilterTreeNodeTestBase { private ITmfEventField[] fFields2 = new ITmfEventField[] { new TmfEventField(FIELD, "value 2", null) }; private ITmfEventField fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields1); private ITmfEventField fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fFields2); - private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent1); - private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, new TmfNanoTimestamp(2), EVENT_TYPE, fContent2); + private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent1); + private TmfEvent fEvent2 = new TmfEvent(TRACE, 1, TmfTimestamp.fromNanos(2), EVENT_TYPE, fContent2); private TmfFilterMatchesNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterNodeTest.java index 27b74bc782..32eb05e1c6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterNodeTest.java @@ -31,7 +31,7 @@ import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -49,7 +49,7 @@ public class TmfFilterNodeTest extends TmfFilterTreeNodeTestBase { private static final String FILTER = "filter"; private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null); - private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent); + private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent); private TmfFilterNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterOrNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterOrNodeTest.java index 8c0a7ffe1b..f78b99556b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterOrNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterOrNodeTest.java @@ -30,7 +30,7 @@ import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterEqualsNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterMatchesNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterOrNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterTraceTypeNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -47,7 +47,7 @@ public class TmfFilterOrNodeTest extends TmfFilterTreeNodeTestBase { // ------------------------------------------------------------------------ private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null); - private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent); + private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent); private TmfFilterOrNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterRootNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterRootNodeTest.java index bcd444f644..41c3c1c532 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterRootNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterRootNodeTest.java @@ -22,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterNode; import org.eclipse.tracecompass.tmf.core.filter.model.TmfFilterRootNode; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Before; import org.junit.Test; @@ -39,7 +39,7 @@ public class TmfFilterRootNodeTest extends TmfFilterTreeNodeTestBase { // ------------------------------------------------------------------------ private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null); - private TmfEvent fEvent = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent); + private TmfEvent fEvent = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent); private TmfFilterRootNode fFilter; // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterTraceTypeNodeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterTraceTypeNodeTest.java index e9cac2952b..7ecbb3b335 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterTraceTypeNodeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/filter/TmfFilterTraceTypeNodeTest.java @@ -40,7 +40,7 @@ import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlEventType; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub; import org.junit.AfterClass; import org.junit.Before; @@ -79,9 +79,9 @@ public class TmfFilterTraceTypeNodeTest extends TmfFilterTreeNodeTestBase { private static TmfEventType fCustomTxtEventType = new CustomTxtEventType(fCustomTxtDefinition); private static TmfEventType fCustomXmlEventType = new CustomXmlEventType(fCustomXmlDefinition); private ITmfEventField fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, null); - private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, new TmfNanoTimestamp(1), EVENT_TYPE, fContent); - private TmfEvent fEvent2 = new CustomTxtEvent(fCustomTxtDefinition, fCustomTxtTrace, new TmfNanoTimestamp(2), fCustomTxtEventType); - private TmfEvent fEvent3 = new CustomXmlEvent(fCustomXmlDefinition, fCustomXmlTrace, new TmfNanoTimestamp(3), fCustomXmlEventType); + private TmfEvent fEvent1 = new TmfEvent(TRACE, 0, TmfTimestamp.fromNanos(1), EVENT_TYPE, fContent); + private TmfEvent fEvent2 = new CustomTxtEvent(fCustomTxtDefinition, fCustomTxtTrace, TmfTimestamp.fromNanos(2), fCustomTxtEventType); + private TmfEvent fEvent3 = new CustomXmlEvent(fCustomXmlDefinition, fCustomXmlTrace, TmfTimestamp.fromNanos(3), fCustomXmlEventType); private TmfFilterTraceTypeNode fFilter; @AfterClass diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfCoalescedEventRequestTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfCoalescedEventRequestTest.java index 20e90d02e3..e9ad4cadd6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfCoalescedEventRequestTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfCoalescedEventRequestTest.java @@ -37,6 +37,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub; @@ -55,7 +56,7 @@ public class TmfCoalescedEventRequestTest { // ------------------------------------------------------------------------ private final TmfTimeRange range1 = TmfTimeRange.ETERNITY; - private final TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH); + private final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE), TmfTimestamp.BIG_CRUNCH); private TmfCoalescedEventRequest fRequest1; private TmfCoalescedEventRequest fRequest2; @@ -438,7 +439,7 @@ public class TmfCoalescedEventRequestTest { */ @TmfSignalHandler public void trigger(final TmfTestTriggerSignal2 signal) { - TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(100, -3), TmfTimestamp.BIG_CRUNCH); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(100, -3), TmfTimestamp.BIG_CRUNCH); requestedEvents1 = new Vector<>(); request1 = new TmfEventRequest(ITmfEvent.class, range, 0, 1, ExecutionType.FOREGROUND) { @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfEventRequestTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfEventRequestTest.java index cc58654fd9..fbc536567c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfEventRequestTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/request/TmfEventRequestTest.java @@ -38,7 +38,7 @@ public class TmfEventRequestTest { // ------------------------------------------------------------------------ private static TmfTimeRange range1 = TmfTimeRange.ETERNITY; - private static TmfTimeRange range2 = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH); + private static TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH); private static TmfEventRequest fRequest1; private static TmfEventRequest fRequest2; @@ -115,12 +115,12 @@ public class TmfEventRequestTest { @Test public void testTmfEventRequestTimeRange() { - TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH); TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range); assertEquals("getDataType", ITmfEvent.class, request.getDataType()); - assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime()); + assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime()); assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime()); assertEquals("getIndex", 0, request.getIndex()); @@ -135,12 +135,12 @@ public class TmfEventRequestTest { @Test public void testTmfEventRequestTimeRangeNbRequested() { - TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH); TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100); assertEquals("getDataType", ITmfEvent.class, request.getDataType()); - assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime()); + assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime()); assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime()); assertEquals("getIndex", 0, request.getIndex()); @@ -155,12 +155,12 @@ public class TmfEventRequestTest { @Test public void testTmfEventRequestTimeRangeNbRequestedBlocksize() { - TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(), TmfTimestamp.BIG_CRUNCH); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH); TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200); assertEquals("getDataType", ITmfEvent.class, request.getDataType()); - assertEquals("StartTime", new TmfTimestamp(), request.getRange().getStartTime()); + assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime()); assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime()); assertEquals("getIndex", 0, request.getIndex()); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java index 76c1ec9766..83c1150b80 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java @@ -31,7 +31,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub; @@ -113,7 +113,7 @@ class TmfMipmapStateProviderStub extends AbstractTmfMipmapStateProvider { } else { value = TmfStateValue.nullValue(); } - ITmfTimestamp timestamp = new TmfNanoTimestamp(time); + ITmfTimestamp timestamp = TmfTimestamp.fromNanos(time); ITmfEventType eventType = new TmfEventType(MIPMAP_ID, null); ITmfEventField content = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, value, null); ITmfEvent event = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, timestamp, eventType, content); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java index a3c55e0077..d74d1b6549 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderWeightedTest.java @@ -25,8 +25,8 @@ import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFact import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; -import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type; +import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.junit.BeforeClass; import org.junit.Test; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java index ac38003992..5d6b94a238 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java @@ -195,8 +195,8 @@ public class SyncTest { private static void addSyncMatch(SynchronizationAlgorithm algo, ITmfTrace sender, long sendTs, ITmfTrace receiver, long receiveTs) { algo.addMatch( new TmfEventDependency( - new TmfSyncEventStub(sender, new TmfTimestamp(sendTs)), - new TmfSyncEventStub(receiver, new TmfTimestamp(receiveTs)) + new TmfSyncEventStub(sender, TmfTimestamp.fromSeconds(sendTs)), + new TmfSyncEventStub(receiver, TmfTimestamp.fromSeconds(receiveTs)) )); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformFactoryTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformFactoryTest.java index 1374e18779..78de389de5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformFactoryTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformFactoryTest.java @@ -22,7 +22,6 @@ import org.eclipse.tracecompass.internal.tmf.core.synchronization.TmfConstantTra import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.junit.Test; @@ -34,18 +33,18 @@ import org.junit.Test; */ @NonNullByDefault public class TsTransformFactoryTest { - private final ITmfTimestamp t0 = new TmfTimestamp(0); - private final ITmfTimestamp t100 = new TmfTimestamp(100); - private final ITmfTimestamp t1e2 = new TmfTimestamp(1, 2); - private final ITmfTimestamp t1e3 = new TmfTimestamp(1, 3); - private final ITmfTimestamp tn0 = new TmfNanoTimestamp(0); - private final ITmfTimestamp tn100 = new TmfNanoTimestamp(100); - private final ITmfTimestamp tn1 = new TmfNanoTimestamp(1); - private final ITmfTimestampTransform identity1 = TimestampTransformFactory.createLinear(1.0, new TmfNanoTimestamp(0)); + private final ITmfTimestamp t0 = TmfTimestamp.fromSeconds(0); + private final ITmfTimestamp t100 = TmfTimestamp.fromSeconds(100); + private final ITmfTimestamp t1e2 = TmfTimestamp.create(1, 2); + private final ITmfTimestamp t1e3 = TmfTimestamp.create(1, 3); + private final ITmfTimestamp tn0 = TmfTimestamp.fromNanos(0); + private final ITmfTimestamp tn100 = TmfTimestamp.fromNanos(100); + private final ITmfTimestamp tn1 = TmfTimestamp.fromNanos(1); + private final ITmfTimestampTransform identity1 = TimestampTransformFactory.createLinear(1.0, TmfTimestamp.fromNanos(0)); private final ITmfTimestampTransform offset1 = TimestampTransformFactory.createWithOffset(100); private final ITmfTimestampTransform offset2 = TimestampTransformFactory.createLinear(NonNullUtils.checkNotNull(BigDecimal.ONE), NonNullUtils.checkNotNull(new BigDecimal(100))); private final ITmfTimestampTransform offset3 = TimestampTransformFactory.createLinear(1.0, 100); - private final ITmfTimestampTransform offset4 = TimestampTransformFactory.createLinear(1.0, new TmfNanoTimestamp(100)); + private final ITmfTimestampTransform offset4 = TimestampTransformFactory.createLinear(1.0, TmfTimestamp.fromNanos(100)); /** * Test with identity @@ -79,7 +78,7 @@ public class TsTransformFactoryTest { @Test public void transformOffset() { final ITmfTimestampTransform offset = offset1; - final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.createWithOffset(new TmfNanoTimestamp(-100))); + final ITmfTimestampTransform compositeTransform = offset.composeWith(TimestampTransformFactory.createWithOffset(TmfTimestamp.fromNanos(-100))); assertEquals(tn100, offset.transform(t0)); assertEquals(tn100, offset.transform(tn0)); assertEquals(tn0, compositeTransform.transform(tn0)); @@ -96,12 +95,12 @@ public class TsTransformFactoryTest { @Test public void transformSlope() { final ITmfTimestampTransform slope = TimestampTransformFactory.createLinear(10, 0); - final ITmfTimestampTransform slope1 = TimestampTransformFactory.createLinear(10.0, new TmfNanoTimestamp(0)); + final ITmfTimestampTransform slope1 = TimestampTransformFactory.createLinear(10.0, TmfTimestamp.fromNanos(0)); assertEquals(t1e3, slope.transform(t1e2)); - assertEquals(tn100, slope.transform(new TmfNanoTimestamp(10))); + assertEquals(tn100, slope.transform(TmfTimestamp.fromNanos(10))); assertEquals(tn100, slope.transform(slope.transform(tn1))); assertEquals(tn100, slope.composeWith(slope).transform(tn1)); - assertEquals(tn100, slope1.transform(new TmfNanoTimestamp(10))); + assertEquals(tn100, slope1.transform(TmfTimestamp.fromNanos(10))); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformTest.java index 017fecdb3e..7839cdc448 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/TsTransformTest.java @@ -37,7 +37,7 @@ import org.junit.Test; public class TsTransformTest { private static final long ts = 1361657893526374091L; - private static final @NonNull ITmfTimestamp oTs = new TmfTimestamp(ts); + private static final @NonNull ITmfTimestamp oTs = TmfTimestamp.fromSeconds(ts); /** * Test the linear transform diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfContextTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfContextTest.java index d5b00de491..4f3a45dd52 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfContextTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfContextTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.TmfContext; @@ -38,7 +39,7 @@ public class TmfContextTest { // ------------------------------------------------------------------------ private final Long aLong = 12345L; - private final TmfTimestamp aTimestamp = new TmfTimestamp(); + private final ITmfTimestamp aTimestamp = TmfTimestamp.fromSeconds(0); private final TmfLongLocation fLocation1 = new TmfLongLocation(aLong); private final TmfTimestampLocation fLocation2 = new TmfTimestampLocation(aTimestamp); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java index 87b48e6b7c..1649a39655 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java @@ -190,14 +190,14 @@ public class TmfExperimentTest { @Test public void testGetTimestamp() { - assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0)); - assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1)); - assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10)); - assertEquals("getTimestamp", new TmfTimestamp( 101, (byte) -3), fExperiment.getTimestamp( 100)); - assertEquals("getTimestamp", new TmfTimestamp( 1001, (byte) -3), fExperiment.getTimestamp(1000)); - assertEquals("getTimestamp", new TmfTimestamp( 2001, (byte) -3), fExperiment.getTimestamp(2000)); - assertEquals("getTimestamp", new TmfTimestamp( 2501, (byte) -3), fExperiment.getTimestamp(2500)); - assertEquals("getTimestamp", new TmfTimestamp(10000, (byte) -3), fExperiment.getTimestamp(9999)); + assertEquals("getTimestamp", TmfTimestamp.create( 1, (byte) -3), fExperiment.getTimestamp( 0)); + assertEquals("getTimestamp", TmfTimestamp.create( 2, (byte) -3), fExperiment.getTimestamp( 1)); + assertEquals("getTimestamp", TmfTimestamp.create( 11, (byte) -3), fExperiment.getTimestamp( 10)); + assertEquals("getTimestamp", TmfTimestamp.create( 101, (byte) -3), fExperiment.getTimestamp( 100)); + assertEquals("getTimestamp", TmfTimestamp.create( 1001, (byte) -3), fExperiment.getTimestamp(1000)); + assertEquals("getTimestamp", TmfTimestamp.create( 2001, (byte) -3), fExperiment.getTimestamp(2000)); + assertEquals("getTimestamp", TmfTimestamp.create( 2501, (byte) -3), fExperiment.getTimestamp(2500)); + assertEquals("getTimestamp", TmfTimestamp.create(10000, (byte) -3), fExperiment.getTimestamp(9999)); assertNull("getTimestamp", fExperiment.getTimestamp(10000)); } @@ -407,7 +407,7 @@ public class TmfExperimentTest { long cacheSize = fExperiment.getCacheSize(); // Position trace at event rank 0 - ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE)); + ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(1, SCALE)); assertEquals("Context rank", 0, context.getRank()); ITmfEvent event = fExperiment.getNext(context); @@ -415,7 +415,7 @@ public class TmfExperimentTest { assertEquals("Context rank", 1, context.getRank()); // Position trace at event rank [cacheSize] - context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(cacheSize + 1, SCALE)); assertEquals("Event rank", cacheSize, context.getRank()); event = fExperiment.getNext(context); @@ -423,7 +423,7 @@ public class TmfExperimentTest { assertEquals("Context rank", cacheSize + 1, context.getRank()); // Position trace at event rank [4 * cacheSize] - context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(4 * cacheSize + 1, SCALE)); assertEquals("Context rank", 4 * cacheSize, context.getRank()); event = fExperiment.getNext(context); @@ -434,7 +434,7 @@ public class TmfExperimentTest { @Test public void testSeekTimestampNotOnCacheBoundary() { // Position trace at event rank 1 (TS = 2) - ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE)); + ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(2, SCALE)); assertEquals("Context rank", 1, context.getRank()); ITmfEvent event = fExperiment.getNext(context); @@ -442,7 +442,7 @@ public class TmfExperimentTest { assertEquals("Context rank", 2, context.getRank()); // Position trace at event rank 9 (TS = 10) - context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(10, SCALE)); assertEquals("Context rank", 9, context.getRank()); event = fExperiment.getNext(context); @@ -450,7 +450,7 @@ public class TmfExperimentTest { assertEquals("Context rank", 10, context.getRank()); // Position trace at event rank 999 (TS = 1000) - context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(1000, SCALE)); assertEquals("Context rank", 999, context.getRank()); event = fExperiment.getNext(context); @@ -458,7 +458,7 @@ public class TmfExperimentTest { assertEquals("Context rank", 1000, context.getRank()); // Position trace at event rank 1001 (TS = 1002) - context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(1002, SCALE)); assertEquals("Context rank", 1001, context.getRank()); event = fExperiment.getNext(context); @@ -466,7 +466,7 @@ public class TmfExperimentTest { assertEquals("Context rank", 1002, context.getRank()); // Position trace at event rank 4500 (TS = 4501) - context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(4501, SCALE)); assertEquals("Context rank", 4500, context.getRank()); event = fExperiment.getNext(context); @@ -477,7 +477,7 @@ public class TmfExperimentTest { @Test public void testSeekTimestampOutOfScope() { // Position trace at beginning - ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE)); + ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(-1, SCALE)); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fExperiment.getNext(context); @@ -485,7 +485,7 @@ public class TmfExperimentTest { assertEquals("Event rank", 1, context.getRank()); // Position trace at event passed the end - context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE)); event = fExperiment.getNext(context); assertNull("Event location", event); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -607,7 +607,7 @@ public class TmfExperimentTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 1) - final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); validateContextRanks(context); @@ -633,7 +633,7 @@ public class TmfExperimentTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 2) - final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); validateContextRanks(context); @@ -660,7 +660,7 @@ public class TmfExperimentTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 500) - final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); validateContextRanks(context); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java index e0f888e834..40b0414f03 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java @@ -33,8 +33,8 @@ import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperiment import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; -import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType; +import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; @@ -122,7 +122,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("getStartTime", 1, timeRange.getStartTime().getValue()); assertEquals("getEndTime", NB_EVENTS, timeRange.getEndTime().getValue()); - TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp initRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE); assertEquals("getInitialRangeOffset", initRange, fExperiment.getInitialRangeOffset()); } @@ -224,7 +224,7 @@ public class TmfMultiTraceExperimentTest { long cacheSize = fExperiment.getCacheSize(); // Position trace at event rank 0 - ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(1, SCALE)); + ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(1, SCALE)); assertEquals("Context rank", 0, context.getRank()); ITmfEvent event = fExperiment.getNext(context); @@ -232,7 +232,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Context rank", 1, context.getRank()); // Position trace at event rank [cacheSize] - context = fExperiment.seekEvent(new TmfTimestamp(cacheSize + 1, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(cacheSize + 1, SCALE)); assertEquals("Event rank", cacheSize, context.getRank()); event = fExperiment.getNext(context); @@ -240,7 +240,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Context rank", cacheSize + 1, context.getRank()); // Position trace at event rank [4 * cacheSize] - context = fExperiment.seekEvent(new TmfTimestamp(4 * cacheSize + 1, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(4 * cacheSize + 1, SCALE)); assertEquals("Context rank", 4 * cacheSize, context.getRank()); event = fExperiment.getNext(context); @@ -251,7 +251,7 @@ public class TmfMultiTraceExperimentTest { @Test public void testSeekTimestampNotOnCacheBoundary() { // Position trace at event rank 1 (TS = 2) - ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(2, SCALE)); + ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(2, SCALE)); assertEquals("Context rank", 1, context.getRank()); ITmfEvent event = fExperiment.getNext(context); @@ -259,7 +259,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Context rank", 2, context.getRank()); // Position trace at event rank 9 (TS = 10) - context = fExperiment.seekEvent(new TmfTimestamp(10, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(10, SCALE)); assertEquals("Context rank", 9, context.getRank()); event = fExperiment.getNext(context); @@ -267,7 +267,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Context rank", 10, context.getRank()); // Position trace at event rank 999 (TS = 1000) - context = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(1000, SCALE)); assertEquals("Context rank", 999, context.getRank()); event = fExperiment.getNext(context); @@ -275,7 +275,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Context rank", 1000, context.getRank()); // Position trace at event rank 1001 (TS = 1002) - context = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(1002, SCALE)); assertEquals("Context rank", 1001, context.getRank()); event = fExperiment.getNext(context); @@ -283,7 +283,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Context rank", 1002, context.getRank()); // Position trace at event rank 4500 (TS = 4501) - context = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(4501, SCALE)); assertEquals("Context rank", 4500, context.getRank()); event = fExperiment.getNext(context); @@ -294,7 +294,7 @@ public class TmfMultiTraceExperimentTest { @Test public void testSeekTimestampOutOfScope() { // Position trace at beginning - ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(-1, SCALE)); + ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(-1, SCALE)); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fExperiment.getNext(context); @@ -302,7 +302,7 @@ public class TmfMultiTraceExperimentTest { assertEquals("Event rank", 1, context.getRank()); // Position trace at event passed the end - context = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE)); + context = fExperiment.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE)); event = fExperiment.getNext(context); assertNull("Event location", event); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -423,7 +423,7 @@ public class TmfMultiTraceExperimentTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 1) - final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); validateContextRanks(context); @@ -449,7 +449,7 @@ public class TmfMultiTraceExperimentTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 2) - final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); validateContextRanks(context); @@ -475,7 +475,7 @@ public class TmfMultiTraceExperimentTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 500) - final ITmfContext context = fExperiment.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fExperiment.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); validateContextRanks(context); @@ -770,15 +770,15 @@ public class TmfMultiTraceExperimentTest { @Test public void testGetTimestamp() { - assertEquals("getTimestamp", new TmfTimestamp( 1, (byte) -3), fExperiment.getTimestamp( 0)); - assertEquals("getTimestamp", new TmfTimestamp( 2, (byte) -3), fExperiment.getTimestamp( 1)); - assertEquals("getTimestamp", new TmfTimestamp( 11, (byte) -3), fExperiment.getTimestamp( 10)); - assertEquals("getTimestamp", new TmfTimestamp( 101, (byte) -3), fExperiment.getTimestamp( 100)); - assertEquals("getTimestamp", new TmfTimestamp( 1001, (byte) -3), fExperiment.getTimestamp( 1000)); - assertEquals("getTimestamp", new TmfTimestamp( 2001, (byte) -3), fExperiment.getTimestamp( 2000)); - assertEquals("getTimestamp", new TmfTimestamp( 2501, (byte) -3), fExperiment.getTimestamp( 2500)); - assertEquals("getTimestamp", new TmfTimestamp(10000, (byte) -3), fExperiment.getTimestamp( 9999)); - assertEquals("getTimestamp", new TmfTimestamp(20000, (byte) -3), fExperiment.getTimestamp(19999)); + assertEquals("getTimestamp", TmfTimestamp.create( 1, (byte) -3), fExperiment.getTimestamp( 0)); + assertEquals("getTimestamp", TmfTimestamp.create( 2, (byte) -3), fExperiment.getTimestamp( 1)); + assertEquals("getTimestamp", TmfTimestamp.create( 11, (byte) -3), fExperiment.getTimestamp( 10)); + assertEquals("getTimestamp", TmfTimestamp.create( 101, (byte) -3), fExperiment.getTimestamp( 100)); + assertEquals("getTimestamp", TmfTimestamp.create( 1001, (byte) -3), fExperiment.getTimestamp( 1000)); + assertEquals("getTimestamp", TmfTimestamp.create( 2001, (byte) -3), fExperiment.getTimestamp( 2000)); + assertEquals("getTimestamp", TmfTimestamp.create( 2501, (byte) -3), fExperiment.getTimestamp( 2500)); + assertEquals("getTimestamp", TmfTimestamp.create(10000, (byte) -3), fExperiment.getTimestamp( 9999)); + assertEquals("getTimestamp", TmfTimestamp.create(20000, (byte) -3), fExperiment.getTimestamp(19999)); assertNull("getTimestamp", fExperiment.getTimestamp(20000)); } @@ -792,7 +792,7 @@ public class TmfMultiTraceExperimentTest { TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE); // verify initial values - TmfTimestamp initRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp initRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE); assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset()); exp.dispose(); @@ -801,11 +801,11 @@ public class TmfMultiTraceExperimentTest { @Test public void testInitialRangeOffset() { ITmfTrace[] traces = setupTraces(); - ((TmfTraceStub) traces[0]).setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE)); - ((TmfTraceStub) traces[1]).setInitialRangeOffset(new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE)); + ((TmfTraceStub) traces[0]).setInitialRangeOffset(TmfTimestamp.fromMillis(5)); + ((TmfTraceStub) traces[1]).setInitialRangeOffset(TmfTimestamp.fromMillis(2)); TmfExperimentStub exp = new TmfExperimentStub(EXPERIMENT, traces, BLOCK_SIZE); - TmfTimestamp initRange = new TmfTimestamp(2, ITmfTimestamp.MILLISECOND_SCALE); + ITmfTimestamp initRange = TmfTimestamp.fromMillis(2); assertEquals("getInitialRangeOffset", initRange, exp.getInitialRangeOffset()); exp.dispose(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceTest.java index 1b0006aaf8..9480f72f01 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfTraceTest.java @@ -379,7 +379,7 @@ public class TmfTraceTest { assertEquals("getStartTime", 1, trace.getStartTime().getValue()); assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); - trace.setTimeRange(new TmfTimeRange(new TmfTimestamp(100), new TmfTimestamp(200))); + trace.setTimeRange(new TmfTimeRange(TmfTimestamp.fromSeconds(100), TmfTimestamp.fromSeconds(200))); assertEquals("setTimeRange", 100, trace.getTimeRange().getStartTime().getValue()); assertEquals("setTimeRange", 200, trace.getTimeRange().getEndTime().getValue()); assertEquals("setTimeRange", 100, trace.getStartTime().getValue()); @@ -398,7 +398,7 @@ public class TmfTraceTest { assertEquals("getStartTime", 1, trace.getStartTime().getValue()); assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); - trace.setStartTime(new TmfTimestamp(100)); + trace.setStartTime(TmfTimestamp.fromSeconds(100)); assertEquals("setStartTime", 100, trace.getTimeRange().getStartTime().getValue()); assertEquals("setStartTime", NB_EVENTS, trace.getTimeRange().getEndTime().getValue()); assertEquals("setStartTime", 100, trace.getStartTime().getValue()); @@ -417,7 +417,7 @@ public class TmfTraceTest { assertEquals("getStartTime", 1, trace.getStartTime().getValue()); assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue()); - trace.setEndTime(new TmfTimestamp(100)); + trace.setEndTime(TmfTimestamp.fromSeconds(100)); assertEquals("setEndTime", 1, trace.getTimeRange().getStartTime().getValue()); assertEquals("setEndTime", 100, trace.getTimeRange().getEndTime().getValue()); assertEquals("setEndTime", 1, trace.getStartTime().getValue()); @@ -508,7 +508,7 @@ public class TmfTraceTest { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event rank 1000 - ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE)); + ITmfContext tmpContext = fTrace.seekEvent(TmfTimestamp.create(1001, SCALE)); context = fTrace.seekEvent(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -521,7 +521,7 @@ public class TmfTraceTest { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event rank 4000 - tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE)); + tmpContext = fTrace.seekEvent(TmfTimestamp.create(4001, SCALE)); context = fTrace.seekEvent(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -537,7 +537,7 @@ public class TmfTraceTest { @Test public void testSeekEventNotOnCacheBoundary() { // Position trace at event rank 9 - ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE)); + ITmfContext tmpContext = fTrace.seekEvent(TmfTimestamp.create(10, SCALE)); TmfContext context = fTrace.seekEvent(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -550,7 +550,7 @@ public class TmfTraceTest { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event rank 999 - tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE)); + tmpContext = fTrace.seekEvent(TmfTimestamp.create(1000, SCALE)); context = fTrace.seekEvent(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -563,7 +563,7 @@ public class TmfTraceTest { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event rank 1001 - tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE)); + tmpContext = fTrace.seekEvent(TmfTimestamp.create(1002, SCALE)); context = fTrace.seekEvent(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -576,7 +576,7 @@ public class TmfTraceTest { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event rank 4500 - tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE)); + tmpContext = fTrace.seekEvent(TmfTimestamp.create(4501, SCALE)); context = fTrace.seekEvent(tmpContext.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -605,7 +605,7 @@ public class TmfTraceTest { assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); // Position trace at event passed the end - context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE)); assertNull("Event timestamp", context.getLocation()); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); @@ -631,7 +631,7 @@ public class TmfTraceTest { @Test public void testSeekEventOnTimestampOnCacheBoundary() { // Position trace at event rank 0 - ITmfContext context = fTrace.seekEvent(new TmfTimestamp(1, SCALE)); + ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(1, SCALE)); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -643,7 +643,7 @@ public class TmfTraceTest { assertEquals("Event rank", 1, context.getRank()); // Position trace at event rank 1000 - context = fTrace.seekEvent(new TmfTimestamp(1001, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(1001, SCALE)); assertEquals("Event rank", 1000, context.getRank()); event = fTrace.parseEvent(context); @@ -655,7 +655,7 @@ public class TmfTraceTest { assertEquals("Event rank", 1001, context.getRank()); // Position trace at event rank 4000 - context = fTrace.seekEvent(new TmfTimestamp(4001, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(4001, SCALE)); assertEquals("Event rank", 4000, context.getRank()); event = fTrace.parseEvent(context); @@ -670,7 +670,7 @@ public class TmfTraceTest { @Test public void testSeekEventOnTimestampNotOnCacheBoundary() { // Position trace at event rank 1 - ITmfContext context = fTrace.seekEvent(new TmfTimestamp(2, SCALE)); + ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(2, SCALE)); assertEquals("Event rank", 1, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -682,7 +682,7 @@ public class TmfTraceTest { assertEquals("Event rank", 2, context.getRank()); // Position trace at event rank 9 - context = fTrace.seekEvent(new TmfTimestamp(10, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(10, SCALE)); assertEquals("Event rank", 9, context.getRank()); event = fTrace.parseEvent(context); @@ -694,7 +694,7 @@ public class TmfTraceTest { assertEquals("Event rank", 10, context.getRank()); // Position trace at event rank 999 - context = fTrace.seekEvent(new TmfTimestamp(1000, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(1000, SCALE)); assertEquals("Event rank", 999, context.getRank()); event = fTrace.parseEvent(context); @@ -706,7 +706,7 @@ public class TmfTraceTest { assertEquals("Event rank", 1000, context.getRank()); // Position trace at event rank 1001 - context = fTrace.seekEvent(new TmfTimestamp(1002, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(1002, SCALE)); assertEquals("Event rank", 1001, context.getRank()); event = fTrace.parseEvent(context); @@ -718,7 +718,7 @@ public class TmfTraceTest { assertEquals("Event rank", 1002, context.getRank()); // Position trace at event rank 4500 - context = fTrace.seekEvent(new TmfTimestamp(4501, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(4501, SCALE)); assertEquals("Event rank", 4500, context.getRank()); event = fTrace.parseEvent(context); @@ -733,7 +733,7 @@ public class TmfTraceTest { @Test public void testSeekEventOnTimestampOutOfScope() { // Position trace at beginning - ITmfContext context = fTrace.seekEvent(new TmfTimestamp(-1, SCALE)); + ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(-1, SCALE)); assertEquals("Event rank", 0, context.getRank()); ITmfEvent event = fTrace.parseEvent(context); @@ -745,7 +745,7 @@ public class TmfTraceTest { assertEquals("Event rank", 1, context.getRank()); // Position trace at event passed the end - context = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE)); + context = fTrace.seekEvent(TmfTimestamp.create(NB_EVENTS + 1, SCALE)); assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank()); event = fTrace.parseEvent(context); @@ -898,7 +898,7 @@ public class TmfTraceTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 0) - final TmfContext context = (TmfContext) fTrace.seekEvent(new TmfTimestamp(0, SCALE)); + final TmfContext context = (TmfContext) fTrace.seekEvent(TmfTimestamp.create(0, SCALE)); TmfContext svContext = new TmfContext(context); ITmfEvent event = fTrace.parseEvent(context); @@ -944,7 +944,7 @@ public class TmfTraceTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 1) - final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); // Read NB_EVENTS ITmfEvent event; @@ -966,7 +966,7 @@ public class TmfTraceTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 500) - final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); // Read NB_EVENTS ITmfEvent event; @@ -988,7 +988,7 @@ public class TmfTraceTest { final int NB_READS = 20; // On lower bound, returns the first event (ts = 500) - final ITmfContext context = fTrace.seekEvent(new TmfTimestamp(INITIAL_TS, SCALE)); + final ITmfContext context = fTrace.seekEvent(TmfTimestamp.create(INITIAL_TS, SCALE)); // Read NB_EVENTS ITmfEvent event; @@ -1223,7 +1223,7 @@ public class TmfTraceTest { final int nbEvents = 1000; final Vector requestedEvents = new Vector<>(); - final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); + final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) { @Override @@ -1254,7 +1254,7 @@ public class TmfTraceTest { final int nbEvents = 1000; final Vector requestedEvents = new Vector<>(); - final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); + final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(startTime, SCALE), TmfTimestamp.BIG_CRUNCH); final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, startIndex, nbEvents, ExecutionType.FOREGROUND) { @Override @@ -1381,12 +1381,12 @@ public class TmfTraceTest { testfile = new File(FileLocator.toFileURL(location).toURI()); trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null); // verify initial values - TmfTimestamp defaultInitRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp defaultInitRange = TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE); assertEquals("getInitialRangeOffset", defaultInitRange, trace.getInitialRangeOffset()); - trace.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE)); + trace.setInitialRangeOffset(TmfTimestamp.fromMillis(5)); trace.indexTrace(true); - TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE); + ITmfTimestamp initRange = TmfTimestamp.fromMillis(5); assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset()); trace.dispose(); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java index 2fd655eecf..65c2c15f3a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AbstractCheckpointCollectionTest.java @@ -154,7 +154,7 @@ public abstract class AbstractCheckpointCollectionTest { @Test public void testSetGetTimeRange() { if (isPersistableCollection()) { - TmfTimeRange timeRange = new TmfTimeRange(new TmfTimestamp(0), new TmfTimestamp(100)); + TmfTimeRange timeRange = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.fromSeconds(100)); fCheckpointCollection.setTimeRange(timeRange); assertEquals(timeRange, fCheckpointCollection.getTimeRange()); } @@ -187,7 +187,7 @@ public abstract class AbstractCheckpointCollectionTest { assertEquals(0, fCheckpointCollection.size()); int expected = CHECKPOINTS_INSERT_NUM; for (int i = 0; i < expected; ++i) { - fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), i)); + fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), i)); } assertEquals(expected, fCheckpointCollection.size()); } @@ -252,7 +252,7 @@ public abstract class AbstractCheckpointCollectionTest { */ @Test public void testInsert() { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0); fCheckpointCollection.insert(checkpoint); long found = fCheckpointCollection.binarySearch(checkpoint); @@ -267,7 +267,7 @@ public abstract class AbstractCheckpointCollectionTest { */ protected ArrayList insertAlot() { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + i), new TmfLongLocation(123456L + i), i); fCheckpointCollection.insert(checkpoint); } @@ -304,7 +304,7 @@ public abstract class AbstractCheckpointCollectionTest { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { Integer randomCheckpoint = list.get(i); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0); long found = fCheckpointCollection.binarySearch(checkpoint); assertEquals(randomCheckpoint.intValue(), found); } @@ -319,7 +319,7 @@ public abstract class AbstractCheckpointCollectionTest { @Test public void testInsertSameTimestamp() { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L + i), i); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L + i), i); fCheckpointCollection.insert(checkpoint); } assertEquals(CHECKPOINTS_INSERT_NUM, fCheckpointCollection.size()); @@ -346,7 +346,7 @@ public abstract class AbstractCheckpointCollectionTest { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { Integer randomCheckpoint = list.get(i); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L + randomCheckpoint), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L + randomCheckpoint), 0); long found = fCheckpointCollection.binarySearch(checkpoint); assertEquals(randomCheckpoint.intValue(), found); } @@ -359,12 +359,12 @@ public abstract class AbstractCheckpointCollectionTest { @Test public void testBinarySearchFindInBetween() { for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(2 * i), new TmfLongLocation(2 * i), i); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(2 * i), new TmfLongLocation(2 * i), i); fCheckpointCollection.insert(checkpoint); } assertEquals(CHECKPOINTS_INSERT_NUM, fCheckpointCollection.size()); - TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(new TmfTimestamp(123), new TmfLongLocation(123L), 123); + TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(123), new TmfLongLocation(123L), 123); int expectedInsertionPoint = 61; int expectedRank = -(expectedInsertionPoint + 2); @@ -382,17 +382,17 @@ public abstract class AbstractCheckpointCollectionTest { public void testBinarySearchInBetweenSameTimestamp() { int checkpointNum = 0; for (; checkpointNum < CHECKPOINTS_INSERT_NUM / 2; checkpointNum++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(0), new TmfLongLocation(checkpointNum), checkpointNum); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(0), new TmfLongLocation(checkpointNum), checkpointNum); fCheckpointCollection.insert(checkpoint); } for (; checkpointNum < CHECKPOINTS_INSERT_NUM; checkpointNum++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(1), new TmfLongLocation(checkpointNum), checkpointNum); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(1), new TmfLongLocation(checkpointNum), checkpointNum); fCheckpointCollection.insert(checkpoint); } assertEquals(CHECKPOINTS_INSERT_NUM, fCheckpointCollection.size()); - final TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(new TmfTimestamp(1), null, 0); + final TmfCheckpoint searchedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(1), null, 0); long found = fCheckpointCollection.binarySearch(searchedCheckpoint); @@ -411,7 +411,7 @@ public abstract class AbstractCheckpointCollectionTest { return; } - fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0)); + fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0)); assertEquals(1, fCheckpointCollection.size()); @@ -419,11 +419,11 @@ public abstract class AbstractCheckpointCollectionTest { fCheckpointCollection = createCollection(); assertEquals(1, fCheckpointCollection.size()); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0); long found = fCheckpointCollection.binarySearch(checkpoint); assertEquals(0, found); - fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(12345 + 1), new TmfLongLocation(123456L + 1), 1)); + fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + 1), new TmfLongLocation(123456L + 1), 1)); assertEquals(2, fCheckpointCollection.size()); fCheckpointCollection.dispose(); @@ -438,7 +438,7 @@ public abstract class AbstractCheckpointCollectionTest { public void testInsertAfterEmptyReopen() { fCheckpointCollection.dispose(); fCheckpointCollection = createCollection(); - fCheckpointCollection.insert(new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0)); + fCheckpointCollection.insert(new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0)); assertEquals(1, fCheckpointCollection.size()); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AllBench.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AllBench.java index 24aa14253d..a6d30741fa 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AllBench.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/AllBench.java @@ -152,7 +152,7 @@ public class AllBench { long old = System.currentTimeMillis(); bTree = new BTree(BTREE_DEGREE, file, fTrace); for (int i = 0; i < checkpointsNum; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + i), new TmfLongLocation(123456L + i), i); bTree.insert(checkpoint); } @@ -177,7 +177,7 @@ public class AllBench { long old = System.currentTimeMillis(); array = new FlatArray(file, fTrace); for (int i = 0; i < checkpointsNum; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + i), new TmfLongLocation(123456L + i), i); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + i), new TmfLongLocation(123456L + i), i); array.insert(checkpoint); } @@ -205,7 +205,7 @@ public class AllBench { bTree = new BTree(BTREE_DEGREE, file, fTrace); for (int i = 0; i < checkpointsNum; i++) { Integer randomCheckpoint = list.get(i); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0); BTreeCheckpointVisitor treeVisitor = new BTreeCheckpointVisitor(checkpoint); bTree.accept(treeVisitor); assertEquals(randomCheckpoint.intValue(), treeVisitor.getCheckpoint().getCheckpointRank()); @@ -231,7 +231,7 @@ public class AllBench { array = new FlatArray(file, fTrace); for (int i = 0; i < checkpointsNum; i++) { Integer randomCheckpoint = list.get(i); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + randomCheckpoint), new TmfLongLocation(123456L + randomCheckpoint), 0); long found = array.binarySearch(checkpoint); assertEquals(randomCheckpoint.intValue(), found); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/BTreeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/BTreeTest.java index df4d697a0d..02675ced17 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/BTreeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/BTreeTest.java @@ -54,11 +54,11 @@ public class BTreeTest extends AbstractCheckpointCollectionTest { @Test public void testAccept() { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), 0); fBTree.insert(checkpoint); } - final TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(123), new TmfLongLocation(123L), 0); + final TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(123), new TmfLongLocation(123L), 0); class TestVisitor implements IBTreeVisitor { public int fLastCompare = 0; @@ -93,7 +93,7 @@ public class BTreeTest extends AbstractCheckpointCollectionTest { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { Integer checkpointIndex = list.get(i); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + checkpointIndex), new TmfLongLocation(123456L + checkpointIndex), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + checkpointIndex), new TmfLongLocation(123456L + checkpointIndex), 0); BTreeCheckpointVisitor treeVisitor = new BTreeCheckpointVisitor(checkpoint); fBTree.accept(treeVisitor); assertEquals(checkpoint, treeVisitor.getCheckpoint()); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/FlatArrayTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/FlatArrayTest.java index 4774586182..13bec30017 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/FlatArrayTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/FlatArrayTest.java @@ -51,11 +51,11 @@ public class FlatArrayTest extends AbstractCheckpointCollectionTest { @Test public void testBinarySearch() { for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), 0); fFlatArray.insert(checkpoint); } - TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(new TmfTimestamp(122), new TmfLongLocation(122L), 0); + TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(122), new TmfLongLocation(122L), 0); int expectedRank = 122; long rank = fFlatArray.binarySearch(expectedCheckpoint); @@ -77,7 +77,7 @@ public class FlatArrayTest extends AbstractCheckpointCollectionTest { for (int i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { int checkpointIndex = list.get(i); - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345 + checkpointIndex), + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345 + checkpointIndex), new TmfLongLocation(123456L + checkpointIndex), checkpointIndex); ITmfCheckpoint found = fFlatArray.get(checkpointIndex); assertEquals(checkpoint, found); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java index 65c4a26065..6c4ad43db8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/TmfMemoryIndexTest.java @@ -43,7 +43,7 @@ public class TmfMemoryIndexTest extends AbstractCheckpointCollectionTest { @Override @Test public void testInsert() { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(12345), new TmfLongLocation(123456L), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(12345), new TmfLongLocation(123456L), 0); fMemoryIndex.insert(checkpoint); ITmfCheckpoint indexCheckpoint = fMemoryIndex.get(0); @@ -59,11 +59,11 @@ public class TmfMemoryIndexTest extends AbstractCheckpointCollectionTest { @Test public void testBinarySearch() { for (long i = 0; i < CHECKPOINTS_INSERT_NUM; i++) { - TmfCheckpoint checkpoint = new TmfCheckpoint(new TmfTimestamp(i), new TmfLongLocation(i), 0); + TmfCheckpoint checkpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(i), new TmfLongLocation(i), 0); fMemoryIndex.insert(checkpoint); } - TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(new TmfTimestamp(122), new TmfLongLocation(122L), 0); + TmfCheckpoint expectedCheckpoint = new TmfCheckpoint(TmfTimestamp.fromSeconds(122), new TmfLongLocation(122L), 0); int expectedRank = 122; long rank = fMemoryIndex.binarySearch(expectedCheckpoint); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java index a26ca09675..bffb1c6137 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointIndexTest2.java @@ -29,6 +29,7 @@ import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; import org.eclipse.tracecompass.tmf.core.tests.trace.indexer.checkpoint.AbstractIndexTest.ITestIndexer; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; @@ -178,7 +179,7 @@ public class TmfCheckpointIndexTest2 { // Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp) // and not the event at checkpoint boundary - TmfTimestamp seekTs = new TmfTimestamp(101, -3); + ITmfTimestamp seekTs = TmfTimestamp.create(101, -3); ITmfContext ctx = fTrace.seekEvent(seekTs); ITmfEvent event = fTrace.getNext(ctx); @@ -198,7 +199,7 @@ public class TmfCheckpointIndexTest2 { // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created // Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp) // and not the event at checkpoint boundary - seekTs = new TmfTimestamp(102, -3); + seekTs = TmfTimestamp.create(102, -3); ctx = fTrace.seekEvent(seekTs); event = fTrace.getNext(ctx); @@ -206,7 +207,7 @@ public class TmfCheckpointIndexTest2 { assertEquals(0, seekTs.compareTo(event.getTimestamp())); // Verify seek to first checkpoint - seekTs = new TmfTimestamp(1, -3); + seekTs = TmfTimestamp.create(1, -3); ctx = fTrace.seekEvent(seekTs); event = fTrace.getNext(ctx); @@ -214,15 +215,15 @@ public class TmfCheckpointIndexTest2 { assertEquals(0, seekTs.compareTo(event.getTimestamp())); // Verify seek to timestamp before first event - seekTs = new TmfTimestamp(0, -3); + seekTs = TmfTimestamp.create(0, -3); ctx = fTrace.seekEvent(seekTs); event = fTrace.getNext(ctx); assertEquals(1, ctx.getRank()); - assertEquals(0, new TmfTimestamp(1, -3).compareTo(event.getTimestamp())); + assertEquals(0, TmfTimestamp.create(1, -3).compareTo(event.getTimestamp())); // Verify seek to timestamp between first and second checkpoint - seekTs = new TmfTimestamp(50, -3); + seekTs = TmfTimestamp.create(50, -3); ctx = fTrace.seekEvent(seekTs); event = fTrace.getNext(ctx); @@ -230,7 +231,7 @@ public class TmfCheckpointIndexTest2 { assertEquals(0, seekTs.compareTo(event.getTimestamp())); // Verify seek to timestamp after last event in trace - seekTs = new TmfTimestamp(103, -3); + seekTs = TmfTimestamp.create(103, -3); ctx = fTrace.seekEvent(seekTs); event = fTrace.getNext(ctx); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java index f4c128619d..2491a4460b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfCheckpointTest.java @@ -37,7 +37,7 @@ public class TmfCheckpointTest { // Variables // ------------------------------------------------------------------------ - private ITmfTimestamp fTimestamp1 = new TmfTimestamp(); + private ITmfTimestamp fTimestamp1 = TmfTimestamp.fromSeconds(0); private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG; private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH; @@ -209,7 +209,7 @@ public class TmfCheckpointTest { assertFalse("equals", checkpoint1.equals(null)); // Different types - assertFalse("equals", checkpoint1.equals(new TmfTimestamp())); + assertFalse("equals", checkpoint1.equals(TmfTimestamp.fromSeconds(0))); // Null locations/location assertFalse("equals", checkpoint1.equals(checkpoint4)); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java index ad18de40d9..dd3af76943 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/indexer/checkpoint/TmfExperimentCheckpointIndexTest.java @@ -162,7 +162,7 @@ public class TmfExperimentCheckpointIndexTest { int pageSize = experiment.getCacheSize(); // Build the first half of the index - TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3)); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(1, -3), TmfTimestamp.create(NB_EVENTS / 2 - 1, -3)); experiment.getIndexer().buildIndex(0, range, true); // Validate that each checkpoint points to the right event diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java index 855fb12d32..91eae78b0a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java @@ -23,6 +23,7 @@ import java.nio.ByteBuffer; import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentLocation; import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfLocationArray; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; import org.eclipse.tracecompass.tmf.core.trace.location.TmfLocation; @@ -42,7 +43,7 @@ public class TmfLocationTest { // ------------------------------------------------------------------------ private Long aLong = 12345L; - private TmfTimestamp aTimestamp = new TmfTimestamp(); + private ITmfTimestamp aTimestamp = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE); private TmfLocationArray aLocationArray; private TmfLongLocation fLocation1; @@ -234,7 +235,7 @@ public class TmfLocationTest { @Test public void testToString() { - TmfTimestamp ts = new TmfTimestamp(); + ITmfTimestamp ts = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE); TmfLongLocation location1 = new TmfLongLocation(aLong); TmfTimestampLocation location2 = new TmfTimestampLocation(ts); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java index 739b398b75..38207c227a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/text/TextTraceTest.java @@ -128,7 +128,7 @@ public class TextTraceTest { assertEquals("getName", "", trace.getName()); assertEquals("getCacheSize", 100, trace.getCacheSize()); - TmfTimestamp initRange = new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE); + ITmfTimestamp initRange = TmfTimestamp.fromSeconds(60); assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset()); } @@ -177,7 +177,7 @@ public class TextTraceTest { public void testTraceIndexing() { assertEquals("getNbEvents", 6, fTrace.getNbEvents()); - TmfTimestamp initRange = new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE); + ITmfTimestamp initRange = TmfTimestamp.fromSeconds(60); assertEquals("getInitialRangeOffset", initRange, fTrace.getInitialRangeOffset()); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java index 5348c2b01b..f32fb23536 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java @@ -23,6 +23,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.uml2sd.TmfAsyncSequenceDiagramEvent; @@ -38,8 +39,8 @@ public class TmfAsyncSequenceDiagramEventTest { private final String fLabel1 = "label2"; private final String[] fLabels = new String[] { fLabel0, fLabel1 }; - private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); - private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2); + private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2); + private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2); private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels)); private final ITmfEvent fEvent1; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java index 476c6cae83..ee4e423679 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java @@ -23,6 +23,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent; @@ -38,7 +39,7 @@ public class TmfSyncSequenceDiagramEventTest { private final @NonNull String fLabel1 = "label2"; private final String[] fLabels = new String[] { fLabel0, fLabel1 }; - private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); + private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2); private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels)); private final ITmfEvent fEvent1; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/component/TmfSyntheticEventProviderStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/component/TmfSyntheticEventProviderStub.java index aeb5cf695c..332d29e5b7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/component/TmfSyntheticEventProviderStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/component/TmfSyntheticEventProviderStub.java @@ -22,8 +22,8 @@ import org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider; import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; -import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType; +import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.TmfContext; diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfTraceStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfTraceStub.java index a3e4d47e56..f1adf8ed5c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfTraceStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfTraceStub.java @@ -340,7 +340,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfPersistentlyIndexable @Override public ITmfTimestamp createTimestamp(long ts) { - return new TmfTimestamp(getTimestampTransform().transform(ts) / 1000000L, ITmfTimestamp.MILLISECOND_SCALE); + return TmfTimestamp.fromMillis(getTimestampTransform().transform(ts) / 1000000L); } @Override @@ -397,7 +397,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfPersistentlyIndexable @Override public synchronized int getCheckpointSize() { if (fCheckpointSize == -1) { - TmfCheckpoint c = new TmfCheckpoint(new TmfTimestamp(0L), new TmfLongLocation(0L), 0); + TmfCheckpoint c = new TmfCheckpoint(TmfTimestamp.fromSeconds(0L), new TmfLongLocation(0L), 0); ByteBuffer b = ByteBuffer.allocate(ITmfCheckpoint.MAX_SERIALIZE_SIZE); b.clear(); c.serialize(b); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogTrace.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogTrace.java index b5df50009e..58b126aaa1 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogTrace.java @@ -105,7 +105,7 @@ public class SyslogTrace extends TextTrace { timestamp = createTimestamp(ns); } } catch (ParseException e) { - timestamp = new TmfTimestamp(); + timestamp = TmfTimestamp.create(0, ITmfTimestamp.SECOND_SCALE); } TextTraceEventContent content = new TextTraceEventContent(5); @@ -136,7 +136,7 @@ public class SyslogTrace extends TextTrace { @Override public ITmfTimestamp getInitialRangeOffset() { - return new TmfTimestamp(60, ITmfTimestamp.SECOND_SCALE); + return TmfTimestamp.fromSeconds(60); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java index ccb079d1a7..b2bb7a3fbd 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java @@ -52,7 +52,7 @@ import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.TmfContext; import org.eclipse.tracecompass.tmf.core.trace.TmfTrace; @@ -315,7 +315,7 @@ public class TmfXmlTraceStub extends TmfTrace { * original is in second and we need to convert it. We should do that at * the source when it is supported */ - ITmfTimestamp timestamp = new TmfNanoTimestamp(event.getTimestamp().getValue() / SECONDS_TO_NS); + ITmfTimestamp timestamp = TmfTimestamp.fromNanos(event.getTimestamp().getValue() / SECONDS_TO_NS); TmfEvent newEvent = new TmfEvent(this, ITmfContext.UNKNOWN_RANK, timestamp, eventType, eventFields); updateAttributes(savedContext, event); return newEvent; diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java index 474226858a..472ba6fc40 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java @@ -39,7 +39,6 @@ import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider; import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; @@ -240,8 +239,8 @@ public class PartialHistoryBackend implements IStateHistoryBackend { * caused by the event(s) happening exactly at 'checkpointTime', * if any. We must not include those events in the query. */ - new TmfTimestamp(checkpointTime + 1, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(t, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(checkpointTime + 1), + TmfTimestamp.fromNanos(t)); ITmfEventRequest request = new PartialStateSystemRequest(fPartialInput, range); fPartialInput.getTrace().sendRequest(request); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AvgMipmapFeature.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AvgMipmapFeature.java index 6ed717254b..ef04ff4d44 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AvgMipmapFeature.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/mipmap/AvgMipmapFeature.java @@ -18,8 +18,8 @@ import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; -import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type; +import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue; /** * The average mipmap feature. diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfConstantTransform.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfConstantTransform.java index da979b5517..dfa470ddbc 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfConstantTransform.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfConstantTransform.java @@ -16,7 +16,6 @@ import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; /** * Constant transform, just offset your timestamp with another. @@ -56,7 +55,7 @@ public class TmfConstantTransform implements ITmfTimestampTransformInvertible { * The offset of the linear transform */ public TmfConstantTransform(@NonNull ITmfTimestamp offset) { - this(new TmfNanoTimestamp(offset).getValue()); + this(offset.toNanos()); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinear.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinear.java index a67f05feea..5f94d4cf3b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinear.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinear.java @@ -88,7 +88,7 @@ public class TmfTimestampTransformLinear implements ITmfTimestampTransformInvert @Override public ITmfTimestamp transform(ITmfTimestamp timestamp) { BigDecimal newvalue = BigDecimal.valueOf(timestamp.getValue()).multiply(fAlpha, fMc).add(fBeta); - return new TmfTimestamp(timestamp, newvalue.longValue()); + return TmfTimestamp.create(newvalue.longValue(), timestamp.getScale()); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinearFast.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinearFast.java index cfa4b5d066..30531a60f6 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinearFast.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/synchronization/TmfTimestampTransformLinearFast.java @@ -169,7 +169,7 @@ public class TmfTimestampTransformLinearFast implements ITmfTimestampTransformIn @Override public ITmfTimestamp transform(ITmfTimestamp timestamp) { - return new TmfTimestamp(timestamp, transform(timestamp.getValue())); + return TmfTimestamp.create(transform(timestamp.getValue()), timestamp.getScale()); } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/AbstractFileCheckpointCollection.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/AbstractFileCheckpointCollection.java index 1f4878df18..247d0693fa 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/AbstractFileCheckpointCollection.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/AbstractFileCheckpointCollection.java @@ -82,7 +82,7 @@ public abstract class AbstractFileCheckpointCollection implements ICheckpointCol b.clear(); fFileChannel.read(b); b.flip(); - fTimeRange = new TmfTimeRange(new TmfTimestamp(b), new TmfTimestamp(b)); + fTimeRange = new TmfTimeRange(TmfTimestamp.create(b), TmfTimestamp.create(b)); } /** @@ -112,8 +112,8 @@ public abstract class AbstractFileCheckpointCollection implements ICheckpointCol ByteBuffer b = ByteBuffer.allocate(MAX_TIME_RANGE_SERIALIZE_SIZE); b.clear(); - new TmfTimestamp(fTimeRange.getStartTime()).serialize(b); - new TmfTimestamp(fTimeRange.getEndTime()).serialize(b); + TmfTimestamp.serialize(b, fTimeRange.getStartTime()); + TmfTimestamp.serialize(b, fTimeRange.getEndTime()); b.rewind(); fFileChannel.write(b); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/BTreeNode.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/BTreeNode.java index d864586405..6dc910fb7d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/BTreeNode.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/BTreeNode.java @@ -113,7 +113,7 @@ class BTreeNode { for (int i = 0; i < fNumEntries; ++i) { ITmfLocation location = fTree.getTrace().restoreLocation(bb); - ITmfTimestamp timeStamp = new TmfTimestamp(bb); + ITmfTimestamp timeStamp = TmfTimestamp.create(bb); TmfCheckpoint c = new TmfCheckpoint(timeStamp, location, bb); fEntries[i] = c; } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/FlatArray.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/FlatArray.java index 64bfa085bb..ffe3da9ccf 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/FlatArray.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/indexer/FlatArray.java @@ -94,7 +94,7 @@ public class FlatArray extends AbstractFileCheckpointCollection { fByteBuffer.clear(); getRandomAccessFile().read(fByteBuffer.array()); ITmfLocation location = getTrace().restoreLocation(fByteBuffer); - ITmfTimestamp timeStamp = new TmfTimestamp(fByteBuffer); + ITmfTimestamp timeStamp = TmfTimestamp.create(fByteBuffer); checkpoint = new TmfCheckpoint(timeStamp, location, fByteBuffer); } catch (IOException e) { Activator.logError(MessageFormat.format(Messages.FlatArray_IOErrorReading, getFile()), e); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterCompareNode.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterCompareNode.java index 8b6ae8b51d..2d18d80b30 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterCompareNode.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/filter/model/TmfFilterCompareNode.java @@ -19,7 +19,7 @@ import java.util.List; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; /** @@ -212,7 +212,7 @@ public class TmfFilterCompareNode extends TmfFilterAspectNode { return (ITmfTimestamp) value; } try { - return new TmfNanoTimestamp(fTimestampFormat.parseValue(value.toString())); + return TmfTimestamp.fromNanos(fTimestampFormat.parseValue(value.toString())); } catch (ParseException e) { } return null; diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java index 6d55a9664a..14333459bd 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java @@ -26,7 +26,6 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; @@ -220,12 +219,12 @@ public class CustomEvent extends TmfEvent { private void processData() { String timestampString = fData.get(CustomTraceDefinition.TAG_TIMESTAMP); String timestampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY); - TmfTimestamp timestamp = null; + ITmfTimestamp timestamp = null; if (timestampInputFormat != null && timestampString != null) { TmfTimestampFormat timestampFormat = new TmfTimestampFormat(timestampInputFormat); try { long time = timestampFormat.parseValue(timestampString); - timestamp = new TmfNanoTimestamp(getTrace().getTimestampTransform().transform(time)); + timestamp = TmfTimestamp.fromNanos(getTrace().getTimestampTransform().transform(time)); setTimestamp(timestamp); } catch (ParseException e) { setTimestamp(TmfTimestamp.ZERO); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java index 31c411338a..6c1215184a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statistics/TmfEventsStatistics.java @@ -114,8 +114,8 @@ public class TmfEventsStatistics implements ITmfStatistics { @Override public long getEventsInRange(long start, long end) { - ITmfTimestamp startTS = new TmfTimestamp(start, SCALE); - ITmfTimestamp endTS = new TmfTimestamp(end, SCALE); + ITmfTimestamp startTS = TmfTimestamp.create(start, SCALE); + ITmfTimestamp endTS = TmfTimestamp.create(end, SCALE); TmfTimeRange range = new TmfTimeRange(startTS, endTS); StatsTotalRequest request = new StatsTotalRequest(trace, range); @@ -127,8 +127,8 @@ public class TmfEventsStatistics implements ITmfStatistics { @Override public Map getEventTypesInRange(long start, long end) { - ITmfTimestamp startTS = new TmfTimestamp(start, SCALE); - ITmfTimestamp endTS = new TmfTimestamp(end, SCALE); + ITmfTimestamp startTS = TmfTimestamp.create(start, SCALE); + ITmfTimestamp endTS = TmfTimestamp.create(end, SCALE); TmfTimeRange range = new TmfTimeRange(startTS, endTS); StatsPerTypeRequest request = new StatsPerTypeRequest(trace, range); @@ -247,8 +247,8 @@ public class TmfEventsStatistics implements ITmfStatistics { public HistogramQueryRequest(long[] borders, long endTime) { super(trace.getEventType(), new TmfTimeRange( - new TmfTimestamp(borders[0], SCALE), - new TmfTimestamp(endTime, SCALE)), + TmfTimestamp.create(borders[0], SCALE), + TmfTimestamp.create(endTime, SCALE)), 0, ITmfEventRequest.ALL_DATA, ITmfEventRequest.ExecutionType.BACKGROUND); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfNanoTimestamp.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfNanoTimestamp.java index 150ba09e83..49ea7b1970 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfNanoTimestamp.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfNanoTimestamp.java @@ -16,7 +16,9 @@ package org.eclipse.tracecompass.tmf.core.timestamp; /** * A simplified timestamp where scale is nanoseconds and precision is set to 0. */ -public class TmfNanoTimestamp extends TmfTimestamp { +public final class TmfNanoTimestamp extends TmfTimestamp { + + private final long fValue; // ------------------------------------------------------------------------ // Constructors @@ -36,20 +38,18 @@ public class TmfNanoTimestamp extends TmfTimestamp { * the timestamp value */ public TmfNanoTimestamp(final long value) { - super(value, ITmfTimestamp.NANOSECOND_SCALE); + fValue = value; } - /** - * Copy constructor. - * - * If the parameter is not a TmfNanoTimestamp, the timestamp will be scaled - * to nanoseconds, and the precision will be discarded. - * - * @param timestamp - * The timestamp to copy - */ - public TmfNanoTimestamp(final ITmfTimestamp timestamp) { - super(timestamp.toNanos(), ITmfTimestamp.NANOSECOND_SCALE); + @Override + public long getValue() { + return fValue; + } + + + @Override + public int getScale() { + return ITmfTimestamp.NANOSECOND_SCALE; } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfRealTimestamp.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfRealTimestamp.java new file mode 100644 index 0000000000..e0ee9e0627 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfRealTimestamp.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + *******************************************************************************/ + +package org.eclipse.tracecompass.tmf.core.timestamp; + +/** + * A timestamp with a user provided scale and value + * + * @author Matthew Khouzam + * @since 2.0 + */ +public class TmfRealTimestamp extends TmfTimestamp { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + /** + * The timestamp raw value (mantissa) + */ + private final long fValue; + + /** + * The timestamp scale (magnitude) + */ + private final int fScale; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * Full constructor + * + * @param value + * the timestamp value + * @param scale + * the timestamp scale + */ + public TmfRealTimestamp(final long value, final int scale) { + fValue = value; + fScale = scale; + } + + @Override + public long getValue() { + return fValue; + } + + @Override + public int getScale() { + return fScale; + } +} diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfSimpleTimestamp.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfSecondTimestamp.java similarity index 73% rename from tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfSimpleTimestamp.java rename to tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfSecondTimestamp.java index 78cce97c6b..8c5b573bca 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfSimpleTimestamp.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfSecondTimestamp.java @@ -17,8 +17,11 @@ package org.eclipse.tracecompass.tmf.core.timestamp; * A simplified timestamp where scale and precision are set to 0. * * @author Francois Chouinard + * @since 2.0 */ -public class TmfSimpleTimestamp extends TmfTimestamp { +public class TmfSecondTimestamp extends TmfTimestamp { + + private final long fValue; // ------------------------------------------------------------------------ // Constructors @@ -27,30 +30,28 @@ public class TmfSimpleTimestamp extends TmfTimestamp { /** * Default constructor (value = 0) */ - public TmfSimpleTimestamp() { + public TmfSecondTimestamp() { this(0); } /** * Full constructor * - * @param value the timestamp value + * @param value + * the timestamp value */ - public TmfSimpleTimestamp(final long value) { - super(value, 0); + public TmfSecondTimestamp(final long value) { + fValue = value; } - /** - * Copy constructor. - * - * If the parameter is not a TmfSimpleTimestamp, the timestamp will be - * scaled to seconds, and the precision will be discarded. - * - * @param timestamp - * The timestamp to copy - */ - public TmfSimpleTimestamp(final ITmfTimestamp timestamp) { - super(timestamp.normalize(0, ITmfTimestamp.SECOND_SCALE).getValue(), 0); + @Override + public int getScale() { + return ITmfTimestamp.SECOND_SCALE; + } + + @Override + public long getValue() { + return fValue; } // ------------------------------------------------------------------------ @@ -60,14 +61,14 @@ public class TmfSimpleTimestamp extends TmfTimestamp { @Override public ITmfTimestamp normalize(final long offset, final int scale) { if (scale == ITmfTimestamp.SECOND_SCALE) { - return new TmfSimpleTimestamp(saturatedAdd(getValue(), offset)); + return TmfTimestamp.fromSeconds(saturatedAdd(getValue(), offset)); } return super.normalize(offset, scale); } @Override public int compareTo(final ITmfTimestamp ts) { - if (ts instanceof TmfSimpleTimestamp) { + if (ts instanceof TmfSecondTimestamp) { final long delta = getValue() - ts.getValue(); return (delta == 0) ? 0 : (delta > 0) ? 1 : -1; } @@ -76,7 +77,7 @@ public class TmfSimpleTimestamp extends TmfTimestamp { @Override public ITmfTimestamp getDelta(final ITmfTimestamp ts) { - if (ts instanceof TmfSimpleTimestamp) { + if (ts instanceof TmfSecondTimestamp) { return new TmfTimestampDelta(getValue() - ts.getValue()); } return super.getDelta(ts); @@ -99,10 +100,10 @@ public class TmfSimpleTimestamp extends TmfTimestamp { if (other == null) { return false; } - if (!(other instanceof TmfSimpleTimestamp)) { + if (!(other instanceof TmfSecondTimestamp)) { return super.equals(other); } - final TmfSimpleTimestamp ts = (TmfSimpleTimestamp) other; + final TmfSecondTimestamp ts = (TmfSecondTimestamp) other; return compareTo(ts) == 0; } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestamp.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestamp.java index e1102ded77..a12eb9d9d3 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestamp.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestamp.java @@ -21,134 +21,140 @@ import org.eclipse.jdt.annotation.NonNull; /** * A generic timestamp implementation. The timestamp is represented by the tuple - * { value, scale, precision }. By default, timestamps are scaled in seconds. + * { value, scale, precision }. * * @author Francois Chouinard */ -public class TmfTimestamp implements ITmfTimestamp { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - +public abstract class TmfTimestamp implements ITmfTimestamp { /** - * The beginning of time - */ - public static final @NonNull ITmfTimestamp BIG_BANG = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE); - - /** - * The end of time - */ - public static final @NonNull ITmfTimestamp BIG_CRUNCH = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE); - - /** - * Zero - */ - public static final @NonNull ITmfTimestamp ZERO = new TmfTimestamp(0, 0); - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - /** - * The timestamp raw value (mantissa) + * Create a timestamp. + * + * @param value + * the value in nanoseconds + * @return the timestamp + * @since 2.0 */ - private final long fValue; + public static @NonNull ITmfTimestamp fromNanos(long value) { + return new TmfNanoTimestamp(value); + } /** - * The timestamp scale (magnitude) + * Create a timestamp. + * + * @param value + * the value in microseconds + * @return the timestamp + * @since 2.0 */ - private final int fScale; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ + public static @NonNull ITmfTimestamp fromMicros(long value) { + return create(value, ITmfTimestamp.MICROSECOND_SCALE); + } /** - * Default constructor + * Create a timestamp. + * + * @param value + * the value in milliseconds + * @return the timestamp + * @since 2.0 */ - public TmfTimestamp() { - this(0, ITmfTimestamp.SECOND_SCALE); + public static @NonNull ITmfTimestamp fromMillis(long value) { + return create(value, ITmfTimestamp.MILLISECOND_SCALE); } /** - * Simple constructor (scale = 0) + * Create a timestamp. * * @param value - * the timestamp value + * the value in seconds + * @return the timestamp + * @since 2.0 */ - public TmfTimestamp(final long value) { - this(value, ITmfTimestamp.SECOND_SCALE); + public static @NonNull ITmfTimestamp fromSeconds(long value) { + return new TmfSecondTimestamp(value); } /** - * Full constructor + * Create a timestamp. * - * @param value - * the timestamp value - * @param scale - * the timestamp scale + * @param bufferIn + * the byte buffer to read the timestamp from. + * @return the timestamp + * @since 2.0 */ - public TmfTimestamp(final long value, final int scale) { - fValue = value; - fScale = scale; + public static @NonNull ITmfTimestamp create(ByteBuffer bufferIn) { + return create(bufferIn.getLong(), bufferIn.getInt()); } /** - * Copy constructor + * Create a timestamp. * - * @param timestamp - * the timestamp to copy + * @param value + * the value in time, the unit is specified by the scale + * @param scale + * the scale of the timestamp with respect to seconds, so a + * nanosecond would be -9 (10e-9) and a megasecond would be 6 + * (10e6) + * @return the timestamp + * @since 2.0 */ - public TmfTimestamp(final ITmfTimestamp timestamp) { - if (timestamp == null) { - throw new IllegalArgumentException(); + public static @NonNull ITmfTimestamp create(long value, int scale) { + if (scale == ITmfTimestamp.NANOSECOND_SCALE) { + return fromNanos(value); } - fValue = timestamp.getValue(); - fScale = timestamp.getScale(); + if (scale == ITmfTimestamp.SECOND_SCALE) { + return fromSeconds(value); + } + return createOther(value, scale); } /** - * Copies a timestamp but with a new time value + * Write the time stamp to the ByteBuffer so that it can be saved to disk. * - * @param timestamp - * The timestamp to copy - * @param newvalue - * The value the new timestamp will have + * @param bufferOut + * the buffer to write to + * @param ts + * the timestamp to write + * @since 2.0 */ - public TmfTimestamp(ITmfTimestamp timestamp, long newvalue) { - if (timestamp == null) { - throw new IllegalArgumentException(); - } - fValue = newvalue; - fScale = timestamp.getScale(); + public static void serialize(ByteBuffer bufferOut, ITmfTimestamp ts) { + bufferOut.putLong(ts.getValue()); + bufferOut.putInt(ts.getScale()); + } + + private static @NonNull ITmfTimestamp createOther(long value, int scale) { + return new TmfRealTimestamp(value, scale); } // ------------------------------------------------------------------------ - // ITmfTimestamp + // Constants // ------------------------------------------------------------------------ /** - * Construct the timestamp from the ByteBuffer. - * - * @param bufferIn - * the buffer to read from + * The beginning of time */ - public TmfTimestamp(ByteBuffer bufferIn) { - this(bufferIn.getLong(), bufferIn.getInt()); - } + public static final @NonNull ITmfTimestamp BIG_BANG = new TmfRealTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE); - @Override - public long getValue() { - return fValue; - } + /** + * The end of time + */ + public static final @NonNull ITmfTimestamp BIG_CRUNCH = new TmfRealTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE); - @Override - public int getScale() { - return fScale; - } + /** + * Zero + */ + public static final @NonNull ITmfTimestamp ZERO = new TmfRealTimestamp(0, 0); + + // ------------------------------------------------------------------------ + // ITmfTimestamp + // ------------------------------------------------------------------------ - private static final long scalingFactors[] = new long[] { + /** + * Scaling factors to help scale + * + * @since 2.0 + */ + protected static final long SCALING_FACTORS[] = new long[] { 1L, 10L, 100L, @@ -187,20 +193,20 @@ public class TmfTimestamp implements ITmfTimestamp { } if (value == 0) { - return new TmfTimestamp(offset, scale); + return create(offset, scale); } // First, scale the timestamp if (getScale() != scale) { final int scaleDiff = Math.abs(getScale() - scale); - if (scaleDiff >= scalingFactors.length) { + if (scaleDiff >= SCALING_FACTORS.length) { if (getScale() < scale) { value = 0; } else { value = value > 0 ? Long.MAX_VALUE : Long.MIN_VALUE; } } else { - final long scalingFactor = scalingFactors[scaleDiff]; + final long scalingFactor = SCALING_FACTORS[scaleDiff]; if (getScale() < scale) { value /= scalingFactor; } else { @@ -211,14 +217,15 @@ public class TmfTimestamp implements ITmfTimestamp { value = saturatedAdd(value, offset); - return new TmfTimestamp(value, scale); + return create(value, scale); } @Override public ITmfTimestamp getDelta(final ITmfTimestamp ts) { - final ITmfTimestamp nts = ts.normalize(0, fScale); - final long value = fValue - nts.getValue(); - return new TmfTimestampDelta(value, fScale); + final int scale = getScale(); + final ITmfTimestamp nts = ts.normalize(0, scale); + final long value = getValue() - nts.getValue(); + return new TmfTimestampDelta(value, scale); } @Override @@ -236,41 +243,43 @@ public class TmfTimestamp implements ITmfTimestamp { @Override public int compareTo(final ITmfTimestamp ts) { + long value = getValue(); + int scale = getScale(); // Check the corner cases (we can't use equals() because it uses // compareTo()...) if (ts == null) { return 1; } - if (this == ts || (fValue == ts.getValue() && fScale == ts.getScale())) { + if (this == ts || (value == ts.getValue() && scale == ts.getScale())) { return 0; } - if ((fValue == BIG_BANG.getValue() && fScale == BIG_BANG.getScale()) || (ts.getValue() == BIG_CRUNCH.getValue() && ts.getScale() == BIG_CRUNCH.getScale())) { + if ((value == BIG_BANG.getValue() && scale == BIG_BANG.getScale()) || (ts.getValue() == BIG_CRUNCH.getValue() && ts.getScale() == BIG_CRUNCH.getScale())) { return -1; } - if ((fValue == BIG_CRUNCH.getValue() && fScale == BIG_CRUNCH.getScale()) || (ts.getValue() == BIG_BANG.getValue() && ts.getScale() == BIG_BANG.getScale())) { + if ((value == BIG_CRUNCH.getValue() && scale == BIG_CRUNCH.getScale()) || (ts.getValue() == BIG_BANG.getValue() && ts.getScale() == BIG_BANG.getScale())) { return 1; } - final ITmfTimestamp nts = ts.normalize(0, fScale); + final ITmfTimestamp nts = ts.normalize(0, scale); if ((nts.getValue() == 0 && ts.getValue() != 0) || (ts.getValue() != Long.MAX_VALUE && nts.getValue() == Long.MAX_VALUE) || (ts.getValue() != Long.MIN_VALUE && nts.getValue() == Long.MIN_VALUE)) { // Scaling error. We can figure it out nonetheless. // First, look at the sign of the mantissa - final long value = ts.getValue(); - if (fValue == 0 && value == 0) { + final long otherValue = ts.getValue(); + if (value == 0 && otherValue == 0) { return 0; } - if (fValue < 0 && value >= 0) { + if (value < 0 && otherValue >= 0) { return -1; } - if (fValue >= 0 && value < 0) { + if (value >= 0 && otherValue < 0) { return 1; } // Otherwise, just compare the scales - final int scale = ts.getScale(); - return (fScale > scale) ? (fValue >= 0) ? 1 : -1 : (fValue >= 0) ? -1 : 1; + final int otherScale = ts.getScale(); + return (scale > otherScale) ? (otherValue >= 0) ? 1 : -1 : (otherValue >= 0) ? -1 : 1; } - final long delta = fValue - nts.getValue(); + final long delta = value - nts.getValue(); return Long.compare(delta, 0); } @@ -332,8 +341,9 @@ public class TmfTimestamp implements ITmfTimestamp { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + (int) (fValue ^ (fValue >>> 32)); - result = prime * result + fScale; + final long value = getValue(); + result = prime * result + (int) (value ^ (value >>> 32)); + result = prime * result + getScale(); return result; } @@ -366,15 +376,4 @@ public class TmfTimestamp implements ITmfTimestamp { return format.format(0); } } - - /** - * Write the time stamp to the ByteBuffer so that it can be saved to disk. - * - * @param bufferOut - * the buffer to write to - */ - public void serialize(ByteBuffer bufferOut) { - bufferOut.putLong(fValue); - bufferOut.putInt(fScale); - } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampDelta.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampDelta.java index af46693a39..275bf233bb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampDelta.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampDelta.java @@ -14,12 +14,12 @@ package org.eclipse.tracecompass.tmf.core.timestamp; import java.util.TimeZone; /** - * A generic timestamp implementation for delta between timestamps. - * The toString() method takes negative values into consideration. + * A generic timestamp implementation for delta between timestamps. The + * toString() method takes negative values into consideration. * * @author Bernd Hufmann */ -public class TmfTimestampDelta extends TmfTimestamp { +public class TmfTimestampDelta extends TmfRealTimestamp { // ------------------------------------------------------------------------ // Members @@ -32,37 +32,40 @@ public class TmfTimestampDelta extends TmfTimestamp { * Default constructor */ public TmfTimestampDelta() { - super(); + super(0, ITmfTimestamp.SECOND_SCALE); } /** * Simple constructor (scale = precision = 0) * - * @param value the timestamp value + * @param value + * the timestamp value */ public TmfTimestampDelta(long value) { - super(value); + super(value, ITmfTimestamp.SECOND_SCALE); } /** - * Simple constructor (precision = 0) + * Constructor * - * @param value the timestamp value - * @param scale the timestamp scale + * @param value + * the timestamp value + * @param scale + * the timestamp scale */ public TmfTimestampDelta(long value, int scale) { super(value, scale); } - /** * Copy constructor * - * @param timestamp the timestamp to copy + * @param timestamp + * the timestamp to copy */ public TmfTimestampDelta(ITmfTimestamp timestamp) { - super(timestamp); + super(timestamp.getValue(), timestamp.getScale()); } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java index 8bdf031a4d..cb94d02547 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java @@ -51,7 +51,6 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal; import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; @@ -411,7 +410,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT @Override public ITmfTimestamp getInitialRangeOffset() { final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec - return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE); + return TmfTimestamp.fromNanos(DEFAULT_INITIAL_OFFSET_VALUE); } @Override @@ -725,7 +724,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT @Override public @NonNull ITmfTimestamp createTimestamp(long ts) { - return new TmfNanoTimestamp(getTimestampTransform().transform(ts)); + return TmfTimestamp.fromNanos(getTimestampTransform().transform(ts)); } // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java index 137c7b9af7..0d0a2124f2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java @@ -285,7 +285,7 @@ public final class TmfTraceManager { long offset = trace.getInitialRangeOffset().toNanos(); long endTime = startTs.toNanos() + offset; final TmfTimeRange selectionRange = new TmfTimeRange(startTs, startTs); - final TmfTimeRange windowRange = new TmfTimeRange(startTs, new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE)); + final TmfTimeRange windowRange = new TmfTimeRange(startTs, TmfTimestamp.fromNanos(endTime)); final TmfTraceContext startCtx = trace.createTraceContext(selectionRange, windowRange, editorFile, null); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/indexer/checkpoint/TmfCheckpoint.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/indexer/checkpoint/TmfCheckpoint.java index efe3a552d3..0582179595 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/indexer/checkpoint/TmfCheckpoint.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/indexer/checkpoint/TmfCheckpoint.java @@ -197,8 +197,7 @@ public class TmfCheckpoint implements ITmfCheckpoint { fLocation.serialize(bufferOut); // Always serialize as base TmfTimestamp, this should be sufficient for indexing. // If not, we can add API for the test to restore the time stamp, similarly to the location. - TmfTimestamp t = new TmfTimestamp(fTimestamp); - t.serialize(bufferOut); + TmfTimestamp.serialize(bufferOut, fTimestamp); bufferOut.putLong(fCheckpointRank); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/location/TmfTimestampLocation.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/location/TmfTimestampLocation.java index 5ed344cd78..40a1deed1b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/location/TmfTimestampLocation.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/location/TmfTimestampLocation.java @@ -49,7 +49,7 @@ public final class TmfTimestampLocation extends TmfLocation { * the buffer to read from */ public TmfTimestampLocation(ByteBuffer bufferIn) { - super(new TmfTimestamp(bufferIn)); + super(TmfTimestamp.create(bufferIn)); } @Override @@ -59,7 +59,6 @@ public final class TmfTimestampLocation extends TmfLocation { @Override public void serialize(ByteBuffer bufferOut) { - TmfTimestamp t = new TmfTimestamp(getLocationInfo()); - t.serialize(bufferOut); + TmfTimestamp.serialize(bufferOut, getLocationInfo()); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java index d5e053cbea..c60398198f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java @@ -13,9 +13,9 @@ package org.eclipse.tracecompass.tmf.remote.core.tests.shell; import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; -import static org.junit.Assume.assumeTrue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; import java.util.Arrays; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/histogram/HistogramDataModelTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/histogram/HistogramDataModelTest.java index a66f168d74..ad2c036968 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/histogram/HistogramDataModelTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/histogram/HistogramDataModelTest.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; @@ -589,13 +588,13 @@ public class HistogramDataModelTest { countEventsInModel(nbEvents, model); final TmfTimeRange timeRange_0 = new TmfTimeRange( - new TmfTimestamp(5L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(10L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(5L), + TmfTimestamp.fromNanos(10L)); model.countLostEvent(timeRange_0, nbLostEvents_0, false); final TmfTimeRange timeRange_1 = new TmfTimeRange( - new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(27L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(18L), + TmfTimestamp.fromNanos(27L)); model.countLostEvent(timeRange_1, nbLostEvents_1, false); HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1); @@ -625,13 +624,13 @@ public class HistogramDataModelTest { countEventsInModel(nbEvents, model); final TmfTimeRange timeRange_0 = new TmfTimeRange( - new TmfTimestamp(5L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(10L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(5L), + TmfTimestamp.fromNanos(10L)); model.countLostEvent(timeRange_0, nbLostEvents_0, false); final TmfTimeRange timeRange_1 = new TmfTimeRange( - new TmfTimestamp(11L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(11L), + TmfTimestamp.fromNanos(18L)); model.countLostEvent(timeRange_1, nbLostEvents_1, false); HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1); @@ -660,18 +659,18 @@ public class HistogramDataModelTest { countEventsInModel(nbEvents, model); final TmfTimeRange timeRange_0 = new TmfTimeRange( - new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(22L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(18L), + TmfTimestamp.fromNanos(22L)); model.countLostEvent(timeRange_0, nbLostEvents_0, false); final TmfTimeRange timeRange_2 = new TmfTimeRange( - new TmfTimestamp(28L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(29L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(28L), + TmfTimestamp.fromNanos(29L)); model.countLostEvent(timeRange_2, nbLostEvents_2, false); final TmfTimeRange timeRange_1 = new TmfTimeRange( - new TmfTimestamp(11L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(26L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(11L), + TmfTimestamp.fromNanos(26L)); model.countLostEvent(timeRange_1, nbLostEvents_1, false); HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1); @@ -698,8 +697,8 @@ public class HistogramDataModelTest { countEventsInModel(nbEvents, model); final TmfTimeRange timeRange_0 = new TmfTimeRange( - new TmfTimestamp(11L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(26L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(11L), + TmfTimestamp.fromNanos(26L)); model.countLostEvent(timeRange_0, nbLostEvents_0, false); HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1); @@ -727,16 +726,16 @@ public class HistogramDataModelTest { HistogramDataModel model = new HistogramDataModel(nbBuckets); final TmfTimeRange timeRange_0 = new TmfTimeRange( - new TmfTimestamp(5L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(10L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(5L), + TmfTimestamp.fromNanos(10L)); model.countLostEvent(timeRange_0, nbLostEvents_0, false); int firstNonLostEventTime = 6; countEventsInModel(nbEvents, model, 0, firstNonLostEventTime); final TmfTimeRange timeRange_1 = new TmfTimeRange( - new TmfTimestamp(18L, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(27L, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(18L), + TmfTimestamp.fromNanos(27L)); model.countLostEvent(timeRange_1, nbLostEvents_1, false); HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java index 959a07fe68..5c63c538ec 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java @@ -26,15 +26,16 @@ import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.Messages; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData; +import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnDataProvider; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; -import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.junit.Test; @@ -66,9 +67,9 @@ public class TmfBaseColumnDataProviderTest { private final String fLabel2 = "label3"; private final String[] fLabels = new String[] { fLabel0, fLabel1, fLabel2 }; - private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); - private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2); - private final TmfTimestamp fTimestamp3 = new TmfTimestamp(12355, (byte) 2); + private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2); + private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2); + private final ITmfTimestamp fTimestamp3 = TmfTimestamp.create(12355, (byte) 2); private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels)); private final TmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java index 82046b6891..63e280b065 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java @@ -22,9 +22,9 @@ import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData; +import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTree; import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; -import org.eclipse.tracecompass.internal.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.junit.Before; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java index 4328b2c2c5..668fb17f46 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java @@ -34,6 +34,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.junit.Test; @@ -57,9 +58,9 @@ public class TmfBaseStatisticsDataTest { private final String fLabel2 = "label3"; private final String[] fLabels = new String[] { fLabel0, fLabel1, fLabel2 }; - private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); - private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2); - private final TmfTimestamp fTimestamp3 = new TmfTimestamp(12355, (byte) 2); + private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2); + private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2); + private final ITmfTimestamp fTimestamp3 = TmfTimestamp.create(12355, (byte) 2); private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels)); private final TmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java index fa9f73cf9c..737598826a 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java @@ -32,6 +32,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.junit.Test; @@ -54,8 +55,8 @@ public class TmfTreeContentProviderTest { private final String fLabel1 = "label2"; private final String[] fLabels = new String[] { fLabel0, fLabel1 }; - private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); - private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2); + private final ITmfTimestamp fTimestamp1 = TmfTimestamp.create(12345, (byte) 2); + private final ITmfTimestamp fTimestamp2 = TmfTimestamp.create(12350, (byte) 2); private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels)); private final TmfEventType fType2 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/IUml2SdSignalValidator.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/IUml2SdSignalValidator.java index aa427bf3f3..fa93e0f0bb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/IUml2SdSignalValidator.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/IUml2SdSignalValidator.java @@ -11,8 +11,8 @@ *******************************************************************************/ package org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.loader; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; /** * Interface for testing signal handling within TmfUml2SD @@ -83,12 +83,12 @@ public interface IUml2SdSignalValidator { /** * @return the expected current time. */ - TmfTimestamp getCurrentTime(); + ITmfTimestamp getCurrentTime(); /** * Sets the expected current time * @param currentTime Time to set */ - void setCurrentTime(TmfTimestamp currentTime); + void setCurrentTime(ITmfTimestamp currentTime); /** * @return the expected current time range. diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java index 1ae4b6df1d..242933b13d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderSignalTest.java @@ -18,8 +18,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java index 741fa9d1d6..059c1d2074 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderTimeTest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertTrue; import java.util.List; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java index 32fab5fb18..3982ea448b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java @@ -14,12 +14,12 @@ package org.eclipse.tracecompass.tmf.ui.tests.views.uml2sd.loader; import org.eclipse.tracecompass.tmf.core.component.TmfComponent; import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal; -import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfStartSynchSignal; -import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; /** * Class to implement that certain signals are sent as well as are sent with correct content. @@ -39,7 +39,7 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal private boolean fIsRangeError = false; private Object fSource = null; - private TmfTimestamp fCurrentTimestamp = null; + private ITmfTimestamp fCurrentTimestamp = null; private TmfTimeRange fCurrentTimeRange = null; // ------------------------------------------------------------------------ @@ -166,13 +166,13 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal } @Override - public TmfTimestamp getCurrentTime() { + public ITmfTimestamp getCurrentTime() { return fCurrentTimestamp; } @Override - public void setCurrentTime(TmfTimestamp currentTime) { - fCurrentTimestamp = currentTime == null ? null : new TmfTimestamp(currentTime); + public void setCurrentTime(ITmfTimestamp currentTime) { + fCurrentTimestamp = currentTime; } @Override diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestTimestamp.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestTimestamp.java index 04c060d7a1..c9fa64b294 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestTimestamp.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestTimestamp.java @@ -20,10 +20,14 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; * */ public class Uml2SDTestTimestamp extends TmfTimestamp { + // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ + private final long fValue; + private final int fScale; + // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ @@ -33,11 +37,22 @@ public class Uml2SDTestTimestamp extends TmfTimestamp { * @param value time as long value (nanoseconds) */ public Uml2SDTestTimestamp(long value) { - super(value, IUml2SDTestConstants.TIME_SCALE); + fValue = value; + fScale = IUml2SDTestConstants.TIME_SCALE; } // ------------------------------------------------------------------------ // Operations // ------------------------------------------------------------------------ + @Override + public long getValue() { + return fValue; + } + + @Override + public int getScale() { + return fScale; + } + } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/load/TestLoaders.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/load/TestLoaders.java index ddea688608..e1ec9bf7c0 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/load/TestLoaders.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/load/TestLoaders.java @@ -151,7 +151,7 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro // else if (i == 6) // m3.setTime(new TmfTimestamp(i)); // else - m3.setTime(new TmfTimestamp(i + 1)); + m3.setTime(TmfTimestamp.fromSeconds(i + 1)); } for (int i = testFrame.lifeLinesCount() - 1; i > 0; i--) { @@ -189,8 +189,8 @@ public class TestLoaders implements IUml2SDLoader, ISDFindProvider, ISDFilterPro m.setEndLifeline(testFrame.getLifeline(3)); m.setStartOccurrence(2); m.setEndOccurrence(6); - m.setStartTime(new TmfTimestamp(2)); - m.setEndTime(new TmfTimestamp(6)); + m.setStartTime(TmfTimestamp.fromSeconds(2)); + m.setEndTime(TmfTimestamp.fromSeconds(6)); m.setName("*******************Async TEST ****************"); testFrame.addMessage(m); v.setFrame(testFrame); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java index 92c1a62311..3fb0d95630 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java @@ -100,7 +100,7 @@ public class TmfUml2SDTestTrace implements ITmfEventParser { fields[2] = new TmfEventField("signal", signal, null); ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content, fields); - ITmfEvent tmfEvent = new TmfEvent(fEventStream, ITmfContext.UNKNOWN_RANK, new TmfTimestamp(ts, -9), tmfEventType, tmfContent); + ITmfEvent tmfEvent = new TmfEvent(fEventStream, ITmfContext.UNKNOWN_RANK, TmfTimestamp.create(ts, -9), tmfEventType, tmfContent); return tmfEvent; } catch (final EOFException e) { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/markers/LostEventsMarkerEventSourceFactory.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/markers/LostEventsMarkerEventSourceFactory.java index 20c25fb176..d349a2f403 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/markers/LostEventsMarkerEventSourceFactory.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/markers/LostEventsMarkerEventSourceFactory.java @@ -12,8 +12,8 @@ package org.eclipse.tracecompass.internal.tmf.ui.markers; -import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.AbstractTmfTraceAdapterFactory; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEventSource; /** diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java index a9f966710c..61325a1afe 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserInputWizardPage.java @@ -75,10 +75,10 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.tracecompass.internal.tmf.ui.Activator; import org.eclipse.tracecompass.internal.tmf.ui.Messages; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition; +import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputElement; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace; import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition; -import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlInputAttribute; import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType; import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/offset/OffsetDialog.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/offset/OffsetDialog.java index 838dd48ce4..adcdadfe0c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/offset/OffsetDialog.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/dialogs/offset/OffsetDialog.java @@ -56,12 +56,12 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.tracecompass.tmf.core.signal.TmfEventSelectedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; -import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; @@ -80,8 +80,8 @@ import org.eclipse.ui.dialogs.PatternFilter; public class OffsetDialog extends Dialog { private static final int TREE_EDITOR_MIN_WIDTH = 50; - private static final String EDITOR_KEY = "$editor$"; //$NON-NLS-1$ - private static final String WIDTH_KEY = "$width$"; //$NON-NLS-1$ + private static final String EDITOR_KEY = "$editor$"; //$NON-NLS-1$ + private static final String WIDTH_KEY = "$width$"; //$NON-NLS-1$ private static final TmfTimestampFormat TIME_FORMAT = new TmfTimestampFormat("yyyy-MM-dd HH:mm:ss.SSS SSS SSS"); //$NON-NLS-1$ private static final TmfTimestampFormat OFFSET_FORMAT = new TmfTimestampFormat("T.SSS SSS SSS"); //$NON-NLS-1$ @@ -138,7 +138,7 @@ public class OffsetDialog extends Dialog { ITmfTimestamp refTime = map.get(element); long ref = refTime == null ? 0 : refTime.toNanos(); Long newVal = TIME_FORMAT.parseValue(string, ref); - map.put((TmfTraceElement) element, new TmfNanoTimestamp(newVal)); + map.put((TmfTraceElement) element, TmfTimestamp.fromNanos(newVal)); } catch (ParseException e) { /* Ignore and reload previous value */ } @@ -314,11 +314,11 @@ public class OffsetDialog extends Dialog { // Define the TableViewer fViewer = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER, new PatternFilter() { - @Override - protected boolean isLeafMatch(Viewer viewer, Object element) { - return wordMatches(((TmfTraceElement) element).getElementPath()); - } - }, true); + @Override + protected boolean isLeafMatch(Viewer viewer, Object element) { + return wordMatches(((TmfTraceElement) element).getElementPath()); + } + }, true); // Make lines and make header visible final Tree tree = fViewer.getViewer().getTree(); @@ -421,8 +421,8 @@ public class OffsetDialog extends Dialog { ITmfTimestamp targetTime = fTargetTimeMap.get(traceElement); ITmfTimestamp refTime = fRefTimeMap.get(traceElement); if (targetTime != null && refTime != null) { - long offset = new TmfNanoTimestamp(targetTime).getValue() - - new TmfNanoTimestamp(refTime).getValue(); + long offset = targetTime.toNanos() - + refTime.toNanos(); fOffsetMap.put(traceElement, offset); fViewer.getViewer().update(traceElement, null); } @@ -435,8 +435,8 @@ public class OffsetDialog extends Dialog { } /* put temporary values in maps to pack according to time formats */ - fRefTimeMap.put(traces.get(0), new TmfNanoTimestamp()); - fTargetTimeMap.put(traces.get(0), new TmfNanoTimestamp()); + fRefTimeMap.put(traces.get(0), TmfTimestamp.fromNanos(0)); + fTargetTimeMap.put(traces.get(0), TmfTimestamp.fromNanos(0)); fViewer.getViewer().update(traces.get(0), null); for (final TreeColumn treeColumn : tree.getColumns()) { if (treeColumn.getResizable()) { @@ -495,7 +495,7 @@ public class OffsetDialog extends Dialog { fRefTimeColumn.setWidth(0); fRefTimeColumn.setResizable(false); fButtonViewerColumn.getColumn().setWidth(0); - fAdvancedMessageLabel.setText(""); //$NON-NLS-1$ + fAdvancedMessageLabel.setText(""); //$NON-NLS-1$ } private void setAdvancedMode() { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/TmfAlignmentSynchronizer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/TmfAlignmentSynchronizer.java index 6c5a6372e4..7de2ca6bcb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/TmfAlignmentSynchronizer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/TmfAlignmentSynchronizer.java @@ -18,9 +18,9 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; -import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java index b8d4754374..08d0bf567b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/TmfTimeViewer.java @@ -214,8 +214,8 @@ public abstract class TmfTimeViewer extends TmfViewer implements ITmfTimeProvide if (fTrace != null) { setSelectionRange(currentBeginTime, currentEndTime); - final ITmfTimestamp startTimestamp = new TmfTimestamp(getSelectionBeginTime(), ITmfTimestamp.NANOSECOND_SCALE); - final ITmfTimestamp endTimestamp = new TmfTimestamp(getSelectionEndTime(), ITmfTimestamp.NANOSECOND_SCALE); + final ITmfTimestamp startTimestamp = TmfTimestamp.fromNanos(getSelectionBeginTime()); + final ITmfTimestamp endTimestamp = TmfTimestamp.fromNanos(getSelectionEndTime()); TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(this, startTimestamp, endTimestamp); broadcast(signal); @@ -229,8 +229,8 @@ public abstract class TmfTimeViewer extends TmfViewer implements ITmfTimeProvide // Build the new time range; keep the current time TmfTimeRange timeRange = new TmfTimeRange( - new TmfTimestamp(getWindowStartTime(), ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(getWindowEndTime(), ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(getWindowStartTime()), + TmfTimestamp.fromNanos(getWindowEndTime())); // Send the signal TmfWindowRangeUpdatedSignal signal = new TmfWindowRangeUpdatedSignal(this, timeRange); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java index 12299f726d..c62b70d720 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java @@ -152,7 +152,6 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; @@ -233,8 +232,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS private final class ColumnMovedListener extends ControlAdapter { /* - * Make sure that the margin column is always first and keep the - * column order variable up to date. + * Make sure that the margin column is always first and keep the column + * order variable up to date. */ @Override public void controlMoved(ControlEvent e) { @@ -460,13 +459,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS GC gc = event.gc; Color background = item.getBackground(event.index); /* - * Paint the background if it is not the default system color. - * In Windows, if you let the widget draw the background, it - * will not show the item's background color if the item is - * selected or hot. If there are no style ranges and the item - * background is the default system color, we do not want to - * paint it or otherwise we would override the platform theme - * (e.g. alternating colors). + * Paint the background if it is not the default system color. In + * Windows, if you let the widget draw the background, it will not + * show the item's background color if the item is selected or hot. + * If there are no style ranges and the item background is the + * default system color, we do not want to paint it or otherwise we + * would override the platform theme (e.g. alternating colors). */ if (styleRanges != null || !background.equals(item.getParent().getBackground())) { // we will paint the table item's background @@ -479,9 +477,9 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS /* * We will paint the table item's foreground. In Windows, if you - * paint the background but let the widget draw the foreground, - * it will override your background, unless the item is selected - * or hot. + * paint the background but let the widget draw the foreground, it + * will override your background, unless the item is selected or + * hot. */ event.detail &= ~SWT.FOREGROUND; @@ -556,8 +554,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS /* * Bug in Linux. The coordinates of the event have an origin * that excludes the table header but the method toDisplay() - * expects coordinates relative to an origin that includes - * the table header. + * expects coordinates relative to an origin that includes the + * table header. */ int y = event.y; if (IS_LINUX) { @@ -590,8 +588,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS * The events table search/filter/data keys * * @author Patrick Tasse - * @noimplement This interface only contains Event Table specific - * static definitions. + * @noimplement This interface only contains Event Table specific static + * definitions. */ public interface Key { @@ -1559,7 +1557,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS } item.setText(itemStrings); item.setData(tmfEvent); - item.setData(Key.TIMESTAMP, new TmfTimestamp(tmfEvent.getTimestamp())); + item.setData(Key.TIMESTAMP, tmfEvent.getTimestamp()); item.setData(Key.RANK, rank); final Collection markerIds = fBookmarksMap.get(rank); @@ -2614,8 +2612,10 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS /** * Returns true if the column is a visible event column. * - * @param column the column - * @return false if the column is the margin column or hidden, true otherwise + * @param column + * the column + * @return false if the column is the margin column or hidden, true + * otherwise */ private static boolean isVisibleEventColumn(TableColumn column) { if (column.getData(Key.ASPECT) == TmfMarginColumn.MARGIN_ASPECT) { @@ -2963,7 +2963,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS bookmark.setAttribute(IMarker.MESSAGE, message.toString()); bookmark.setAttribute(IMarker.LOCATION, location); bookmark.setAttribute(ITmfMarker.MARKER_RANK, rank.toString()); - bookmark.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(new TmfNanoTimestamp(timestamp).getValue())); + bookmark.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(timestamp.toNanos())); bookmark.setAttribute(ITmfMarker.MARKER_COLOR, dialog.getColorValue().toString()); id[0] = bookmark.getId(); } @@ -3088,10 +3088,10 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS try { String timeString = marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null); long time = Long.parseLong(timeString); - tsBegin = new TmfNanoTimestamp(time); + tsBegin = TmfTimestamp.fromNanos(time); String durationString = marker.getAttribute(ITmfMarker.MARKER_DURATION, (String) null); long duration = Long.parseLong(durationString); - tsEnd = new TmfNanoTimestamp(time + duration); + tsEnd = TmfTimestamp.fromNanos(time + duration); } catch (NumberFormatException e) { /* ignored */ } @@ -3193,8 +3193,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS final TmfEventRequest subRequest = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, 0, 1, ExecutionType.FOREGROUND) { - TmfTimestamp ts = new TmfTimestamp(signal.getBeginTime()); - TmfTimestamp tf = new TmfTimestamp(signal.getEndTime()); + ITmfTimestamp ts = signal.getBeginTime(); + ITmfTimestamp tf = signal.getEndTime(); @Override public void handleSuccess() { @@ -3245,7 +3245,10 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS contextEnd = fTrace.seekEvent(te); rankEnd = contextEnd.getRank(); contextEnd.dispose(); - /* To include all events at the begin time, seek at the next nanosecond and then use the previous rank */ + /* + * To include all events at the begin time, seek at the + * next nanosecond and then use the previous rank + */ tb = timestampBegin.normalize(1, ITmfTimestamp.NANOSECOND_SCALE); if (tb.compareTo(fTrace.getEndTime()) <= 0) { contextBegin = fTrace.seekEvent(tb); @@ -3255,14 +3258,20 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS rankBegin = ITmfContext.UNKNOWN_RANK; } rankBegin = (rankBegin == ITmfContext.UNKNOWN_RANK ? fTrace.getNbEvents() : rankBegin) - 1; - /* If no events in selection range, select only the next event */ + /* + * If no events in selection range, select only the next + * event + */ rankBegin = rankBegin >= rankEnd ? rankBegin : rankEnd; } else { tb = timestampBegin; contextBegin = fTrace.seekEvent(tb); rankBegin = contextBegin.getRank(); contextBegin.dispose(); - /* To include all events at the end time, seek at the next nanosecond and then use the previous rank */ + /* + * To include all events at the end time, seek at the + * next nanosecond and then use the previous rank + */ te = timestampEnd.normalize(1, ITmfTimestamp.NANOSECOND_SCALE); if (te.compareTo(fTrace.getEndTime()) <= 0) { contextEnd = fTrace.seekEvent(te); @@ -3272,7 +3281,10 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS rankEnd = ITmfContext.UNKNOWN_RANK; } rankEnd = (rankEnd == ITmfContext.UNKNOWN_RANK ? fTrace.getNbEvents() : rankEnd) - 1; - /* If no events in selection range, select only the next event */ + /* + * If no events in selection range, select only the next + * event + */ rankEnd = rankEnd >= rankBegin ? rankEnd : rankBegin; } return new Pair<>(Long.valueOf(rankBegin), Long.valueOf(rankEnd)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractTmfTreeViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractTmfTreeViewer.java index 7149790dcf..97fe501b62 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractTmfTreeViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/AbstractTmfTreeViewer.java @@ -38,9 +38,9 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; -import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; +import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.ui.viewers.TmfTimeViewer; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java index 6e7bba9616..d838bf2a69 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfClosestDataPointTooltipProvider.java @@ -20,7 +20,6 @@ import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.widgets.Display; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.swtchart.IAxis; import org.swtchart.ISeries; @@ -58,7 +57,7 @@ public class TmfClosestDataPointTooltipProvider extends TmfBaseProvider implemen * Constructor for a tool tip provider. * * @param tmfChartViewer - * - the parent chart viewer + * - the parent chart viewer */ public TmfClosestDataPointTooltipProvider(ITmfChartTimeProvider tmfChartViewer) { super(tmfChartViewer); @@ -127,8 +126,8 @@ public class TmfClosestDataPointTooltipProvider extends TmfBaseProvider implemen double currentDistance = xs * xs + ys * ys; /* - * Check for smallest distance to mouse position and - * only consider it if the mouse is close the data point. + * Check for smallest distance to mouse position and only + * consider it if the mouse is close the data point. */ if ((currentDistance < smallestDistance) && (currentDistance < (HIGHLIGHT_RADIUS * HIGHLIGHT_RADIUS))) { smallestDistance = currentDistance; @@ -144,15 +143,15 @@ public class TmfClosestDataPointTooltipProvider extends TmfBaseProvider implemen } String tooltip = null; if (param != null) { - tooltip = createToolTipText(param); + tooltip = createToolTipText(param); if (tooltip != null) { fIsHighlight = true; getChart().redraw(); } } /* - * Note that tooltip might be null which will clear the - * previous tooltip string. This is intentional. + * Note that tooltip might be null which will clear the previous + * tooltip string. This is intentional. */ getChart().getPlotArea().setToolTipText(tooltip); } @@ -202,7 +201,7 @@ public class TmfClosestDataPointTooltipProvider extends TmfBaseProvider implemen if ((xS != null) && (yS != null) && (dataIndex < xS.length) && (dataIndex < yS.length)) { StringBuffer buffer = new StringBuffer(); buffer.append("x="); //$NON-NLS-1$ - buffer.append(new TmfTimestamp((long) xS[dataIndex] + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString()); + buffer.append(TmfTimestamp.fromNanos((long) xS[dataIndex] + getChartViewer().getTimeOffset()).toString()); buffer.append('\n'); buffer.append("y="); //$NON-NLS-1$ buffer.append((long) yS[dataIndex]); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java index fb82a4c3a1..ad22dfb491 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/TmfSimpleTooltipProvider.java @@ -13,7 +13,6 @@ package org.eclipse.tracecompass.tmf.ui.viewers.xycharts; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.swtchart.IAxis; @@ -87,7 +86,7 @@ public class TmfSimpleTooltipProvider extends TmfBaseProvider implements MouseTr /* set tooltip of current data point */ StringBuffer buffer = new StringBuffer(); buffer.append("x="); //$NON-NLS-1$ - buffer.append(new TmfTimestamp((long) xCoordinate + viewer.getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString()); + buffer.append(TmfTimestamp.fromNanos((long) xCoordinate + viewer.getTimeOffset()).toString()); buffer.append("\n"); //$NON-NLS-1$ buffer.append("y="); //$NON-NLS-1$ buffer.append((long) yCoordinate); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/barcharts/TmfHistogramTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/barcharts/TmfHistogramTooltipProvider.java index 6e5a51033b..140944127f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/barcharts/TmfHistogramTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/barcharts/TmfHistogramTooltipProvider.java @@ -18,7 +18,6 @@ import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.widgets.Display; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfBaseProvider; @@ -137,9 +136,9 @@ public class TmfHistogramTooltipProvider extends TmfBaseProvider implements Mous /* set tooltip of closest data point */ StringBuffer buffer = new StringBuffer(); buffer.append("Range=["); //$NON-NLS-1$ - buffer.append(new TmfTimestamp((long) rangeStart + viewer.getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString()); + buffer.append(TmfTimestamp.fromNanos((long) rangeStart + viewer.getTimeOffset()).toString()); buffer.append(','); - buffer.append(new TmfTimestamp((long) rangeEnd + viewer.getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString()); + buffer.append(TmfTimestamp.fromNanos((long) rangeEnd + viewer.getTimeOffset()).toString()); buffer.append("]\n"); //$NON-NLS-1$ buffer.append("y="); //$NON-NLS-1$ buffer.append((long) y); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java index e0667942ec..cf9f0bddce 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartTooltipProvider.java @@ -18,7 +18,6 @@ import java.text.ParsePosition; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.ITmfChartTimeProvider; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfBaseProvider; @@ -131,7 +130,7 @@ public class TmfCommonXLineChartTooltipProvider extends TmfBaseProvider implemen } StringBuffer buffer = new StringBuffer(); buffer.append("time="); //$NON-NLS-1$ - buffer.append(new TmfTimestamp((long) xCoordinate + getChartViewer().getTimeOffset(), ITmfTimestamp.NANOSECOND_SCALE).toString()); + buffer.append(TmfTimestamp.fromNanos((long) xCoordinate + getChartViewer().getTimeOffset()).toString()); buffer.append('\n'); /* For each series, get the value at the index */ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java index 3e9bceedc0..fe480fdb3e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java @@ -64,10 +64,9 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampDelta; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; import org.eclipse.tracecompass.tmf.ui.editors.ITmfTraceEditor; @@ -303,10 +302,10 @@ public class CallStackView extends AbstractTimeGraphView { int depth = entry.getStackLevel(); return Integer.toString(depth); } else if (columnIndex == 2 && entry.getFunctionName().length() > 0) { - ITmfTimestamp ts = new TmfTimestamp(entry.getFunctionEntryTime(), ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(entry.getFunctionEntryTime()); return ts.toString(); } else if (columnIndex == 3 && entry.getFunctionName().length() > 0) { - ITmfTimestamp ts = new TmfTimestamp(entry.getFunctionExitTime(), ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(entry.getFunctionExitTime()); return ts.toString(); } else if (columnIndex == 4 && entry.getFunctionName().length() > 0) { ITmfTimestamp ts = new TmfTimestampDelta(entry.getFunctionExitTime() - entry.getFunctionEntryTime(), ITmfTimestamp.NANOSECOND_SCALE); @@ -385,7 +384,7 @@ public class CallStackView extends AbstractTimeGraphView { long spacingTime = (long) ((exitTime - entryTime) * SPACING_RATIO); entryTime -= spacingTime; exitTime += spacingTime; - TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(entryTime), new TmfNanoTimestamp(exitTime)); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(entryTime), TmfTimestamp.fromNanos(exitTime)); broadcast(new TmfWindowRangeUpdatedSignal(CallStackView.this, range)); getTimeGraphViewer().setStartFinishTime(entryTime, exitTime); startZoomThread(entryTime, exitTime); @@ -408,7 +407,7 @@ public class CallStackView extends AbstractTimeGraphView { long spacingTime = (long) ((endTime - startTime) * SPACING_RATIO); startTime -= spacingTime; endTime += spacingTime; - TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(startTime), new TmfNanoTimestamp(endTime)); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime)); broadcast(new TmfWindowRangeUpdatedSignal(CallStackView.this, range)); getTimeGraphViewer().setStartFinishTime(startTime, endTime); startZoomThread(startTime, endTime); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java index 210476b966..a2bd470a93 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java @@ -48,8 +48,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampDelta; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; import org.eclipse.tracecompass.tmf.ui.signal.TmfTimeViewAlignmentSignal; import org.eclipse.tracecompass.tmf.ui.views.ITmfTimeAligned; @@ -1046,8 +1046,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi buffer.append(newLine); } buffer.append(NLS.bind(Messages.Histogram_bucketRangeToolTip, - new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE).toString(), - new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE).toString())); + TmfTimestamp.fromNanos(startTime).toString(), + TmfTimestamp.fromNanos(endTime).toString())); buffer.append(newLine); buffer.append(NLS.bind(Messages.Histogram_eventCountToolTip, nbEvents)); if (!HistogramScaledData.hideLostEvents) { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramCurrentTimeControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramCurrentTimeControl.java index dd65a53637..5f4acf5e3d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramCurrentTimeControl.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramCurrentTimeControl.java @@ -20,7 +20,6 @@ import java.text.ParseException; import org.eclipse.swt.widgets.Composite; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat; @@ -102,7 +101,7 @@ public class HistogramCurrentTimeControl extends HistogramTextControl { @Override public void setValue(long time) { if (time != Long.MIN_VALUE) { - super.setValue(time, new TmfTimestamp(time, ITmfTimestamp.NANOSECOND_SCALE).toString()); + super.setValue(time, TmfTimestamp.fromNanos(time).toString()); } else { super.setValue(time, ""); //$NON-NLS-1$ } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramTimeRangeControl.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramTimeRangeControl.java index 025ea7b370..eda7f2f87d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramTimeRangeControl.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramTimeRangeControl.java @@ -78,7 +78,7 @@ public class HistogramTimeRangeControl extends HistogramTextControl { @Override public void setValue(long time) { if (time != Long.MIN_VALUE) { - ITmfTimestamp ts = new TmfTimestamp(time, ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp ts = TmfTimestamp.fromNanos(time); super.setValue(time, ts.toString(TmfTimestampFormat.getDefaulIntervalFormat())); } else { super.setValue(time, ""); //$NON-NLS-1$ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java index 748e32ec83..a580e02f4a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java @@ -474,8 +474,8 @@ public class HistogramView extends TmfView implements ITmfTimeAligned { */ public TmfTimeRange getTimeRange() { return new TmfTimeRange( - new TmfTimestamp(fWindowStartTime, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(fWindowEndTime, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(fWindowStartTime), + TmfTimestamp.fromNanos(fWindowEndTime)); } /** @@ -539,8 +539,8 @@ public class HistogramView extends TmfView implements ITmfTimeAligned { */ void updateSelectionTime(long beginTime, long endTime) { updateDisplayedSelectionTime(beginTime, endTime); - TmfTimestamp beginTs = new TmfTimestamp(beginTime, ITmfTimestamp.NANOSECOND_SCALE); - TmfTimestamp endTs = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp beginTs = TmfTimestamp.fromNanos(beginTime); + ITmfTimestamp endTs = TmfTimestamp.fromNanos(endTime); TmfSelectionRangeUpdatedSignal signal = new TmfSelectionRangeUpdatedSignal(this, beginTs, endTs); fTimeSyncThrottle.queue(signal); } @@ -578,8 +578,8 @@ public class HistogramView extends TmfView implements ITmfTimeAligned { if (fTrace != null) { // Build the new time range; keep the current time TmfTimeRange timeRange = new TmfTimeRange( - new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(startTime), + TmfTimestamp.fromNanos(endTime)); fTimeSpanControl.setValue(endTime - startTime); updateDisplayedTimeRange(startTime, endTime); @@ -937,8 +937,8 @@ public class HistogramView extends TmfView implements ITmfTimeAligned { if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) { fTimeRangeRequest.cancel(); } - TmfTimestamp startTS = new TmfTimestamp(startTime, ITmfTimestamp.NANOSECOND_SCALE); - TmfTimestamp endTS = new TmfTimestamp(endTime, ITmfTimestamp.NANOSECOND_SCALE); + ITmfTimestamp startTS = TmfTimestamp.fromNanos(startTime); + ITmfTimestamp endTS = TmfTimestamp.fromNanos(endTime); TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS); fTimeRangeHistogram.clear(); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java index 067cfb7aa0..edda1f7f51 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemViewer.java @@ -265,8 +265,8 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { !interval.getStateValue().isNull(); stateEntry = new StateEntry(ss.getAttributeName(quark), quark, ss.getFullAttributePath(quark), interval.getStateValue(), - new TmfTimestamp(interval.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE), + TmfTimestamp.fromNanos(interval.getStartTime()), + TmfTimestamp.fromNanos(interval.getEndTime()), modified); // update children first to know if parent is really needed @@ -283,8 +283,8 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { } } else { stateEntry.update(interval.getStateValue(), - new TmfTimestamp(interval.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE), - new TmfTimestamp(interval.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE)); + TmfTimestamp.fromNanos(interval.getStartTime()), + TmfTimestamp.fromNanos(interval.getEndTime())); // update children recursively updateStateEntries(ss, fullState, stateEntry, quark, timestamp); @@ -365,13 +365,13 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { private final int fQuark; private final String fFullPath; - private @NonNull TmfTimestamp fStart; - private @NonNull TmfTimestamp fEnd; + private @NonNull ITmfTimestamp fStart; + private @NonNull ITmfTimestamp fEnd; private ITmfStateValue fValue; private boolean fModified; private boolean fOutOfRange = false; - public StateEntry(String name, int quark, String fullPath, ITmfStateValue value, @NonNull TmfTimestamp start, @NonNull TmfTimestamp end, boolean modified) { + public StateEntry(String name, int quark, String fullPath, ITmfStateValue value, @NonNull ITmfTimestamp start, @NonNull ITmfTimestamp end, boolean modified) { super(name); fQuark = quark; fFullPath = fullPath; @@ -442,7 +442,7 @@ public class TmfStateSystemViewer extends AbstractTmfTreeViewer { return fModified; } - public void update(ITmfStateValue value, @NonNull TmfTimestamp start, @NonNull TmfTimestamp end) { + public void update(ITmfStateValue value, @NonNull ITmfTimestamp start, @NonNull ITmfTimestamp end) { fModified = false; fOutOfRange = false; if (!start.equals(fStart)) { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java index 98990cf2a9..571c19840f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java @@ -76,8 +76,6 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I /** TimeChartView's ID */ public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$ - private static final int TIMESTAMP_SCALE = -9; - private final int fDisplayWidth; private TimeGraphViewer fViewer; private final List fTimeAnalysisEntries = new ArrayList<>(); @@ -526,8 +524,8 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I fStartTime = event.getStartTime(); fStopTime = event.getEndTime(); itemize(fStartTime, fStopTime); - final ITmfTimestamp startTimestamp = new TmfTimestamp(event.getStartTime(), ITmfTimestamp.NANOSECOND_SCALE); - final ITmfTimestamp endTimestamp = new TmfTimestamp(event.getEndTime(), ITmfTimestamp.NANOSECOND_SCALE); + final ITmfTimestamp startTimestamp = TmfTimestamp.fromNanos(event.getStartTime()); + final ITmfTimestamp endTimestamp = TmfTimestamp.fromNanos(event.getEndTime()); TmfTimeRange range = new TmfTimeRange(startTimestamp, endTimestamp); broadcast(new TmfWindowRangeUpdatedSignal(this, range)); } @@ -547,7 +545,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I @Override public void timeSelected(TimeGraphTimeEvent event) { - broadcast(new TmfSelectionRangeUpdatedSignal(this, new TmfTimestamp(event.getBeginTime(), TIMESTAMP_SCALE), new TmfTimestamp(event.getEndTime(), TIMESTAMP_SCALE))); + broadcast(new TmfSelectionRangeUpdatedSignal(this, TmfTimestamp.fromNanos(event.getBeginTime()), TmfTimestamp.fromNanos(event.getEndTime()))); } @Override @@ -686,7 +684,6 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I final long beginTime = signal.getBeginTime().toNanos(); final long endTime = signal.getEndTime().toNanos(); - Display.getDefault().asyncExec(new Runnable() { @Override public void run() { diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java index d65a9f2641..5baea766ed 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java @@ -87,8 +87,9 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceAdapterManager; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext; @@ -1276,7 +1277,7 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) { final long startTime = event.getStartTime(); final long endTime = event.getEndTime(); - TmfTimeRange range = new TmfTimeRange(new TmfNanoTimestamp(startTime), new TmfNanoTimestamp(endTime)); + TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime)); broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView.this, range)); startZoomThread(startTime, endTime); } @@ -1285,8 +1286,8 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA fTimeGraphWrapper.getTimeGraphViewer().addTimeListener(new ITimeGraphTimeListener() { @Override public void timeSelected(TimeGraphTimeEvent event) { - TmfNanoTimestamp startTime = new TmfNanoTimestamp(event.getBeginTime()); - TmfNanoTimestamp endTime = new TmfNanoTimestamp(event.getEndTime()); + ITmfTimestamp startTime = TmfTimestamp.fromNanos(event.getBeginTime()); + ITmfTimestamp endTime = TmfTimestamp.fromNanos(event.getEndTime()); broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView.this, startTime, endTime)); } }); @@ -1306,12 +1307,12 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA marker.setAttribute(ITmfMarker.MARKER_DURATION, Long.toString(bookmark.getDuration())); marker.setAttribute(IMarker.LOCATION, NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTimeRange, - new TmfNanoTimestamp(bookmark.getTime()), - new TmfNanoTimestamp(bookmark.getTime() + bookmark.getDuration()))); + TmfTimestamp.fromNanos(bookmark.getTime()), + TmfTimestamp.fromNanos(bookmark.getTime() + bookmark.getDuration()))); } else { marker.setAttribute(IMarker.LOCATION, NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTime, - new TmfNanoTimestamp(bookmark.getTime()))); + TmfTimestamp.fromNanos(bookmark.getTime()))); } marker.setAttribute(ITmfMarker.MARKER_COLOR, bookmark.getColor().toString()); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/TimeCompressionBar.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/TimeCompressionBar.java index ba22f90cad..414b27318a 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/TimeCompressionBar.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/TimeCompressionBar.java @@ -93,11 +93,11 @@ public class TimeCompressionBar extends ScrollView implements DisposeListener { /** * The minimum time delta. */ - private ITmfTimestamp fMinTime = new TmfTimestamp(); + private ITmfTimestamp fMinTime = TmfTimestamp.fromSeconds(0); /** * The maximum time delta. */ - private ITmfTimestamp fMaxTime = new TmfTimestamp(); + private ITmfTimestamp fMaxTime = TmfTimestamp.fromSeconds(0); /** * The current zoom value. */ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/AsyncMessage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/AsyncMessage.java index b6f7ef1fe0..0b4431628e 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/AsyncMessage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/AsyncMessage.java @@ -70,11 +70,11 @@ public class AsyncMessage extends BaseMessage implements ITimeRange { /** * The time when the message begin */ - private ITmfTimestamp fEndTime = new TmfTimestamp(); + private ITmfTimestamp fEndTime = TmfTimestamp.fromSeconds(0); /** * The time when the message end */ - private ITmfTimestamp fStartTime = new TmfTimestamp(); + private ITmfTimestamp fStartTime = TmfTimestamp.fromSeconds(0); /** * The associated message. */ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/BasicFrame.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/BasicFrame.java index 930a5f9784..dcb45a6b48 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/BasicFrame.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/BasicFrame.java @@ -46,11 +46,11 @@ public class BasicFrame extends GraphNode { /** * Contains the max elapsed time between two consecutive messages in the whole frame */ - private ITmfTimestamp fMaxTime = new TmfTimestamp(0); + private ITmfTimestamp fMaxTime = TmfTimestamp.fromSeconds(0); /** * Contains the min elapsed time between two consecutive messages in the whole frame */ - private ITmfTimestamp fMinTime = new TmfTimestamp(0); + private ITmfTimestamp fMinTime = TmfTimestamp.fromSeconds(0); /** * Indicate if the min and max elapsed time between two consecutive messages in the whole frame need to be computed */ @@ -99,11 +99,11 @@ public class BasicFrame extends GraphNode { /** * The minimum time between messages of the sequence diagram frame. */ - private ITmfTimestamp fMinSDTime = new TmfTimestamp(); + private ITmfTimestamp fMinSDTime = TmfTimestamp.fromSeconds(0); /** * The maximum time between messages of the sequence diagram frame. */ - private ITmfTimestamp fMaxSDTime = new TmfTimestamp(); + private ITmfTimestamp fMaxSDTime = TmfTimestamp.fromSeconds(0); /** * Flag to indicate that initial minimum has to be computed. */ @@ -526,7 +526,7 @@ public class BasicFrame extends GraphNode { if (fComputeMinMax) { fMinTime = delta; if (fMinTime.compareTo(TmfTimestamp.ZERO) < 0) { - fMinTime = new TmfTimestamp(0, m1.getTime().getScale()); + fMinTime = TmfTimestamp.create(0, m1.getTime().getScale()); } fMaxTime = fMinTime; setComputeMinMax(false); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/SyncMessage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/SyncMessage.java index 503c4acd33..a73f43137a 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/SyncMessage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/core/SyncMessage.java @@ -72,7 +72,7 @@ public class SyncMessage extends BaseMessage implements ITimeRange { /** * The time when the message occurs */ - private ITmfTimestamp fEventTime = new TmfTimestamp(); + private ITmfTimestamp fEventTime = TmfTimestamp.fromSeconds(0); /** * Flag whether the message has time information available or not */ diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java index 1d40532c61..a7b6650e38 100755 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/dialogs/MinMaxDialog.java @@ -152,8 +152,8 @@ public class MinMaxDialog extends Dialog { max = Long.parseLong(fMaxText.getText()); scale = Integer.parseInt(fScaleText.getText()); - fSdWidget.getFrame().setMax(new TmfTimestamp(max, scale)); - fSdWidget.getFrame().setMin(new TmfTimestamp(min, scale)); + fSdWidget.getFrame().setMax(TmfTimestamp.create(max, scale)); + fSdWidget.getFrame().setMin(TmfTimestamp.create(min, scale)); fSdWidget.redraw(); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java index c649edcbfc..c0c9930412 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java @@ -1181,7 +1181,7 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader, try { TmfTimeRange currentRange = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange(); long offset = fTrace == null ? 0 : currentRange.getEndTime().getDelta(currentRange.getStartTime()).toNanos(); - TmfTimestamp initialEndOfWindow = new TmfTimestamp(startTime.getValue() + offset, startTime.getScale()); + ITmfTimestamp initialEndOfWindow = TmfTimestamp.create(startTime.getValue() + offset, startTime.getScale()); return new TmfTimeRange(startTime, initialEndOfWindow); } finally { -- 2.34.1