1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.event
.lookup
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.equalsNullable
;
18 * TMF call site information for source code lookup.
21 * @author Bernd Hufmann
23 public class TmfCallsite
implements ITmfCallsite
{
25 // ------------------------------------------------------------------------
27 // ------------------------------------------------------------------------
29 /** The file name string. */
30 final private String fFileName
;
32 /** The function name. */
33 final private String fFunctionName
;
35 /** The line number. */
36 final private long fLineNumber
;
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
43 * Default constructor.
52 public TmfCallsite(String fileName
, String functionName
, long lineNumber
) {
53 if (fileName
== null) {
54 throw new IllegalArgumentException();
57 fFunctionName
= functionName
;
58 fLineNumber
= lineNumber
;
65 * - An other call site implementation
67 public TmfCallsite(ITmfCallsite other
) {
68 if ((other
== null) || (other
.getFileName() == null)) {
69 throw new IllegalArgumentException();
71 fFileName
= other
.getFileName();
72 fFunctionName
= other
.getFunctionName();
73 fLineNumber
= other
.getLineNumber();
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
81 public String
getFileName() {
86 public String
getFunctionName() {
91 public long getLineNumber() {
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
100 public int hashCode() {
101 final int prime
= 31;
103 // fFileName cannot be null!
104 result
= prime
* result
+ fFileName
.hashCode();
105 result
= prime
* result
+ ((fFunctionName
== null) ?
0 : fFunctionName
.hashCode());
106 result
= prime
* result
+ (int) (fLineNumber ^
(fLineNumber
>>> 32));
111 public boolean equals(Object obj
) {
118 if (getClass() != obj
.getClass()) {
121 TmfCallsite other
= (TmfCallsite
) obj
;
123 // fFileName cannot be null!
124 if (!fFileName
.equals(other
.fFileName
)) {
128 if (!equalsNullable(fFunctionName
, other
.fFunctionName
)) {
131 if (fLineNumber
!= other
.fLineNumber
) {
138 public String
toString() {
139 StringBuilder builder
= new StringBuilder();
140 builder
.append(fFileName
).append(':');
141 builder
.append(Long
.toString(fLineNumber
));
142 if (fFunctionName
!= null) {
144 builder
.append(fFunctionName
).append("()"); //$NON-NLS-1$
146 return builder
.toString();
This page took 0.039075 seconds and 6 git commands to generate.