tmf: Remove source and reference from ITmfEvent
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core.tests / stubs / org / eclipse / tracecompass / tmf / tests / stubs / trace / text / SyslogEvent.java
CommitLineData
eadf9801
BH
1/*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made 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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12
2bdf0193 13package org.eclipse.tracecompass.tmf.tests.stubs.trace.text;
eadf9801 14
693ec829
BH
15import java.util.List;
16
ca5b04ad 17import org.eclipse.jdt.annotation.NonNull;
2bdf0193
AM
18import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
19import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
20import org.eclipse.tracecompass.tmf.core.event.collapse.ITmfCollapsibleEvent;
21import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
22import org.eclipse.tracecompass.tmf.core.trace.text.TextTraceEvent;
23import org.eclipse.tracecompass.tmf.core.trace.text.TextTraceEventContent;
eadf9801
BH
24
25/**
26 * System log trace implementation of TmfEvent.
27 */
693ec829 28public class SyslogEvent extends TextTraceEvent implements ITmfCollapsibleEvent {
eadf9801
BH
29
30 /**
31 * Default constructor
32 */
33 public SyslogEvent() {
e1de2fd4 34 super(null, null, new SyslogEventType(), null);
eadf9801
BH
35 }
36
37 /**
38 * Copy constructor
39 *
40 * @param other
41 * the event to copy
42 *
43 */
ca5b04ad 44 public SyslogEvent(final @NonNull SyslogEvent other) {
eadf9801
BH
45 super(other);
46 }
47
48 /**
49 * Full Constructor
50 *
51 * @param parentTrace
52 * the parent trace
53 * @param timestamp
54 * the event timestamp
eadf9801
BH
55 * @param type
56 * the event type
57 * @param content
58 * the event content (payload)
eadf9801 59 */
e1de2fd4
AM
60 public SyslogEvent(SyslogTrace parentTrace, final ITmfTimestamp timestamp,
61 final ITmfEventType type, final TextTraceEventContent content) {
62 super(parentTrace, timestamp, type, content);
eadf9801
BH
63 }
64
693ec829
BH
65 @Override
66 public boolean isCollapsibleWith(ITmfEvent otherEvent) {
67 if (this == otherEvent) {
68 return true;
69 }
70
71 if (!(otherEvent instanceof SyslogEvent)) {
72 return false;
73 }
74
75 final SyslogEvent other = (SyslogEvent) otherEvent;
76
ca5b04ad 77 if (!getTrace().equals(other.getTrace())) {
693ec829
BH
78 return false;
79 }
80
81 if (getType() == null) {
82 if (other.getType() != null) {
83 return false;
84 }
85 } else if (!getType().equals(other.getType())) {
86 return false;
87 }
88
89 TextTraceEventContent content = this.getContent();
90 TextTraceEventContent otherContent = other.getContent();
91
92 if (content == null) {
93 if (otherContent != null) {
94 return false;
95 }
96 return true;
97 }
98
99 if (otherContent == null) {
100 return false;
101 }
102
103 List<TextTraceEventContent> fields = content.getFields();
104 List<TextTraceEventContent> otherFields = otherContent.getFields();
105 int size = fields.size();
106
107 if (size != otherFields.size()) {
108 return false;
109 }
110
111 // At i = 0 the timestamp is stored and needs to be bypassed
112 for (int i = 1; i < size; i++) {
113 if (!fields.get(i).equals(otherFields.get(i))) {
114 return false;
115 }
116 }
117 return true;
118 }
119
eadf9801 120}
This page took 0.043583 seconds and 5 git commands to generate.