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
{
30 private String fLastExtraFieldName
= null;
33 * Constructor defining only the trace definition
38 public CustomXmlEvent(CustomXmlTraceDefinition definition
) {
43 * Build a custom trace event from an existing TmfEvent.
48 * Other TmfEvent to copy
50 public CustomXmlEvent(CustomXmlTraceDefinition definition
, @NonNull TmfEvent other
) {
51 super(definition
, other
);
62 * Timestamp of the event
66 public CustomXmlEvent(CustomXmlTraceDefinition definition
,
67 ITmfTrace parentTrace
, ITmfTimestamp timestamp
, TmfEventType type
) {
68 super(definition
, parentTrace
, timestamp
, type
);
72 public void setContent(ITmfEventField content
) {
73 super.setContent(content
);
81 * @param inputAction Input action
82 * @param inputFormat Input format
83 * @deprecated Use {@link #parseInput(String, Tag, String, int, String)} instead.
86 public void parseInput(String value
, String name
, int inputAction
, String inputFormat
) {
93 * @param inputTag Input tag
94 * @param inputName Input name
95 * @param inputAction Input action
96 * @param inputFormat Input format
99 public void parseInput(String value
, Tag inputTag
, String inputName
, int inputAction
, String inputFormat
) {
100 if (value
.length() == 0) {
103 Object key
= (inputTag
.equals(Tag
.OTHER
) ? inputName
: inputTag
);
104 if (key
.equals(Tag
.EXTRA_FIELD_NAME
)) {
105 // If tag extra field name, save the extra field name for
106 // the next extra field value and add the field to the map
107 fLastExtraFieldName
= value
;
108 if (!fData
.containsKey(value
)) {
109 fData
.put(value
, null);
112 } else if (key
.equals(Tag
.EXTRA_FIELD_VALUE
)) {
113 // If tag extra field value, use the extra field name as key
114 if (fLastExtraFieldName
== null) {
117 key
= fLastExtraFieldName
;
119 if (inputAction
== CustomTraceDefinition
.ACTION_SET
) {
120 fData
.put(key
, value
);
121 if (key
.equals(Tag
.TIMESTAMP
)) {
122 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, inputFormat
);
124 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND
) {
125 String s
= fData
.get(key
);
127 fData
.put(key
, s
+ value
);
129 fData
.put(key
, value
);
131 if (key
.equals(Tag
.TIMESTAMP
)) {
132 String timeStampInputFormat
= fData
.get(Key
.TIMESTAMP_INPUT_FORMAT
);
133 if (timeStampInputFormat
!= null) {
134 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, timeStampInputFormat
+ inputFormat
);
136 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, inputFormat
);
139 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
140 String s
= fData
.get(key
);
142 fData
.put(key
, s
+ CustomTraceDefinition
.SEPARATOR
+ value
);
144 fData
.put(key
, value
);
146 if (key
.equals(Tag
.TIMESTAMP
)) {
147 String timeStampInputFormat
= fData
.get(Key
.TIMESTAMP_INPUT_FORMAT
);
148 if (timeStampInputFormat
!= null) {
149 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, timeStampInputFormat
+ " | " + inputFormat
); //$NON-NLS-1$
151 fData
.put(Key
.TIMESTAMP_INPUT_FORMAT
, inputFormat
);