1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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
.linuxtools
.tmf
.core
.parsers
.custom
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventType
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
22 * Trace event for custom XML traces.
24 * @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
, TmfEvent other
) {
49 super(definition
, other
);
60 * Timestamp of the event
66 * Reference of the event
68 public CustomXmlEvent(CustomXmlTraceDefinition definition
, ITmfTrace parentTrace
, ITmfTimestamp timestamp
, String source
, TmfEventType type
, String reference
) {
69 super(definition
, parentTrace
, timestamp
, source
, type
, reference
);
73 public void setContent(ITmfEventField content
) {
74 super.setContent(content
);
82 * @param inputAction Input action
83 * @param inputFormat Input format
85 public void parseInput(String value
, String name
, int inputAction
, String inputFormat
) {
86 if (value
.length() == 0) {
89 if (inputAction
== CustomTraceDefinition
.ACTION_SET
) {
90 fData
.put(name
, value
);
91 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
92 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);
94 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND
) {
95 String s
= fData
.get(name
);
97 fData
.put(name
, s
+ value
);
99 fData
.put(name
, value
);
101 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
102 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
103 if (timeStampInputFormat
!= null) {
104 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ inputFormat
);
106 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);
109 } else if (inputAction
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
110 String s
= fData
.get(name
);
112 fData
.put(name
, s
+ " | " + value
); //$NON-NLS-1$
114 fData
.put(name
, value
);
116 if (name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
117 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
118 if (timeStampInputFormat
!= null) {
119 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ " | " + inputFormat
); //$NON-NLS-1$
121 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, inputFormat
);