Fix javadoc warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / event / TmfEvent.java
CommitLineData
8c8bf09f 1/*******************************************************************************
ce970a71 2 * Copyright (c) 2009, 2012 Ericsson
8c8bf09f 3 *
ce970a71 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
8c8bf09f
ASL
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
bbc1c411 9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
ce970a71 11 * Francois Chouinard - Updated as per TMF Event Model 1.0
8c8bf09f
ASL
12 *******************************************************************************/
13
6c13869b 14package org.eclipse.linuxtools.tmf.core.event;
8c8bf09f 15
6c13869b 16import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
2c8610f7 17
8c8bf09f
ASL
18/**
19 * <b><u>TmfEvent</u></b>
20 * <p>
4c564a2d 21 * A basic implementation of ITmfEvent.
28b94d61 22 *
d7dbf09a
FC
23 * Note that for performance reasons TmfEvent is NOT immutable. If a shallow
24 * copy of the event is needed, use the copy constructor. Otherwise (deep copy)
25 * use clone().
8c8bf09f 26 */
4c564a2d 27public class TmfEvent implements ITmfEvent {
12c155f5 28
cbd4ad82 29 // ------------------------------------------------------------------------
8c8bf09f 30 // Attributes
cbd4ad82 31 // ------------------------------------------------------------------------
8c8bf09f 32
7b477cc3
FC
33 private ITmfTrace<? extends ITmfEvent> fTrace;
34 private long fRank;
35 private ITmfTimestamp fTimestamp;
36 private String fSource;
37 private ITmfEventType fType;
38 private ITmfEventField fContent;
39 private String fReference;
28b94d61 40
cbd4ad82 41 // ------------------------------------------------------------------------
8c8bf09f 42 // Constructors
cbd4ad82 43 // ------------------------------------------------------------------------
8c8bf09f 44
2c8610f7 45 /**
ce970a71 46 * Default constructor
2c8610f7 47 */
ce970a71 48 public TmfEvent() {
b4d534a0 49 this(null, -1, null, null, null, null, null);
12c155f5 50 }
1f506a43 51
12c155f5 52 /**
ce970a71 53 * Constructor - no rank
12c155f5 54 */
72f1e62a 55 public TmfEvent(ITmfTrace<? extends ITmfEvent> trace, ITmfTimestamp timestamp, String source,
d7dbf09a 56 ITmfEventType type, ITmfEventField content, String reference)
5179fc01 57 {
4c564a2d 58 this(trace, -1, timestamp, source, type, content, reference);
12c155f5 59 }
8c8bf09f 60
12c155f5 61 /**
4c564a2d 62 * Constructor - no rank, no content
12c155f5 63 */
72f1e62a 64 public TmfEvent(ITmfTrace<? extends ITmfEvent> trace, ITmfTimestamp timestamp, String source,
d7dbf09a 65 ITmfEventType type, String reference)
4c564a2d
FC
66 {
67 this(trace, -1, timestamp, source, type, null, reference);
68 }
69
70 /**
71 * Constructor - no rank, no content, no trace
72 */
ed963ef6 73 public TmfEvent(ITmfTimestamp timestamp, String source, ITmfEventType type, String reference)
4c564a2d
FC
74 {
75 this(null, -1, timestamp, source, type, null, reference);
12c155f5 76 }
8c8bf09f 77
b4d534a0
FC
78 /**
79 * Full constructor
80 *
81 * @param trace the parent trace
82 * @param rank the event rank (in the trace)
83 * @param timestamp the event timestamp
84 * @param source the event source
85 * @param type the event type
0d9a6d76 86 * @param content the event content (payload)
b4d534a0
FC
87 * @param reference the event reference
88 */
89 public TmfEvent(ITmfTrace<? extends ITmfEvent> trace, long rank, ITmfTimestamp timestamp, String source,
90 ITmfEventType type, ITmfEventField content, String reference)
91 {
92 fTrace = trace;
93 fRank = rank;
94 fTimestamp = timestamp;
95 fSource = source;
96 fType = type;
97 fContent = content;
98 fReference = reference;
99 }
100
12c155f5 101 /**
ce970a71 102 * Copy constructor
103 *
104 * @param event the original event
12c155f5 105 */
72f1e62a 106 public TmfEvent(ITmfEvent event) {
4c564a2d
FC
107 if (event == null)
108 throw new IllegalArgumentException();
72f1e62a
FC
109 fTrace = event.getTrace();
110 fRank = event.getRank();
111 fTimestamp = event.getTimestamp();
112 fSource = event.getSource();
113 fType = event.getType();
114 fContent = event.getContent();
115 fReference = event.getReference();
12c155f5 116 }
8c8bf09f 117
ce970a71 118 // ------------------------------------------------------------------------
119 // ITmfEvent
120 // ------------------------------------------------------------------------
8c8bf09f 121
d7dbf09a
FC
122 /* (non-Javadoc)
123 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getTrace()
124 */
125 @Override
72f1e62a 126 public ITmfTrace<? extends ITmfEvent> getTrace() {
4c564a2d
FC
127 return fTrace;
128 }
129
d7dbf09a
FC
130 /* (non-Javadoc)
131 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getRank()
132 */
133 @Override
4c564a2d
FC
134 public long getRank() {
135 return fRank;
136 }
137
d7dbf09a
FC
138 /* (non-Javadoc)
139 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getTimestamp()
140 */
141 @Override
4df4581d 142 public ITmfTimestamp getTimestamp() {
ce970a71 143 return fTimestamp;
12c155f5 144 }
1f506a43 145
d7dbf09a
FC
146 /* (non-Javadoc)
147 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getSource()
148 */
149 @Override
4c564a2d
FC
150 public String getSource() {
151 return fSource;
152 }
153
d7dbf09a
FC
154 /* (non-Javadoc)
155 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getType()
156 */
157 @Override
4c564a2d
FC
158 public ITmfEventType getType() {
159 return fType;
160 }
161
d7dbf09a
FC
162 /* (non-Javadoc)
163 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getContent()
164 */
165 @Override
4c564a2d
FC
166 public ITmfEventField getContent() {
167 return fContent;
168 }
169
d7dbf09a
FC
170 /* (non-Javadoc)
171 * @see org.eclipse.linuxtools.tmf.core.event.ITmfEvent#getReference()
172 */
173 @Override
4c564a2d
FC
174 public String getReference() {
175 return fReference;
176 }
177
178 // ------------------------------------------------------------------------
179 // Convenience setters
180 // ------------------------------------------------------------------------
181
7b477cc3 182 /**
0d9a6d76 183 * @param trace the new event trace
7b477cc3
FC
184 */
185 protected void setTrace(ITmfTrace<? extends ITmfEvent> trace) {
186 fTrace = trace;
187 }
188
4c564a2d 189 /**
0d9a6d76 190 * @param rank the new event rank
4c564a2d 191 */
7b477cc3
FC
192 protected void setRank(long rank) {
193 fRank = rank;
4c564a2d
FC
194 }
195
196 /**
197 * @param timestamp the new event timestamp
198 */
7b477cc3 199 protected void setTimestamp(ITmfTimestamp timestamp) {
4c564a2d
FC
200 fTimestamp = timestamp;
201 }
202
7b477cc3
FC
203 /**
204 * @param source the new event source
205 */
206 protected void setSource(String source) {
207 fSource = source;
208 }
209
4c564a2d
FC
210 /**
211 * @param type the new event type
212 */
7b477cc3 213 protected void setType(ITmfEventType type) {
4c564a2d
FC
214 fType = type;
215 }
216
217 /**
218 * @param content the event new content
219 */
7b477cc3 220 protected void setContent(ITmfEventField content) {
4c564a2d
FC
221 fContent = content;
222 }
223
224 /**
225 * @param reference the new event reference
226 */
7b477cc3 227 protected void setReference(String reference) {
4c564a2d
FC
228 fReference = reference;
229 }
230
ce970a71 231 // ------------------------------------------------------------------------
232 // Cloneable
233 // ------------------------------------------------------------------------
cbd4ad82 234
d7dbf09a
FC
235 /* (non-Javadoc)
236 * @see java.lang.Object#clone()
237 */
ce970a71 238 @Override
239 public TmfEvent clone() {
240 TmfEvent clone = null;
4c564a2d
FC
241 try {
242 clone = (TmfEvent) super.clone();
243 clone.fTrace = fTrace;
244 clone.fRank = fRank;
245 clone.fTimestamp = fTimestamp != null ? fTimestamp.clone() : null;
246 clone.fSource = fSource;
247 clone.fType = fType != null ? fType.clone() : null;
248 clone.fContent = fContent != null ? fContent.clone() : null;
249 clone.fReference = fReference;
250 } catch (CloneNotSupportedException e) {
251 }
ce970a71 252 return clone;
12c155f5 253 }
c76c54bb 254
12c155f5 255 // ------------------------------------------------------------------------
cbd4ad82
FC
256 // Object
257 // ------------------------------------------------------------------------
28b94d61 258
d7dbf09a
FC
259 /* (non-Javadoc)
260 * @see java.lang.Object#hashCode()
261 */
12c155f5 262 @Override
cbd4ad82 263 public int hashCode() {
ce970a71 264 final int prime = 31;
4c564a2d
FC
265 int result = 1;
266 result = prime * result + ((fTrace == null) ? 0 : fTrace.hashCode());
267 result = prime * result + (int) (fRank ^ (fRank >>> 32));
ce970a71 268 result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
4c564a2d
FC
269 result = prime * result + ((fSource == null) ? 0 : fSource.hashCode());
270 result = prime * result + ((fType == null) ? 0 : fType.hashCode());
271 result = prime * result + ((fContent == null) ? 0 : fContent.hashCode());
272 result = prime * result + ((fReference == null) ? 0 : fReference.hashCode());
cbd4ad82
FC
273 return result;
274 }
275
d7dbf09a
FC
276 /* (non-Javadoc)
277 * @see java.lang.Object#equals(java.lang.Object)
278 */
cbd4ad82 279 @Override
ce970a71 280 public boolean equals(Object obj) {
281 if (this == obj)
282 return true;
4c564a2d 283 if (obj == null)
12c155f5 284 return false;
bd78efc6 285 if (!(obj instanceof TmfEvent))
ce970a71 286 return false;
287 TmfEvent other = (TmfEvent) obj;
4c564a2d
FC
288 if (fTrace == null) {
289 if (other.fTrace != null)
290 return false;
291 } else if (!fTrace.equals(other.fTrace))
292 return false;
293 if (fRank != other.fRank)
294 return false;
ce970a71 295 if (fTimestamp == null) {
296 if (other.fTimestamp != null)
0c841e0f 297 return false;
ce970a71 298 } else if (!fTimestamp.equals(other.fTimestamp))
299 return false;
4c564a2d
FC
300 if (fSource == null) {
301 if (other.fSource != null)
302 return false;
303 } else if (!fSource.equals(other.fSource))
304 return false;
305 if (fType == null) {
306 if (other.fType != null)
307 return false;
308 } else if (!fType.equals(other.fType))
309 return false;
310 if (fContent == null) {
311 if (other.fContent != null)
312 return false;
313 } else if (!fContent.equals(other.fContent))
314 return false;
315 if (fReference == null) {
316 if (other.fReference != null)
317 return false;
318 } else if (!fReference.equals(other.fReference))
319 return false;
0c841e0f 320 return true;
cbd4ad82 321 }
28b94d61 322
d7dbf09a
FC
323 /* (non-Javadoc)
324 * @see java.lang.Object#toString()
325 */
12c155f5 326 @Override
3b38ea61 327 @SuppressWarnings("nls")
12c155f5 328 public String toString() {
ce970a71 329 return "TmfEvent [fTimestamp=" + fTimestamp + ", fTrace=" + fTrace + ", fRank=" + fRank
330 + ", fSource=" + fSource + ", fType=" + fType + ", fContent=" + fContent
331 + ", fReference=" + fReference + "]";
12c155f5 332 }
f9673903 333
8c8bf09f 334}
This page took 0.051492 seconds and 5 git commands to generate.