3322554f3e0454779110767df7856f49b7f04000
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / parsers / custom / CustomXmlEvent.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2016 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.parsers.custom;
14
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;
22
23 /**
24 * Trace event for custom XML traces.
25 *
26 * @author Patrick Tassé
27 */
28 public class CustomXmlEvent extends CustomEvent {
29
30 /**
31 * Constructor defining only the trace definition
32 *
33 * @param definition
34 * Trace definition
35 */
36 public CustomXmlEvent(CustomXmlTraceDefinition definition) {
37 super(definition);
38 }
39
40 /**
41 * Build a custom trace event from an existing TmfEvent.
42 *
43 * @param definition
44 * Trace definition
45 * @param other
46 * Other TmfEvent to copy
47 */
48 public CustomXmlEvent(CustomXmlTraceDefinition definition, @NonNull TmfEvent other) {
49 super(definition, other);
50 }
51
52 /**
53 * Full constructor
54 *
55 * @param definition
56 * Trace definition
57 * @param parentTrace
58 * Parent trace object
59 * @param timestamp
60 * Timestamp of the event
61 * @param type
62 * Event type
63 */
64 public CustomXmlEvent(CustomXmlTraceDefinition definition,
65 ITmfTrace parentTrace, ITmfTimestamp timestamp, TmfEventType type) {
66 super(definition, parentTrace, timestamp, type);
67 }
68
69 @Override
70 public void setContent(ITmfEventField content) {
71 super.setContent(content);
72 }
73
74 /**
75 * Parse an entry.
76 *
77 * @param value Value
78 * @param name Name
79 * @param inputAction Input action
80 * @param inputFormat Input format
81 * @deprecated Use {@link #parseInput(String, Tag, String, int, String)} instead.
82 */
83 @Deprecated
84 public void parseInput(String value, String name, int inputAction, String inputFormat) {
85 }
86
87 /**
88 * Parse an entry.
89 *
90 * @param value Value
91 * @param inputTag Input tag
92 * @param inputName Input name
93 * @param inputAction Input action
94 * @param inputFormat Input format
95 * @since 2.1
96 */
97 public void parseInput(String value, Tag inputTag, String inputName, int inputAction, String inputFormat) {
98 if (value.length() == 0) {
99 return;
100 }
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);
106 }
107 } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {
108 String s = fData.get(key);
109 if (s != null) {
110 fData.put(key, s + value);
111 } else {
112 fData.put(key, value);
113 }
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);
118 } else {
119 fData.put(Key.TIMESTAMP_INPUT_FORMAT, inputFormat);
120 }
121 }
122 } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
123 String s = fData.get(key);
124 if (s != null) {
125 fData.put(key, s + " | " + value); //$NON-NLS-1$
126 } else {
127 fData.put(key, value);
128 }
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$
133 } else {
134 fData.put(Key.TIMESTAMP_INPUT_FORMAT, inputFormat);
135 }
136 }
137 }
138 }
139
140 }
This page took 0.033564 seconds and 4 git commands to generate.