Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / trace / TmfCheckpoint.java
index 264d637193b4c94bf1956f16bff4e08367e39a2c..7cea1cba9f355e044bb20e17c7d79173c6aa4e99 100644 (file)
@@ -17,53 +17,114 @@ import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 /**
  * <b><u>TmfCheckpoint</u></b>
  * <p>
- * This class maps an event timestamp with a location.
+ * This class maps an event timestamp to a generic location.
  */
-public class TmfCheckpoint implements Comparable<TmfCheckpoint> {
+@SuppressWarnings("rawtypes")
+public class TmfCheckpoint implements Comparable<TmfCheckpoint>, Cloneable {
 
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
     
-    private final TmfTimestamp fTimestamp;
-    private final ITmfLocation fLocation;
+    private TmfTimestamp fTimestamp;
+       private ITmfLocation<? extends Comparable> fLocation;
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
+    @SuppressWarnings("unused")
+       private TmfCheckpoint() {
+        fTimestamp = null;
+        fLocation  = null;
+    }
+
     /**
-     * @param ts
-     * @param location
+     * @param ts the checkpoint timestamp
+     * @param location the corresponding trace location
      */
-    public TmfCheckpoint(TmfTimestamp ts, ITmfLocation location) {
+    public TmfCheckpoint(TmfTimestamp ts, ITmfLocation<? extends Comparable> location) {
         fTimestamp = ts;
         fLocation = location;
     }
 
+    /**
+     * Deep copy constructor
+     * @param other the other checkpoint
+     */
+    public TmfCheckpoint(TmfCheckpoint other) {
+       if (other == null)
+               throw new IllegalArgumentException();
+        fTimestamp = (TmfTimestamp) other.fTimestamp.clone();
+        fLocation  = other.fLocation.clone();
+    }
+
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
 
     /**
-     * @return the checkpoint event timestamp
+     * @return the checkpoint timestamp
      */
     public TmfTimestamp getTimestamp() {
         return fTimestamp;
     }
 
     /**
-     * @return the checkpoint event stream location
+     * @return the checkpoint stream location
      */
-    public ITmfLocation getLocation() {
+    public ITmfLocation<?> getLocation() {
         return fLocation;
     }
 
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
+
+    @Override
+    public TmfCheckpoint clone() {
+       TmfCheckpoint result = null;
+               try {
+                       result = (TmfCheckpoint) super.clone();
+               result.fTimestamp = new TmfTimestamp(fTimestamp);
+               result.fLocation  = fLocation.clone();
+               return result;
+               } catch (CloneNotSupportedException e) {
+                       e.printStackTrace();
+               }
+               return result;
+    }
+    @Override
+    public int hashCode() {
+       return fTimestamp.hashCode();
+    }
+    @Override
+    public boolean equals(Object other) {
+       if (!(other instanceof TmfCheckpoint)) {
+               return false;
+       }
+       TmfCheckpoint o = (TmfCheckpoint) other;
+       return fTimestamp.equals(o.fTimestamp);
+    }
+    @Override
+    @SuppressWarnings("nls")
+    public String toString() {
+       return "[TmfCheckpoint(" + fTimestamp +  "," + fLocation + ")]";
+    }
     // ------------------------------------------------------------------------
     // Comparable
     // ------------------------------------------------------------------------
 
-    public int compareTo(TmfCheckpoint other) {
+       @SuppressWarnings("unchecked")
+       @Override
+       public int compareTo(TmfCheckpoint other) {
+       if (fTimestamp == null || other.fTimestamp == null) {
+               return fLocation.getLocation().compareTo(other.fLocation.getLocation());
+       }
         return fTimestamp.compareTo(other.fTimestamp, false);
     }
 
This page took 0.026179 seconds and 5 git commands to generate.