1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 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
) {
37 setType(new CustomXmlEventType(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
82 public void parseInput(String value
, String name
, int inputAction
, String inputFormat
) {
83 if (value
.length() == 0) {
86 if (inputAction
== CustomTraceDefinition
.ACTION_SET
) {
87 fData
.put(name
, value
);
88 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
89 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);
91 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND
) {
92 String s
= fData
.get(name
);
94 fData
.put(name
, s
+ value
);
96 fData
.put(name
, value
);
98 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
99 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
100 if (timeStampInputFormat
!= null) {
101 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ inputFormat
);
103 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);
106 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
107 String s
= fData
.get(name
);
109 fData
.put(name
, s
+ " | " + value
); //$NON-NLS-1$
111 fData
.put(name
, value
);
113 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
114 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
115 if (timeStampInputFormat
!= null) {
116 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ " | " + inputFormat
); //$NON-NLS-1$
118 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);