1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.event
;
16 * <b><u>TmfTraceEvent</u></b>
18 * A trace event associates a source code line to an event. The intent is to
19 * provide the capability to open an editor at the line of code that produced
22 * TODO: Concept is still a bit vague and should be aligned with the CDT
23 * source lookup service.
24 * TODO: Consider composition instead of extension
26 public class TmfTraceEvent
extends TmfEvent
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 private final String fSourcePath
;
33 private final String fFileName
;
34 private final int fLineNumber
;
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
51 public TmfTraceEvent(TmfTimestamp originalTS
, TmfTimestamp effectiveTS
, TmfEventSource source
,
52 TmfEventType type
, TmfEventReference reference
, String path
, String file
, int line
)
54 super(originalTS
, effectiveTS
, source
, type
, reference
);
70 public TmfTraceEvent(TmfTimestamp timestamp
, TmfEventSource source
, TmfEventType type
,
71 TmfEventReference reference
, String path
, String file
, int line
)
73 super(timestamp
, source
, type
, reference
);
82 public TmfTraceEvent(TmfTraceEvent other
) {
84 fSourcePath
= other
.fSourcePath
;
85 fFileName
= other
.fFileName
;
86 fLineNumber
= other
.fLineNumber
;
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
96 public String
getSourcePath() {
103 public String
getFileName() {
110 public int getLineNumber() {
114 // ------------------------------------------------------------------------
116 // ------------------------------------------------------------------------
119 public int hashCode() {
120 int result
= super.hashCode();
121 result
= 37 * result
+ ((fSourcePath
!= null) ? fSourcePath
.hashCode() : 0);
122 result
= 37 * result
+ ((fFileName
!= null) ? fFileName
.hashCode() : 0);
123 result
= 37 * result
+ fLineNumber
;
128 public boolean equals(Object other
) {
129 if (other
instanceof TmfEvent
) {
130 return super.equals(other
);
132 if (!(other
instanceof TmfTraceEvent
)) {
135 TmfTraceEvent o
= (TmfTraceEvent
) other
;
136 return super.equals((TmfEvent
) o
) && fSourcePath
.equals(o
.fSourcePath
) &&
137 fFileName
.equals(o
.fFileName
) && fLineNumber
== o
.fLineNumber
;
141 // TODO: Proper format
143 @SuppressWarnings("nls")
144 public String
toString() {
145 return "[TmfTraceEvent(" + fSourcePath
+ "," + fFileName
+ "," + fLineNumber
+ ")]";