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
;
19 * Base class for LAMI table aspects.
21 * @author Alexandre Montplaisir
23 public class LamiGenericAspect
extends LamiTableEntryAspect
{
25 private final int fColIndex
;
26 private final boolean fIsContinuous
;
27 private final boolean fIsTimeStamp
;
33 * Name of the aspect (name of the column in the UI)
35 * The units of this column
37 * Index of this column
39 * If the contents of this column are numbers or not
41 * If the contents of this column are numerical timestamp or not
43 public LamiGenericAspect(String aspectName
, @Nullable String units
, int colIndex
, boolean isContinuous
, boolean isTimeStamp
) {
44 super(aspectName
, units
);
46 fIsContinuous
= isContinuous
;
47 fIsTimeStamp
= isTimeStamp
;
51 public boolean isContinuous() {
56 public boolean isTimeStamp() {
61 public @Nullable String
resolveString(@NonNull LamiTableEntry entry
) {
62 return entry
.getValue(fColIndex
).toString();
66 public @Nullable Double
resolveDouble(@NonNull LamiTableEntry entry
) {
69 if (entry
.getValue(fColIndex
).toString() != null) {
70 return Double
.parseDouble(entry
.getValue(fColIndex
).toString());
72 } catch (NumberFormatException e
) {
73 // Fallback to default value below
80 public Comparator
<LamiTableEntry
> getComparator() {
83 Double dO1
= resolveDouble(o1
);
84 Double dO2
= resolveDouble(o2
);
85 if (dO1
== null || dO2
== null) {
89 return dO1
.compareTo(dO2
);
93 /* Use regular string comparison */
95 String s1
= resolveString(o1
);
96 String s2
= resolveString(o2
);
98 if (s1
== null || s2
== null) {
102 return s1
.compareTo(s2
);
This page took 0.03389 seconds and 5 git commands to generate.