1 /*******************************************************************************
2 * Copyright (c) 2010, 2016 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
;
15 import org
.eclipse
.jdt
.annotation
.NonNull
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEventField
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEvent
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEventType
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
.Tag
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
24 * Trace event for custom XML traces.
26 * @author Patrick Tassé
28 public class CustomXmlEvent
extends CustomEvent
{
31 * Constructor defining only the trace definition
36 public CustomXmlEvent(CustomXmlTraceDefinition definition
) {
41 * Build a custom trace event from an existing TmfEvent.
46 * Other TmfEvent to copy
48 public CustomXmlEvent(CustomXmlTraceDefinition definition
, @NonNull TmfEvent other
) {
49 super(definition
, other
);
60 * Timestamp of the event
64 public CustomXmlEvent(CustomXmlTraceDefinition definition
,
65 ITmfTrace parentTrace
, ITmfTimestamp timestamp
, TmfEventType type
) {
66 super(definition
, parentTrace
, timestamp
, type
);
70 public void setContent(ITmfEventField content
) {
71 super.setContent(content
);
79 * @param inputAction Input action
80 * @param inputFormat Input format
81 * @deprecated Use {@link #parseInput(String, Tag, String, int, String)} instead.
84 public void parseInput(String value
, String name
, int inputAction
, String inputFormat
) {
91 * @param inputTag Input tag
92 * @param inputName Input name
93 * @param inputAction Input action
94 * @param inputFormat Input format
97 public void parseInput(String value
, Tag inputTag
, String inputName
, int inputAction
, String inputFormat
) {
98 if (value
.length() == 0) {
101 Object key
= (inputTag
.equals(Tag
.OTHER
) ? inputName
: inputTag
);
102 if (inputAction
== CustomTraceDefinition
.ACTION_SET
) {
103 fData
.put(key
, value
);
104 if (key
.equals(Tag
.TIMESTAMP
)) {
105 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, inputFormat
);
107 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND
) {
108 String s
= fData
.get(key
);
110 fData
.put(key
, s
+ value
);
112 fData
.put(key
, value
);
114 if (key
.equals(Tag
.TIMESTAMP
)) {
115 String timeStampInputFormat
= fData
.get(Key
.TIMESTAMP_INPUT_FORMAT
);
116 if (timeStampInputFormat
!= null) {
117 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, timeStampInputFormat
+ inputFormat
);
119 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, inputFormat
);
122 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
123 String s
= fData
.get(key
);
125 fData
.put(key
, s
+ " | " + value
); //$NON-NLS-1$
127 fData
.put(key
, value
);
129 if (key
.equals(Tag
.TIMESTAMP
)) {
130 String timeStampInputFormat
= fData
.get(Key
.TIMESTAMP_INPUT_FORMAT
);
131 if (timeStampInputFormat
!= null) {
132 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, timeStampInputFormat
+ " | " + inputFormat
); //$NON-NLS-1$
134 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, inputFormat
);