+ tb = timestampBegin;
+ contextBegin = fTrace.seekEvent(tb);
+ rankBegin = contextBegin.getRank();
+ contextBegin.dispose();
+ if (monitor.isCanceled()) {
+ return null;
+ }
+ /*
+ * To include all events at the end time, seek at the
+ * next nanosecond and then use the previous rank
+ */
+ te = timestampEnd.normalize(1, ITmfTimestamp.NANOSECOND_SCALE);
+ if (te.compareTo(fTrace.getEndTime()) <= 0) {
+ contextEnd = fTrace.seekEvent(te);
+ rankEnd = contextEnd.getRank();
+ contextEnd.dispose();
+ } else {
+ rankEnd = ITmfContext.UNKNOWN_RANK;
+ }
+ rankEnd = (rankEnd == ITmfContext.UNKNOWN_RANK ? fTrace.getNbEvents() : rankEnd) - 1;
+ /*
+ * If no events in selection range, select only the next
+ * event
+ */
+ rankEnd = rankEnd >= rankBegin ? rankEnd : rankBegin;