blob: 27c5724dddb6f072b77d194f311d0e3981aaf7a9 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2015, 2016 EfficiOS Inc., Alexandre Montplaisir
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect;
import java.util.Comparator;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
/**
* Aspect for a time range duration
*
* @author Alexandre Montplaisir
*/
public class LamiTimeRangeEndAspect extends LamiGenericAspect {
/**
* Constructor
*
* @param timeRangeName
* Name of the time range
* @param colIndex
* Column index
*/
public LamiTimeRangeEndAspect(String timeRangeName, int colIndex) {
super(timeRangeName + " (" + Messages.LamiAspect_TimeRangeEnd + ')', null, colIndex, true, true); //$NON-NLS-1$
}
@Override
public @Nullable String resolveString(LamiTableEntry entry) {
LamiData data = entry.getValue(getColIndex());
if (data instanceof LamiTimeRange) {
LamiTimeRange range = (LamiTimeRange) data;
LamiTimestamp ts = range.getEnd();
// TODO: Consider low and high limits here.
Number timestamp = ts.getValue();
if (timestamp != null) {
return TmfTimestampFormat.getDefaulTimeFormat().format(timestamp.longValue());
}
}
return data.toString();
}
@Override
public @Nullable Number resolveNumber(@NonNull LamiTableEntry entry) {
LamiData data = entry.getValue(getColIndex());
if (data instanceof LamiTimeRange) {
LamiTimeRange range = (LamiTimeRange) data;
LamiTimestamp ts = range.getEnd();
// TODO: Consider low and high limits here.
return ts.getValue();
}
return null;
}
@Override
public Comparator<LamiTableEntry> getComparator() {
return LamiComparators.getLongComparator(this::resolveNumber);
}
}