analysis.lami: correctly handle Number (double, long etc.) type graphing
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.lami.core / src / org / eclipse / tracecompass / internal / provisional / analysis / lami / core / aspect / LamiIRQTypeAspect.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Philippe Proulx
3 *
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 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect;
11
12 import java.util.Comparator;
13
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry;
16 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData;
17 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiIRQ;
18
19 /**
20 * Aspect for IRQ type, indicating if it is a hardware IRQ or software IRQ.
21 *
22 * @author Philippe Proulx
23 */
24 public class LamiIRQTypeAspect extends LamiTableEntryAspect {
25
26 private final int fColIndex;
27
28 /**
29 * Constructor
30 *
31 * @param colName
32 * Column name
33 * @param colIndex
34 * Column index
35 */
36 public LamiIRQTypeAspect(String colName, int colIndex) {
37 super(colName + " (" + Messages.LamiAspect_Type +')', null); //$NON-NLS-1$
38 fColIndex = colIndex;
39 }
40
41 @Override
42 public boolean isContinuous() {
43 return false;
44 }
45
46 @Override
47 public boolean isTimeStamp() {
48 return false;
49 }
50
51 @Override
52 public @Nullable String resolveString(LamiTableEntry entry) {
53 LamiData data = entry.getValue(fColIndex);
54 if (data instanceof LamiIRQ) {
55 LamiIRQ irq = (LamiIRQ) data;
56
57 switch (irq.getType()) {
58 case HARD:
59 return Messages.LamiIRQTypeAspect_HardwareIRQ;
60
61 case SOFT:
62 return Messages.LamiIRQTypeAspect_SoftIRQ;
63
64 default:
65 return "?"; //$NON-NLS-1$
66 }
67 }
68 /* Could be null, unknown, etc. */
69 return data.toString();
70 }
71
72 @Override
73 public @Nullable Number resolveNumber(LamiTableEntry entry) {
74 return null;
75 }
76
77 @Override
78 public Comparator<LamiTableEntry> getComparator() {
79 return (o1, o2) -> {
80 String s1 = resolveString(o1);
81 String s2 = resolveString(o2);
82
83 if (s1 == null && s2 == null) {
84 return 0;
85 }
86 if (s1 == null) {
87 return 1;
88 }
89
90 if (s2 == null) {
91 return -1;
92 }
93
94 return s1.compareTo(s2);
95 };
96 }
97
98 }
This page took 0.033242 seconds and 5 git commands to generate.