Commit | Line | Data |
---|---|---|
d132bcc7 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
31a6a4e4 | 12 | package org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl; |
d132bcc7 | 13 | |
31a6a4e4 | 14 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo; |
d132bcc7 BH |
15 | |
16 | /** | |
17 | * <b><u>ProbleEventInfo</u></b> | |
18 | * <p> | |
19 | * Implementation of the trace event interface (IProbeEventInfo) to store probe event | |
20 | * related data. | |
21 | * </p> | |
22 | */ | |
23 | public class ProbeEventInfo extends EventInfo implements IProbeEventInfo { | |
24 | ||
25 | // ------------------------------------------------------------------------ | |
26 | // Attributes | |
27 | // ------------------------------------------------------------------------ | |
28 | /** | |
29 | * The dynamic probe address (null if symbol is used). | |
30 | */ | |
31 | private String fAddress; | |
32 | /** | |
33 | * The dynamic probe offset (if symbol is used). | |
34 | */ | |
35 | private String fOffset; | |
36 | ||
37 | /** | |
38 | * The symbol name (null if address is used) | |
39 | */ | |
40 | private String fSymbol; | |
41 | ||
42 | ||
43 | // ------------------------------------------------------------------------ | |
44 | // Constructors | |
45 | // ------------------------------------------------------------------------ | |
46 | /** | |
47 | * Constructor | |
48 | * @param name - name of event | |
49 | */ | |
50 | public ProbeEventInfo(String name) { | |
51 | super(name); | |
52 | } | |
53 | ||
54 | /** | |
55 | * Copy constructor | |
56 | * @param other - the instance to copy | |
57 | */ | |
58 | public ProbeEventInfo(ProbeEventInfo other) { | |
59 | super(other); | |
60 | fAddress = other.fAddress; | |
61 | fOffset = other.fOffset; | |
62 | fSymbol = other.fSymbol; | |
63 | } | |
64 | ||
65 | // ------------------------------------------------------------------------ | |
66 | // Accessors | |
67 | // ------------------------------------------------------------------------ | |
68 | ||
69 | /* | |
70 | * (non-Javadoc) | |
31a6a4e4 | 71 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getAddress() |
d132bcc7 BH |
72 | */ |
73 | @Override | |
74 | public String getAddress() { | |
75 | return fAddress; | |
76 | } | |
77 | ||
78 | /* | |
79 | * (non-Javadoc) | |
31a6a4e4 | 80 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setAddress(java.lang.String) |
d132bcc7 BH |
81 | */ |
82 | @Override | |
83 | public void setAddress(String address) { | |
84 | fAddress = address; | |
85 | } | |
86 | ||
87 | /* | |
88 | * (non-Javadoc) | |
31a6a4e4 | 89 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getOffset() |
d132bcc7 BH |
90 | */ |
91 | @Override | |
92 | public String getOffset() { | |
93 | return fOffset; | |
94 | } | |
95 | ||
96 | /* | |
97 | * (non-Javadoc) | |
31a6a4e4 | 98 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setOffset(java.lang.String) |
d132bcc7 BH |
99 | */ |
100 | @Override | |
101 | public void setOffset(String offset) { | |
102 | fOffset = offset; | |
103 | } | |
104 | ||
105 | /* | |
106 | * (non-Javadoc) | |
31a6a4e4 | 107 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getSymbol() |
d132bcc7 BH |
108 | */ |
109 | @Override | |
110 | public String getSymbol() { | |
111 | return fSymbol; | |
112 | } | |
113 | ||
114 | /* | |
115 | * (non-Javadoc) | |
31a6a4e4 | 116 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setSymbol(java.lang.String) |
d132bcc7 BH |
117 | */ |
118 | @Override | |
119 | public void setSymbol(String symbol) { | |
120 | fSymbol = symbol; | |
121 | } | |
122 | ||
123 | // ------------------------------------------------------------------------ | |
124 | // Operation | |
125 | // ------------------------------------------------------------------------ | |
126 | /* | |
127 | * (non-Javadoc) | |
31a6a4e4 | 128 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString() |
d132bcc7 BH |
129 | */ |
130 | @SuppressWarnings("nls") | |
131 | @Override | |
132 | public String formatString() { | |
133 | StringBuffer output = new StringBuffer(); | |
134 | // name (type: probe) [enabled]"); | |
135 | // address: | |
136 | output.append(super.formatString()); | |
137 | if (fAddress != null) { | |
138 | output.append("\n addr: "); | |
139 | output.append(fAddress); | |
140 | } else { | |
141 | output.append("\n offset: "); | |
142 | output.append(fOffset); | |
143 | output.append("\n"); | |
144 | output.append(" symbol: "); | |
145 | output.append(fSymbol); | |
146 | } | |
147 | return output.toString(); | |
148 | } | |
149 | ||
150 | /* | |
151 | * (non-Javadoc) | |
31a6a4e4 | 152 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#hashCode() |
d132bcc7 BH |
153 | */ |
154 | @Override | |
155 | public int hashCode() { | |
156 | final int prime = 31; | |
157 | int result = super.hashCode(); | |
158 | result = prime * result + ((fAddress == null) ? 0 : fAddress.hashCode()); | |
159 | result = prime * result + ((fOffset == null) ? 0 : fOffset.hashCode()); | |
160 | result = prime * result + ((fSymbol == null) ? 0 : fSymbol.hashCode()); | |
161 | return result; | |
162 | } | |
163 | ||
164 | /* | |
165 | * (non-Javadoc) | |
31a6a4e4 | 166 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object) |
d132bcc7 BH |
167 | */ |
168 | @Override | |
169 | public boolean equals(Object obj) { | |
170 | if (this == obj) { | |
171 | return true; | |
172 | } | |
173 | if (!super.equals(obj)) { | |
174 | return false; | |
175 | } | |
176 | if (getClass() != obj.getClass()) { | |
177 | return false; | |
178 | } | |
179 | ProbeEventInfo other = (ProbeEventInfo) obj; | |
180 | if (fAddress == null) { | |
181 | if (other.fAddress != null) { | |
182 | return false; | |
183 | } | |
184 | } else if (!fAddress.equals(other.fAddress)) { | |
185 | return false; | |
186 | } | |
187 | if (fOffset == null) { | |
188 | if (other.fOffset != null) { | |
189 | return false; | |
190 | } | |
191 | } else if (!fOffset.equals(other.fOffset)) { | |
192 | return false; | |
193 | } | |
194 | if (fSymbol == null) { | |
195 | if (other.fSymbol != null) { | |
196 | return false; | |
197 | } | |
198 | } else if (!fSymbol.equals(other.fSymbol)) { | |
199 | return false; | |
200 | } | |
201 | return true; | |
202 | } | |
203 | ||
204 | ||
205 | /* | |
206 | * (non-Javadoc) | |
31a6a4e4 | 207 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo#toString() |
d132bcc7 BH |
208 | */ |
209 | @SuppressWarnings("nls") | |
210 | @Override | |
211 | public String toString() { | |
212 | StringBuffer output = new StringBuffer(); | |
213 | output.append("[ProbeEventInfo("); | |
214 | output.append(super.toString()); | |
215 | if (fAddress != null) { | |
216 | output.append(",fAddress="); | |
217 | output.append(fAddress); | |
218 | } else { | |
219 | output.append(",fOffset="); | |
220 | output.append(fOffset); | |
221 | output.append(",fSymbol="); | |
222 | output.append(fSymbol); | |
223 | } | |
224 | output.append(")]"); | |
225 | return output.toString(); | |
226 | } | |
227 | ||
228 | ||
229 | } |