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
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Event Model 1.0
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.event
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
19 * <b><u>TmfEvent</u></b>
21 * The basic event structure in the TMF. In its canonical form, an event has:
23 * <li>a normalized timestamp
24 * <li>a source (reporter)
28 * For convenience, a free-form reference field is also provided. It could be
29 * used as e.g. a location marker in the event stream to distinguish between
30 * otherwise identical events.
32 * Notice that for performance reasons TmfEvent is NOT immutable. If a copy of
33 * the event is needed, use the copy constructor.
35 public class TmfEvent
extends TmfDataItem
implements ITmfEvent
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 protected ITmfTimestamp fTimestamp
;
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
56 * @param trace the parent trace
57 * @param rank the vent rank (in the trace)
58 * @param timestamp the event timestamp
59 * @param source the event source
60 * @param type the event type
61 * @param reference the event reference
63 public TmfEvent(ITmfTrace
<?
> trace
, long rank
, ITmfTimestamp timestamp
, String source
,
64 TmfEventType type
, String reference
)
66 super(trace
, rank
, source
, type
, null, reference
);
67 fTimestamp
= timestamp
;
71 * Constructor - no rank
73 public TmfEvent(ITmfTrace
<?
> parentTrace
, ITmfTimestamp timestamp
, String source
,
74 TmfEventType type
, String reference
)
76 this(parentTrace
, -1, timestamp
, source
, type
, reference
);
80 * Constructor - no trace, no rank
82 public TmfEvent(ITmfTimestamp timestamp
, String source
, TmfEventType type
, String reference
) {
83 this(null, -1, timestamp
, source
, type
, reference
);
89 * @param event the original event
91 public TmfEvent(TmfEvent event
) {
93 fTimestamp
= event
.fTimestamp
!= null ? event
.fTimestamp
.clone() : null;
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
101 * @return the effective event timestamp
103 public ITmfTimestamp
getTimestamp() {
107 // ------------------------------------------------------------------------
109 // ------------------------------------------------------------------------
112 public TmfEvent
clone() {
113 TmfEvent clone
= null;
114 clone
= (TmfEvent
) super.clone();
115 clone
.fTimestamp
= fTimestamp
!= null ? fTimestamp
.clone() : null;
119 // ------------------------------------------------------------------------
121 // ------------------------------------------------------------------------
124 public int hashCode() {
125 final int prime
= 31;
126 int result
= super.hashCode();
127 result
= prime
* result
+ ((fTimestamp
== null) ?
0 : fTimestamp
.hashCode());
132 public boolean equals(Object obj
) {
135 if (!super.equals(obj
))
137 if (getClass() != obj
.getClass())
139 TmfEvent other
= (TmfEvent
) obj
;
140 if (fTimestamp
== null) {
141 if (other
.fTimestamp
!= null)
143 } else if (!fTimestamp
.equals(other
.fTimestamp
))
149 @SuppressWarnings("nls")
150 public String
toString() {
151 return "TmfEvent [fTimestamp=" + fTimestamp
+ ", fTrace=" + fTrace
+ ", fRank=" + fRank
152 + ", fSource=" + fSource
+ ", fType=" + fType
+ ", fContent=" + fContent
153 + ", fReference=" + fReference
+ "]";
This page took 0.03822 seconds and 6 git commands to generate.