1 /*******************************************************************************
2 * Copyright (c) 2015, 2016 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.aspect
;
12 import java
.util
.Comparator
;
14 import org
.eclipse
.jdt
.annotation
.NonNull
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.module
.LamiTableEntry
;
17 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.types
.LamiData
;
18 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.types
.LamiTimeRange
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestampFormat
;
22 * Aspect for beginning timestamp of a timerange
24 * @author Alexandre Montplaisir
26 public class LamiTimeRangeBeginAspect
extends LamiTableEntryAspect
{
28 private final int fColIndex
;
33 * @param timeRangeName
34 * Name of the time range
38 public LamiTimeRangeBeginAspect(String timeRangeName
, int colIndex
) {
39 super(timeRangeName
+ " (" + Messages
.LamiAspect_TimeRangeBegin
+ ')', null); //$NON-NLS-1$
44 public boolean isContinuous() {
49 public boolean isTimeStamp() {
54 public @Nullable String
resolveString(LamiTableEntry entry
) {
55 LamiData data
= entry
.getValue(fColIndex
);
56 if (data
instanceof LamiTimeRange
) {
57 LamiTimeRange range
= (LamiTimeRange
) data
;
58 return TmfTimestampFormat
.getDefaulTimeFormat().format(range
.getStart());
60 /* Could be null, unknown, etc. */
61 return data
.toString();
67 public @Nullable Number
resolveNumber(@NonNull LamiTableEntry entry
) {
68 LamiData data
= entry
.getValue(fColIndex
);
69 if (data
instanceof LamiTimeRange
) {
70 LamiTimeRange range
= (LamiTimeRange
) data
;
71 return range
.getStart();
77 public Comparator
<LamiTableEntry
> getComparator() {
79 Number d1
= resolveNumber(o1
);
80 Number d2
= resolveNumber(o2
);
82 if (d1
== null && d2
== null) {
93 return Long
.compare(d1
.longValue(), d2
.longValue());