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
;
21 * Aspect for a time range duration
23 * @author Alexandre Montplaisir
25 public class LamiTimeRangeDurationAspect
extends LamiTableEntryAspect
{
27 private final int fColIndex
;
32 * @param timeRangeName
33 * Name of the time range
37 public LamiTimeRangeDurationAspect(String timeRangeName
, int colIndex
) {
38 super(timeRangeName
+ " (" + Messages
.LamiAspect_TimeRangeDuration
+ ')', "ns"); //$NON-NLS-1$ //$NON-NLS-2$
43 public boolean isContinuous() {
48 public boolean isTimeStamp() {
53 public boolean isTimeDuration() {
58 public @Nullable String
resolveString(LamiTableEntry entry
) {
59 LamiData data
= entry
.getValue(fColIndex
);
60 if (data
instanceof LamiTimeRange
) {
61 LamiTimeRange range
= (LamiTimeRange
) data
;
62 return String
.valueOf(range
.getDuration());
64 return data
.toString();
68 public @Nullable Number
resolveNumber(@NonNull LamiTableEntry entry
) {
69 LamiData data
= entry
.getValue(fColIndex
);
70 if (data
instanceof LamiTimeRange
) {
71 LamiTimeRange range
= (LamiTimeRange
) data
;
72 return Long
.valueOf(range
.getDuration());
78 public Comparator
<LamiTableEntry
> getComparator() {
80 Number d1
= resolveNumber(o1
);
81 Number d2
= resolveNumber(o2
);
83 if (d1
== null && d2
== null) {
94 return Long
.compare(d1
.longValue(), d2
.longValue());