1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Patrick Tasse - Move field declarations to trace
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.text
;
16 import java
.util
.List
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventType
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.collapse
.ITmfCollapsibleEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.lookup
.ITmfCallsite
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.event
.lookup
.ITmfSourceLookup
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.event
.lookup
.TmfCallsite
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.text
.TextTraceEvent
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.text
.TextTraceEventContent
;
28 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.text
.SyslogTrace
.Field
;
31 * System log trace implementation of TmfEvent.
33 public class SyslogEvent
extends TextTraceEvent
implements ITmfCollapsibleEvent
, ITmfSourceLookup
{
38 public SyslogEvent() {
39 super(null, null, new SyslogEventType(), null);
49 public SyslogEvent(final @NonNull SyslogEvent other
) {
63 * the event content (payload)
65 public SyslogEvent(SyslogTrace parentTrace
, final ITmfTimestamp timestamp
,
66 final ITmfEventType type
, final TextTraceEventContent content
) {
67 super(parentTrace
, timestamp
, type
, content
);
71 public boolean isCollapsibleWith(ITmfEvent otherEvent
) {
72 if (this == otherEvent
) {
76 if (!(otherEvent
instanceof SyslogEvent
)) {
80 final SyslogEvent other
= (SyslogEvent
) otherEvent
;
82 if (!getTrace().equals(other
.getTrace())) {
86 if (getType() == null) {
87 if (other
.getType() != null) {
90 } else if (!getType().equals(other
.getType())) {
94 TextTraceEventContent content
= this.getContent();
95 TextTraceEventContent otherContent
= other
.getContent();
97 if (content
== null) {
98 if (otherContent
!= null) {
104 if (otherContent
== null) {
108 List
<TextTraceEventContent
> fields
= content
.getFields();
109 List
<TextTraceEventContent
> otherFields
= otherContent
.getFields();
110 int size
= fields
.size();
112 if (size
!= otherFields
.size()) {
116 // At i = 0 the timestamp is stored and needs to be bypassed
117 for (int i
= 1; i
< size
; i
++) {
118 if (!fields
.get(i
).equals(otherFields
.get(i
))) {
126 public ITmfCallsite
getCallsite() {
127 if (getContent() != null) {
130 lineNo
= Long
.valueOf((String
) getContent().getField(Field
.LINE
).getValue());
131 } catch (NumberFormatException e
) {
134 return new TmfCallsite((String
) getContent().getField(Field
.FILE
).getValue(), null, lineNo
);