Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfTraceEvent.java
index c755c0d9b57c4ba7a9b68e2d3926bbd917a2b112..25c05d1bd19783053986f12b0224080d63e67ed2 100644 (file)
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * 
  * Contributors:
- *   Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.event;
@@ -21,43 +21,74 @@ package org.eclipse.linuxtools.tmf.event;
  * <p>
  * TODO: Concept is still a bit vague and should be aligned with the CDT
  * source lookup service.
+ * TODO: Consider composition instead of extension
  */
 public class TmfTraceEvent extends TmfEvent {
 
-    // ========================================================================
+    // ------------------------------------------------------------------------
     // Attributes
-    // ========================================================================
+    // ------------------------------------------------------------------------
 
     private final String fSourcePath;
     private final String fFileName;
-    private final int fLineNumber;
+    private final int    fLineNumber;
 
-    // ========================================================================
+    // ------------------------------------------------------------------------
     // Constructors
-    // ========================================================================
+    // ------------------------------------------------------------------------
+
+       /**
+        * @param originalTS
+        * @param effectiveTS
+        * @param source
+        * @param type
+        * @param content
+        * @param reference
+        * @param path
+        * @param file
+        * @param line
+        */
+       public TmfTraceEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
+                       TmfEventType type, TmfEventReference reference, String path, String file, int line)
+       {
+               super(originalTS, effectiveTS, source, type, reference);
+               fSourcePath = path;
+               fFileName   = file;
+               fLineNumber = line;
+       }
 
        /**
-        * The constructor.
-        * 
         * @param timestamp
         * @param source
         * @param type
         * @param content
         * @param reference
+        * @param path
+        * @param file
+        * @param line
         */
        public TmfTraceEvent(TmfTimestamp timestamp, TmfEventSource source, TmfEventType type,
-                       TmfEventContent content, TmfEventReference reference,
-                       String path, String file, int line)
+                       TmfEventReference reference, String path, String file, int line)
        {
-               super(timestamp, source, type,content, reference);
+               super(timestamp, source, type, reference);
                fSourcePath = path;
-               fFileName = file;
+               fFileName   = file;
                fLineNumber = line;
        }
 
-    // ========================================================================
+       /**
+        * @param other
+        */
+       public TmfTraceEvent(TmfTraceEvent other) {
+               super(other);
+               fSourcePath = other.fSourcePath;
+               fFileName   = other.fFileName;
+               fLineNumber = other.fLineNumber;
+       }
+
+    // ------------------------------------------------------------------------
     // Accessors
-    // ========================================================================
+    // ------------------------------------------------------------------------
 
     /**
      * @return
@@ -80,4 +111,38 @@ public class TmfTraceEvent extends TmfEvent {
         return fLineNumber;
     }
 
+    // ------------------------------------------------------------------------
+    // Object
+    // ------------------------------------------------------------------------
+
+    @Override
+    public int hashCode() {
+               int result = super.hashCode();
+               result = 37 * result + ((fSourcePath != null) ? fSourcePath.hashCode() : 0);
+               result = 37 * result + ((fFileName   != null) ? fFileName.hashCode()   : 0);
+               result = 37 * result + fLineNumber;
+        return result;
+    }
+
+    @Override
+       public boolean equals(Object other) {
+       if (other instanceof TmfEvent) {
+               return super.equals(other); 
+       }
+       if (!(other instanceof TmfTraceEvent)) {
+               return false; 
+       }
+               TmfTraceEvent o = (TmfTraceEvent) other;
+        return super.equals((TmfEvent) o) && fSourcePath.equals(o.fSourcePath) &&
+                       fFileName.equals(o.fFileName) && fLineNumber == o.fLineNumber;
+
+    }
+
+    // TODO: Proper format
+    @Override
+    @SuppressWarnings("nls")
+    public String toString() {
+               return "[TmfTraceEvent(" + fSourcePath + "," + fFileName + "," + fLineNumber + ")]";
+    }
+
 }
This page took 0.024804 seconds and 5 git commands to generate.