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
.timestamp
.ITmfTimestamp
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
23 * Trace event for custom XML traces.
25 * @author Patrick Tassé
27 public class CustomXmlEvent
extends CustomEvent
{
30 * Constructor defining only the trace definition
35 public CustomXmlEvent(CustomXmlTraceDefinition definition
) {
40 * Build a custom trace event from an existing TmfEvent.
45 * Other TmfEvent to copy
47 public CustomXmlEvent(CustomXmlTraceDefinition definition
, @NonNull TmfEvent other
) {
48 super(definition
, other
);
59 * Timestamp of the event
63 public CustomXmlEvent(CustomXmlTraceDefinition definition
,
64 ITmfTrace parentTrace
, ITmfTimestamp timestamp
, TmfEventType type
) {
65 super(definition
, parentTrace
, timestamp
, type
);
69 public void setContent(ITmfEventField content
) {
70 super.setContent(content
);
78 * @param inputAction Input action
79 * @param inputFormat Input format
81 public void parseInput(String value
, String name
, int inputAction
, String inputFormat
) {
82 if (value
.length() == 0) {
85 if (inputAction
== CustomTraceDefinition
.ACTION_SET
) {
86 fData
.put(name
, value
);
87 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
88 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);
90 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND
) {
91 String s
= fData
.get(name
);
93 fData
.put(name
, s
+ value
);
95 fData
.put(name
, value
);
97 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
98 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
99 if (timeStampInputFormat
!= null) {
100 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ inputFormat
);
102 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);
105 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
106 String s
= fData
.get(name
);
108 fData
.put(name
, s
+ " | " + value
); //$NON-NLS-1$
110 fData
.put(name
, value
);
112 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
113 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
114 if (timeStampInputFormat
!= null) {
115 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ " | " + inputFormat
); //$NON-NLS-1$
117 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);