Commit | Line | Data |
---|---|---|
c3c5c786 FC |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2010 Ericsson\r | |
6256d8ad | 3 | *\r |
c3c5c786 FC |
4 | * All rights reserved. This program and the accompanying materials are\r |
5 | * made available under the terms of the Eclipse Public License v1.0 which\r | |
6 | * accompanies this distribution, and is available at\r | |
7 | * http://www.eclipse.org/legal/epl-v10.html\r | |
6256d8ad | 8 | *\r |
c3c5c786 FC |
9 | * Contributors:\r |
10 | * Patrick Tasse - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | \r | |
d34665f9 | 13 | package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r |
c3c5c786 | 14 | \r |
7b477cc3 | 15 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r |
c64aa527 | 16 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r |
6c13869b | 17 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r |
6c13869b | 18 | import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r |
6c13869b | 19 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r |
c3c5c786 FC |
20 | \r |
21 | public class CustomXmlEvent extends CustomEvent {\r | |
22 | \r | |
4bf17f4a | 23 | public CustomXmlEvent(CustomXmlTraceDefinition definition) {\r |
24 | super(definition);\r | |
7b477cc3 | 25 | setType(new CustomXmlEventType(definition));\r |
4bf17f4a | 26 | }\r |
27 | \r | |
c3c5c786 FC |
28 | public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {\r |
29 | super(definition, other);\r | |
30 | }\r | |
31 | \r | |
6256d8ad | 32 | public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {\r |
4bf17f4a | 33 | super(definition, parentTrace, timestamp, source, type, reference);\r |
c3c5c786 FC |
34 | }\r |
35 | \r | |
7b477cc3 FC |
36 | @Override\r |
37 | public void setContent(ITmfEventField content) {\r | |
de126dbb | 38 | super.setContent(content);\r |
7b477cc3 FC |
39 | }\r |
40 | \r | |
c3c5c786 FC |
41 | public void parseInput(String value, String name, int inputAction, String inputFormat) {\r |
42 | if (value.length() == 0) {\r | |
43 | return;\r | |
44 | }\r | |
45 | if (inputAction == CustomTraceDefinition.ACTION_SET) {\r | |
46 | fData.put(name, value);\r | |
47 | if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r | |
48 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);\r | |
49 | }\r | |
50 | } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {\r | |
51 | String s = fData.get(name);\r | |
52 | if (s != null) {\r | |
53 | fData.put(name, s + value);\r | |
54 | } else {\r | |
55 | fData.put(name, value);\r | |
56 | }\r | |
57 | if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r | |
58 | String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r | |
59 | if (timeStampInputFormat != null) {\r | |
60 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + inputFormat);\r | |
61 | } else {\r | |
62 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);\r | |
63 | }\r | |
64 | }\r | |
65 | } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r | |
66 | String s = fData.get(name);\r | |
67 | if (s != null) {\r | |
3b38ea61 | 68 | fData.put(name, s + " | " + value); //$NON-NLS-1$\r |
c3c5c786 FC |
69 | } else {\r |
70 | fData.put(name, value);\r | |
71 | }\r | |
72 | if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r | |
73 | String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r | |
74 | if (timeStampInputFormat != null) {\r | |
3b38ea61 | 75 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + inputFormat); //$NON-NLS-1$\r |
c3c5c786 FC |
76 | } else {\r |
77 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);\r | |
78 | }\r | |
79 | }\r | |
80 | }\r | |
81 | }\r | |
82 | \r | |
83 | }\r |