Commit | Line | Data |
---|---|---|
c3c5c786 FC |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2010 Ericsson\r | |
3 | * \r | |
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 | |
8 | * \r | |
9 | * Contributors:\r | |
10 | * Patrick Tasse - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | \r | |
13 | package org.eclipse.linuxtools.tmf.ui.parsers.custom;\r | |
14 | \r | |
15 | import java.util.regex.Matcher;\r | |
16 | \r | |
17 | import org.eclipse.linuxtools.tmf.event.TmfEvent;\r | |
18 | import org.eclipse.linuxtools.tmf.event.TmfEventReference;\r | |
19 | import org.eclipse.linuxtools.tmf.event.TmfEventSource;\r | |
20 | import org.eclipse.linuxtools.tmf.event.TmfEventType;\r | |
21 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp;\r | |
4bf17f4a | 22 | import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r |
c3c5c786 FC |
23 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;\r |
24 | import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r | |
25 | \r | |
26 | public class CustomTxtEvent extends CustomEvent {\r | |
27 | \r | |
4bf17f4a | 28 | public CustomTxtEvent(CustomTxtTraceDefinition definition) {\r |
29 | super(definition);\r | |
30 | fType = new CustomTxtEventType(definition);\r | |
31 | }\r | |
32 | \r | |
c3c5c786 FC |
33 | public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {\r |
34 | super(definition, other);\r | |
35 | }\r | |
36 | \r | |
4bf17f4a | 37 | public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace<?> parentTrace, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) {\r |
38 | super(definition, parentTrace, timestamp, source, type, reference);\r | |
c3c5c786 FC |
39 | }\r |
40 | \r | |
41 | public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) {\r | |
42 | super(definition, originalTS, effectiveTS, source, type, reference);\r | |
43 | }\r | |
44 | \r | |
45 | public void processGroups(InputLine input, Matcher matcher) {\r | |
d7fcacc9 FC |
46 | if (input.columns == null) {\r |
47 | return;\r | |
48 | }\r | |
c3c5c786 FC |
49 | for (int i = 0; i < input.columns.size(); i++) {\r |
50 | InputData column = input.columns.get(i);\r | |
51 | if (i < matcher.groupCount() && matcher.group(i + 1) != null) {\r | |
52 | String value = matcher.group(i + 1).trim();\r | |
53 | if (value.length() == 0) {\r | |
54 | continue;\r | |
55 | }\r | |
56 | String name = column.name;\r | |
57 | if (column.action == CustomTxtTraceDefinition.ACTION_SET) {\r | |
58 | fData.put(name, value);\r | |
59 | if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r | |
60 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r | |
61 | }\r | |
62 | } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) {\r | |
63 | String s = fData.get(name);\r | |
64 | if (s != null) {\r | |
65 | fData.put(name, s + value);\r | |
66 | } else {\r | |
67 | fData.put(name, value);\r | |
68 | }\r | |
69 | if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r | |
70 | String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r | |
71 | if (timeStampInputFormat != null) {\r | |
72 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format);\r | |
73 | } else {\r | |
74 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r | |
75 | }\r | |
76 | }\r | |
77 | } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r | |
78 | String s = fData.get(name);\r | |
79 | if (s != null) {\r | |
3b38ea61 | 80 | fData.put(name, s + " | " + value); //$NON-NLS-1$\r |
c3c5c786 FC |
81 | } else {\r |
82 | fData.put(name, value);\r | |
83 | }\r | |
84 | if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r | |
85 | String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r | |
86 | if (timeStampInputFormat != null) {\r | |
3b38ea61 | 87 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$\r |
c3c5c786 FC |
88 | } else {\r |
89 | fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r | |
90 | }\r | |
91 | }\r | |
92 | }\r | |
93 | }\r | |
94 | }\r | |
95 | }\r | |
96 | \r | |
97 | }\r |