1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 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 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Event Model 1.0
12 * Alexandre Montplaisir - Made immutable
13 *******************************************************************************/
15 package org
.eclipse
.linuxtools
.tmf
.core
.event
;
17 import org
.eclipse
.core
.runtime
.PlatformObject
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
23 * A basic implementation of ITmfEvent.
26 * @author Francois Chouinard
33 public class TmfEvent
extends PlatformObject
implements ITmfEvent
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 private final ITmfTrace fTrace
;
40 private final long fRank
;
41 private final ITmfTimestamp fTimestamp
;
42 private final String fSource
;
43 private final ITmfEventType fType
;
44 private final ITmfEventField fContent
;
45 private final String fReference
;
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
52 * Default constructor. All fields have their default value (null) and the
53 * event rank is set to TmfContext.UNKNOWN_RANK.
56 this(null, ITmfContext
.UNKNOWN_RANK
, null, null, null, null, null);
60 * Standard constructor. The event rank will be set to TmfContext.UNKNOWN_RANK.
62 * @param trace the parent trace
63 * @param timestamp the event timestamp
64 * @param source the event source
65 * @param type the event type
66 * @param content the event content (payload)
67 * @param reference the event reference
71 public TmfEvent(final ITmfTrace trace
, final ITmfTimestamp timestamp
, final String source
,
72 final ITmfEventType type
, final ITmfEventField content
, final String reference
)
74 this(trace
, ITmfContext
.UNKNOWN_RANK
, timestamp
, source
, type
, content
, reference
);
80 * @param trace the parent trace
81 * @param rank the event rank (in the trace)
82 * @param timestamp the event timestamp
83 * @param source the event source
84 * @param type the event type
85 * @param content the event content (payload)
86 * @param reference the event reference
89 public TmfEvent(final ITmfTrace trace
, final long rank
, final ITmfTimestamp timestamp
, final String source
,
90 final ITmfEventType type
, final ITmfEventField content
, final String reference
)
94 fTimestamp
= timestamp
;
98 fReference
= reference
;
104 * @param event the original event
106 public TmfEvent(final ITmfEvent event
) {
108 throw new IllegalArgumentException();
110 fTrace
= event
.getTrace();
111 fRank
= event
.getRank();
112 fTimestamp
= event
.getTimestamp();
113 fSource
= event
.getSource();
114 fType
= event
.getType();
115 fContent
= event
.getContent();
116 fReference
= event
.getReference();
119 // ------------------------------------------------------------------------
121 // ------------------------------------------------------------------------
124 public ITmfTrace
getTrace() {
129 public long getRank() {
137 public ITmfTimestamp
getTimestamp() {
142 public String
getSource() {
147 public ITmfEventType
getType() {
152 public ITmfEventField
getContent() {
157 public String
getReference() {
161 // ------------------------------------------------------------------------
163 // ------------------------------------------------------------------------
166 public int hashCode() {
167 final int prime
= 31;
169 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.hashCode());
170 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
171 result
= prime
* result
+ ((fTimestamp
== null) ?
0 : fTimestamp
.hashCode());
172 result
= prime
* result
+ ((fSource
== null) ?
0 : fSource
.hashCode());
173 result
= prime
* result
+ ((fType
== null) ?
0 : fType
.hashCode());
174 result
= prime
* result
+ ((fContent
== null) ?
0 : fContent
.hashCode());
175 result
= prime
* result
+ ((fReference
== null) ?
0 : fReference
.hashCode());
180 public boolean equals(final Object obj
) {
187 if (!(obj
instanceof TmfEvent
)) {
190 final TmfEvent other
= (TmfEvent
) obj
;
191 if (fTrace
== null) {
192 if (other
.fTrace
!= null) {
195 } else if (!fTrace
.equals(other
.fTrace
)) {
198 if (fRank
!= other
.fRank
) {
201 if (fTimestamp
== null) {
202 if (other
.fTimestamp
!= null) {
205 } else if (!fTimestamp
.equals(other
.fTimestamp
)) {
208 if (fSource
== null) {
209 if (other
.fSource
!= null) {
212 } else if (!fSource
.equals(other
.fSource
)) {
216 if (other
.fType
!= null) {
219 } else if (!fType
.equals(other
.fType
)) {
222 if (fContent
== null) {
223 if (other
.fContent
!= null) {
226 } else if (!fContent
.equals(other
.fContent
)) {
229 if (fReference
== null) {
230 if (other
.fReference
!= null) {
233 } else if (!fReference
.equals(other
.fReference
)) {
240 @SuppressWarnings("nls")
241 public String
toString() {
242 return getClass().getSimpleName() + " [fTimestamp=" + getTimestamp()
243 + ", fTrace=" + getTrace() + ", fRank=" + getRank()
244 + ", fSource=" + getSource() + ", fType=" + getType()
245 + ", fContent=" + getContent() + ", fReference=" + getReference()
This page took 0.105183 seconds and 5 git commands to generate.