1 /*******************************************************************************
2 * Copyright (c) 2009, 2012 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
9 * Contributors: Francois Chouinard - Initial API and implementation
10 * Francois Chouinard - Updated as per TMF Event Model 1.0
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.event
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
18 * <b><u>TmfEvent</u></b>
20 * The basic event structure in the TMF. In its canonical form, an event has:
22 * <li>a normalized timestamp
23 * <li>a source (reporter)
27 * For convenience, a free-form reference field is also provided. It could be
28 * used as e.g. a location marker in the event stream to distinguish between
29 * otherwise identical events.
31 * Notice that for performance reasons TmfEvent is NOT immutable. If a copy of
32 * the event is needed, use the copy constructor.
34 public class TmfEvent
extends TmfDataEvent
implements Cloneable
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
40 protected TmfTimestamp fTimestamp
;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
55 * @param trace the parent trace
56 * @param rank the vent rank (in the trace)
57 * @param timestamp the event timestamp
58 * @param source the event source
59 * @param type the event type
60 * @param reference the event reference
62 public TmfEvent(ITmfTrace
<?
> trace
, long rank
, TmfTimestamp timestamp
, String source
,
63 TmfEventType type
, String reference
)
65 super(trace
, rank
, source
, type
, null, reference
);
66 fTimestamp
= timestamp
;
70 * Constructor - no rank
72 public TmfEvent(ITmfTrace
<?
> parentTrace
, TmfTimestamp timestamp
, String source
,
73 TmfEventType type
, String reference
)
75 this(parentTrace
, -1, timestamp
, source
, type
, reference
);
79 * Constructor - no trace, no rank
81 public TmfEvent(TmfTimestamp timestamp
, String source
, TmfEventType type
, String reference
) {
82 this(null, -1, timestamp
, source
, type
, reference
);
88 * @param event the original event
90 public TmfEvent(TmfEvent event
) {
92 fTimestamp
= event
.fTimestamp
!= null ?
new TmfTimestamp(event
.fTimestamp
) : null;
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
100 * @return the effective event timestamp
102 public TmfTimestamp
getTimestamp() {
106 // ------------------------------------------------------------------------
108 // ------------------------------------------------------------------------
111 public TmfEvent
clone() {
112 TmfEvent clone
= null;
113 clone
= (TmfEvent
) super.clone();
114 clone
.fTimestamp
= fTimestamp
!= null ? fTimestamp
.clone() : null;
118 // ------------------------------------------------------------------------
120 // ------------------------------------------------------------------------
123 public int hashCode() {
124 final int prime
= 31;
125 int result
= super.hashCode();
126 result
= prime
* result
+ ((fTimestamp
== null) ?
0 : fTimestamp
.hashCode());
131 public boolean equals(Object obj
) {
134 if (!super.equals(obj
))
136 if (getClass() != obj
.getClass())
138 TmfEvent other
= (TmfEvent
) obj
;
139 if (fTimestamp
== null) {
140 if (other
.fTimestamp
!= null)
142 } else if (!fTimestamp
.equals(other
.fTimestamp
))
148 @SuppressWarnings("nls")
149 public String
toString() {
150 return "TmfEvent [fTimestamp=" + fTimestamp
+ ", fTrace=" + fTrace
+ ", fRank=" + fRank
151 + ", fSource=" + fSource
+ ", fType=" + fType
+ ", fContent=" + fContent
152 + ", fReference=" + fReference
+ "]";
This page took 0.072081 seconds and 6 git commands to generate.