|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Last known location represents the last known position of a trace |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracebuilder.engine; |
|
20 |
|
21 import com.nokia.tracebuilder.model.Trace; |
|
22 import com.nokia.tracebuilder.model.TraceObject; |
|
23 import com.nokia.tracebuilder.source.SourceConstants; |
|
24 |
|
25 /** |
|
26 * Last known location represents the last known position of a trace |
|
27 * |
|
28 */ |
|
29 public final class LastKnownLocation implements LocationProperties { |
|
30 |
|
31 /** |
|
32 * Location list owning this location |
|
33 */ |
|
34 private LastKnownLocationList list; |
|
35 |
|
36 /** |
|
37 * Path of the source file |
|
38 */ |
|
39 private String path; |
|
40 |
|
41 /** |
|
42 * Source file name |
|
43 */ |
|
44 private String file; |
|
45 |
|
46 /** |
|
47 * Line number |
|
48 */ |
|
49 private int line; |
|
50 |
|
51 /** |
|
52 * View reference, used by view for quick access |
|
53 */ |
|
54 private Object viewReference; |
|
55 |
|
56 /** |
|
57 * Name of the class where the trace belongs to |
|
58 */ |
|
59 private String className; |
|
60 |
|
61 /** |
|
62 * Name of the function where the trace belongs to |
|
63 */ |
|
64 private String functionName; |
|
65 |
|
66 /** |
|
67 * Creates a new last known location |
|
68 * |
|
69 * @param path |
|
70 * file path |
|
71 * @param file |
|
72 * file name |
|
73 * @param line |
|
74 * line number |
|
75 * @param className |
|
76 * the name of the class |
|
77 * @param functionName |
|
78 * the name of the function |
|
79 */ |
|
80 public LastKnownLocation(String path, String file, int line, |
|
81 String className, String functionName) { |
|
82 if (path != null && path.length() > 0) { |
|
83 path = path.replace(SourceConstants.BACKSLASH_CHAR, |
|
84 SourceConstants.FORWARD_SLASH_CHAR); |
|
85 if (path.charAt(path.length() - 1) != SourceConstants.FORWARD_SLASH_CHAR) { |
|
86 path = path + SourceConstants.FORWARD_SLASH_CHAR; |
|
87 } |
|
88 this.path = path; |
|
89 } else { |
|
90 this.path = String.valueOf(SourceConstants.FORWARD_SLASH_CHAR); |
|
91 } |
|
92 this.file = file == null ? "" : file; //$NON-NLS-1$ |
|
93 this.line = line; |
|
94 this.className = className == null ? "" : className; //$NON-NLS-1$ |
|
95 this.functionName = functionName == null ? "" : functionName; //$NON-NLS-1$ |
|
96 } |
|
97 |
|
98 /** |
|
99 * Gets the trace |
|
100 * |
|
101 * @return the trace |
|
102 */ |
|
103 public Trace getTrace() { |
|
104 Trace retval = null; |
|
105 if (list != null) { |
|
106 TraceObject owner = list.getOwner(); |
|
107 if (owner instanceof Trace) { |
|
108 retval = (Trace) owner; |
|
109 } |
|
110 } |
|
111 return retval; |
|
112 } |
|
113 |
|
114 /* |
|
115 * (non-Javadoc) |
|
116 * |
|
117 * @see com.nokia.tracebuilder.engine.LocationProperties#getFilePath() |
|
118 */ |
|
119 public String getFilePath() { |
|
120 return path; |
|
121 } |
|
122 |
|
123 /* |
|
124 * (non-Javadoc) |
|
125 * |
|
126 * @see com.nokia.tracebuilder.engine.LocationProperties#getFileName() |
|
127 */ |
|
128 public String getFileName() { |
|
129 return file; |
|
130 } |
|
131 |
|
132 /* |
|
133 * (non-Javadoc) |
|
134 * |
|
135 * @see com.nokia.tracebuilder.engine.LocationProperties#getLineNumber() |
|
136 */ |
|
137 public int getLineNumber() { |
|
138 return line; |
|
139 } |
|
140 |
|
141 /* |
|
142 * (non-Javadoc) |
|
143 * |
|
144 * @see com.nokia.tracebuilder.engine.LocationProperties#getClassName() |
|
145 */ |
|
146 public String getClassName() { |
|
147 return className; |
|
148 } |
|
149 |
|
150 /* |
|
151 * (non-Javadoc) |
|
152 * |
|
153 * @see com.nokia.tracebuilder.engine.LocationProperties#getFunctionName() |
|
154 */ |
|
155 public String getFunctionName() { |
|
156 return functionName; |
|
157 } |
|
158 |
|
159 /** |
|
160 * Used by view for quick access |
|
161 * |
|
162 * @return the view reference |
|
163 */ |
|
164 public Object getViewReference() { |
|
165 return viewReference; |
|
166 } |
|
167 |
|
168 /** |
|
169 * Sets the view reference |
|
170 * |
|
171 * @param ref |
|
172 * the view reference |
|
173 */ |
|
174 public void setViewReference(Object ref) { |
|
175 viewReference = ref; |
|
176 } |
|
177 |
|
178 /** |
|
179 * Sets the location list |
|
180 * |
|
181 * @param list |
|
182 * the list |
|
183 */ |
|
184 void setLocationList(LastKnownLocationList list) { |
|
185 this.list = list; |
|
186 } |
|
187 |
|
188 } |