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