1 /*******************************************************************************
2 * Copyright (c) 2009, 2015 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, updated as per TMF Event Model 1.0
11 * Alexandre Montplaisir - Made immutable, consolidated constructors
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.core
.event
;
16 import org
.eclipse
.core
.runtime
.PlatformObject
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
24 * 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 @NonNull ITmfTimestamp fTimestamp
;
42 private final ITmfEventType fType
;
43 private final ITmfEventField fContent
;
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
50 * Default constructor. Is required for extension points, but should not be
53 * @deprecated Do not use, extension-point use only. Use
54 * {@link #TmfEvent(ITmfTrace, long, ITmfTimestamp, ITmfEventType, ITmfEventField)}
59 this(null, ITmfContext
.UNKNOWN_RANK
, null, null, null);
68 * the event rank (in the trace). You can use
69 * {@link ITmfContext#UNKNOWN_RANK} as default value
75 * the event content (payload)
77 public TmfEvent(final ITmfTrace trace
,
79 final ITmfTimestamp timestamp
,
80 final ITmfEventType type
,
81 final ITmfEventField content
) {
84 if (timestamp
!= null) {
85 fTimestamp
= timestamp
;
87 fTimestamp
= TmfTimestamp
.ZERO
;
96 * @param event the original event
98 public TmfEvent(final @NonNull ITmfEvent event
) {
99 fTrace
= event
.getTrace();
100 fRank
= event
.getRank();
101 fTimestamp
= event
.getTimestamp();
102 fType
= event
.getType();
103 fContent
= event
.getContent();
106 // ------------------------------------------------------------------------
108 // ------------------------------------------------------------------------
111 public ITmfTrace
getTrace() {
112 ITmfTrace trace
= fTrace
;
114 throw new IllegalStateException("Null traces are only allowed on special kind of events and getTrace() should not be called on them"); //$NON-NLS-1$
120 public long getRank() {
125 public ITmfTimestamp
getTimestamp() {
130 public ITmfEventType
getType() {
135 public ITmfEventField
getContent() {
143 public String
getName() {
144 ITmfEventType type
= getType();
146 return type
.getName();
148 return ""; //$NON-NLS-1$
151 // ------------------------------------------------------------------------
153 // ------------------------------------------------------------------------
156 public int hashCode() {
157 final int prime
= 31;
159 result
= prime
* result
+ ((fTrace
== null) ?
0 : fTrace
.hashCode());
160 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
161 result
= prime
* result
+ fTimestamp
.hashCode();
162 result
= prime
* result
+ ((fType
== null) ?
0 : fType
.hashCode());
163 result
= prime
* result
+ ((fContent
== null) ?
0 : fContent
.hashCode());
168 public boolean equals(final Object obj
) {
175 if (!(obj
instanceof TmfEvent
)) {
178 final TmfEvent other
= (TmfEvent
) obj
;
179 if (fTrace
== null) {
180 if (other
.fTrace
!= null) {
183 } else if (!fTrace
.equals(other
.fTrace
)) {
186 if (fRank
!= other
.fRank
) {
189 if (!fTimestamp
.equals(other
.fTimestamp
)) {
193 if (other
.fType
!= null) {
196 } else if (!fType
.equals(other
.fType
)) {
199 if (fContent
== null) {
200 if (other
.fContent
!= null) {
203 } else if (!fContent
.equals(other
.fContent
)) {
210 @SuppressWarnings("nls")
211 public String
toString() {
212 return getClass().getSimpleName() + " [fTimestamp=" + getTimestamp()
213 + ", fTrace=" + getTrace() + ", fRank=" + getRank()
214 + ", fType=" + getType() + ", fContent=" + getContent()
This page took 0.03624 seconds and 5 git commands to generate.