1 /*******************************************************************************
2 * Copyright (c) 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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.event
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
19 * A basic implementation of ITmfLostEvent.
21 * @author Francois Chouinard
25 public class TmfLostEvent
extends TmfEvent
implements ITmfLostEvent
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 private TmfTimeRange fTimeRange
;
32 private long fNbLostEvents
;
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
39 * Default constructor which boils down to the default TmfEvent with no
40 * lost event over the empty time range.
42 public TmfLostEvent() {
43 this(null, ITmfContext
.UNKNOWN_RANK
, null, null, null, null, TmfTimeRange
.NULL_RANGE
, 0);
49 * @param trace the parent trace
50 * @param rank the event rank (in the trace)
51 * @param timestamp the event timestamp
52 * @param source the event source
53 * @param type the event type
54 * @param reference the event reference
55 * @param timeRange the 'problematic' time range
56 * @param nbLostEvents the number of lost events in the time range
58 public TmfLostEvent(final ITmfTrace trace
, final long rank
, final ITmfTimestamp timestamp
,
59 final String source
, final ITmfEventType type
, final String reference
, final TmfTimeRange timeRange
, final long nbLostEvents
)
61 super(trace
, rank
, timestamp
, source
, type
, null, reference
);
62 fTimeRange
= timeRange
;
63 fNbLostEvents
= nbLostEvents
;
69 * @param event the original event
71 public TmfLostEvent(final ITmfLostEvent event
) {
73 throw new IllegalArgumentException();
75 setTrace(event
.getTrace());
76 setRank(event
.getRank());
77 setTimestamp(event
.getTimestamp());
78 setSource(event
.getSource());
79 setType(event
.getType());
80 setContent(event
.getContent());
81 setReference(event
.getReference());
83 fTimeRange
= event
.getTimeRange();
84 fNbLostEvents
= event
.getNbLostEvents();
87 // ------------------------------------------------------------------------
89 // ------------------------------------------------------------------------
92 * @see org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent#getTimeRange()
95 public TmfTimeRange
getTimeRange() {
100 * @see org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent#getNbLostEvents()
103 public long getNbLostEvents() {
104 return fNbLostEvents
;
107 // ------------------------------------------------------------------------
108 // Convenience setters
109 // ------------------------------------------------------------------------
112 * @param timeRange the 'problematic' time range
114 protected void setTimeRange(final TmfTimeRange timeRange
) {
115 fTimeRange
= timeRange
;
119 * @param nbLostEvents the number of lost events
121 protected void setNbLostEvents(final long nbLostEvents
) {
122 fNbLostEvents
= nbLostEvents
;
125 // ------------------------------------------------------------------------
127 // ------------------------------------------------------------------------
130 * @see java.lang.Object#clone()
133 public TmfLostEvent
clone() {
134 TmfLostEvent clone
= null;
136 clone
= (TmfLostEvent
) super.clone();
137 clone
.fTimeRange
= fTimeRange
.clone();
138 clone
.fNbLostEvents
= fNbLostEvents
;
139 } catch (CloneNotSupportedException e
) {
144 // ------------------------------------------------------------------------
146 // ------------------------------------------------------------------------
149 * @see java.lang.Object#hashCode()
152 public int hashCode() {
153 final int prime
= 31;
154 int result
= super.hashCode();
155 result
= prime
* result
+ (int) (fNbLostEvents ^
(fNbLostEvents
>>> 32));
156 result
= prime
* result
+ ((fTimeRange
== null) ?
0 : fTimeRange
.hashCode());
161 * @see java.lang.Object#equals(java.lang.Object)
164 public boolean equals(Object obj
) {
168 if (!super.equals(obj
)) {
171 if (!(obj
instanceof TmfLostEvent
)) {
174 TmfLostEvent other
= (TmfLostEvent
) obj
;
175 if (fNbLostEvents
!= other
.fNbLostEvents
) {
178 if (fTimeRange
== null) {
179 if (other
.fTimeRange
!= null) {
182 } else if (!fTimeRange
.equals(other
.fTimeRange
)) {
189 * @see java.lang.Object#toString()
192 @SuppressWarnings("nls")
193 public String
toString() {
194 return "TmfLostEvent [Event=" + super.toString() + ", fTimeRange=" + fTimeRange
+ ", fNbLostEvents=" + fNbLostEvents
+ "]";