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
.checkNotNull
;
17 import java
.util
.Objects
;
19 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 import org
.eclipse
.jdt
.annotation
.Nullable
;
23 * TMF call site information for source code lookup.
25 * @author Bernd Hufmann
27 public class TmfCallsite
implements ITmfCallsite
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 /** The file name string. */
34 private final @NonNull String fFileName
;
36 /** The line number. */
37 private final @Nullable Long fLineNumber
;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * Default constructor.
52 * @deprecated Use {@link #TmfCallsite(String, Long)} instead.
55 public TmfCallsite(String fileName
, String functionName
, long lineNumber
) {
56 this(checkNotNull(fileName
), lineNumber
);
63 * The source file's name
65 * The line number in the source file
68 public TmfCallsite(@NonNull String fileName
, @Nullable Long lineNumber
) {
70 fLineNumber
= lineNumber
;
77 * - An other call site implementation
79 public TmfCallsite(@NonNull ITmfCallsite other
) {
80 fFileName
= other
.getFileName();
81 fLineNumber
= other
.getLineNo();
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 public @NonNull String
getFileName() {
95 public String
getFunctionName() {
96 return ""; //$NON-NLS-1$
101 public long getLineNumber() {
102 Long lineNumber
= fLineNumber
;
103 return (lineNumber
== null ?
-1 : lineNumber
.longValue());
111 public @Nullable Long
getLineNo() {
115 // ------------------------------------------------------------------------
117 // ------------------------------------------------------------------------
120 public int hashCode() {
121 return Objects
.hash(fFileName
, fLineNumber
);
125 public boolean equals(Object obj
) {
132 if (getClass() != obj
.getClass()) {
135 TmfCallsite other
= (TmfCallsite
) obj
;
137 // fFileName cannot be null!
138 if (!fFileName
.equals(other
.fFileName
)) {
142 if (fLineNumber
!= other
.fLineNumber
) {
149 public String
toString() {
150 Long lineNumber
= fLineNumber
;
152 StringBuilder builder
= new StringBuilder();
153 builder
.append(fFileName
).append(':');
154 builder
.append(lineNumber
== null ?
"??" : Long
.toString(lineNumber
)); //$NON-NLS-1$
155 return builder
.toString();
This page took 0.036453 seconds and 6 git commands to generate.