use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp in project tracecompass by tracecompass.
the class LamiTimestampAspect method resolveString.
@Override
@Nullable
public String resolveString(LamiTableEntry entry) {
LamiData data = entry.getValue(getColIndex());
if (data instanceof LamiTimestamp) {
LamiTimestamp ts = (LamiTimestamp) data;
// TODO: Consider low and high limits here.
Number timestamp = ts.getValue();
if (timestamp != null) {
return TmfTimestampFormat.getDefaulTimeFormat().format(timestamp.longValue());
}
}
return data.toString();
}
use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp in project tracecompass by tracecompass.
the class LamiTableEntry method getCorrespondingTimeRange.
/**
* Get the time range represented by this row.
*
* If more than one exists, one of them (usually the first) is returned.
*
* If there are no time ranges in this row, null is returned.
*
* @return The time range of this row
*/
@Nullable
public LamiTimeRange getCorrespondingTimeRange() {
/*
* If there is one or more time range(s) in the values, return the first
* one we find directly.
*/
Optional<LamiTimeRange> oTimerange = fValues.stream().filter(LamiTimeRange.class::isInstance).map(LamiTimeRange.class::cast).findFirst();
if (oTimerange.isPresent()) {
return oTimerange.get();
}
/* Look for individual timestamps instead */
List<LamiTimestamp> timestamps = fValues.stream().filter(LamiTimestamp.class::isInstance).map(LamiTimestamp.class::cast).collect(Collectors.toList());
if (timestamps.size() > 1) {
/* We can try using the first two timestamps to create a range (making sure it's valid) */
LamiTimestamp firstTs = timestamps.get(0);
LamiTimestamp secondTs = timestamps.get(1);
Number firstTsValue = firstTs.getValue();
Number secondTsValue = secondTs.getValue();
// TODO: Consider low and high limits in comparisons.
if (firstTsValue != null && secondTsValue != null && Long.compare(firstTsValue.longValue(), secondTsValue.longValue()) <= 0) {
return new LamiTimeRange(firstTs, secondTs);
}
}
if (!timestamps.isEmpty()) {
/* If there is only one timestamp, use it to create a punctual range */
LamiTimestamp ts = timestamps.get(0);
return new LamiTimeRange(ts, ts);
}
/* Didn't find any timestamp we can't use */
return null;
}
Aggregations