Fix ranks in CtfTmfTrace as part of bug #389051
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfIterator.java
index aa259ae7c06eaff98ae0a1e803ebf6f0bcf3b653..2c2efbc1ea52fc37b5f23ff5ccb049b44e9ec885 100644 (file)
@@ -20,8 +20,7 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
  * it does not have a file handle, so many iterators can be used without worries
  * of io errors.
  */
-public class CtfIterator extends CTFTraceReader implements ITmfContext,
-        Comparable<CtfIterator> {
+public class CtfIterator extends CTFTraceReader implements ITmfContext, Comparable<CtfIterator>, Cloneable {
 
     private final CtfTmfTrace ctfTmfTrace;
 
@@ -110,7 +109,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
     public boolean seek(final long timestamp) {
         boolean ret = false;
         final long offsetTimestamp = timestamp
-                - this.getCtfTmfTrace().getCTFTrace().getOffset();
+                - this.getTrace().getOffset();
         if (offsetTimestamp < 0) {
             ret = super.seek(timestamp);
         } else {
@@ -125,23 +124,6 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
         return ret;
     }
 
-    /**
-     * Method seekRank. seeks to a given rank
-     * @param rank long the rank to seek to
-     * @return boolean
-     */
-    public boolean seekRank(final long rank) {
-        boolean ret = false;
-        ret = super.seekIndex(rank);
-
-        if (ret) {
-            curLocation.setLocation(getCurrentEvent().getTimestampValue());
-        } else {
-            curLocation = NULL_LOCATION;
-        }
-        return ret;
-    }
-
     /**
      * Method getRank.
      * @return long
@@ -213,7 +195,10 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
      */
     @Override
     public void increaseRank() {
-        curRank++;
+        /* Only increase the rank if it's valid */
+        if(hasValidRank()) {
+            curRank++;
+        }
     }
 
     /**
This page took 0.024421 seconds and 5 git commands to generate.