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.
20 * @author Bernd Hufmann
22 public class TmfCallsite
implements ITmfCallsite
{
24 // ------------------------------------------------------------------------
26 // ------------------------------------------------------------------------
28 /** The file name string. */
29 final private String fFileName
;
31 /** The function name. */
32 final private String fFunctionName
;
34 /** The line number. */
35 final private long fLineNumber
;
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
42 * Default constructor.
51 public TmfCallsite(String fileName
, String functionName
, long lineNumber
) {
52 if (fileName
== null) {
53 throw new IllegalArgumentException();
56 fFunctionName
= functionName
;
57 fLineNumber
= lineNumber
;
64 * - An other call site implementation
66 public TmfCallsite(ITmfCallsite other
) {
67 if ((other
== null) || (other
.getFileName() == null)) {
68 throw new IllegalArgumentException();
70 fFileName
= other
.getFileName();
71 fFunctionName
= other
.getFunctionName();
72 fLineNumber
= other
.getLineNumber();
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 public String
getFileName() {
85 public String
getFunctionName() {
90 public long getLineNumber() {
94 // ------------------------------------------------------------------------
96 // ------------------------------------------------------------------------
99 public int hashCode() {
100 final int prime
= 31;
102 // fFileName cannot be null!
103 result
= prime
* result
+ fFileName
.hashCode();
104 result
= prime
* result
+ ((fFunctionName
== null) ?
0 : fFunctionName
.hashCode());
105 result
= prime
* result
+ (int) (fLineNumber ^
(fLineNumber
>>> 32));
110 public boolean equals(Object obj
) {
117 if (getClass() != obj
.getClass()) {
120 TmfCallsite other
= (TmfCallsite
) obj
;
122 // fFileName cannot be null!
123 if (!fFileName
.equals(other
.fFileName
)) {
127 if (!equalsNullable(fFunctionName
, other
.fFunctionName
)) {
130 if (fLineNumber
!= other
.fLineNumber
) {
137 public String
toString() {
138 StringBuilder builder
= new StringBuilder();
139 builder
.append(fFileName
).append(':');
140 builder
.append(Long
.toString(fLineNumber
));
141 if (fFunctionName
!= null) {
143 builder
.append(fFunctionName
).append("()"); //$NON-NLS-1$
145 return builder
.toString();
This page took 0.035172 seconds and 6 git commands to generate.