2010-11-09 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug315307
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / parsers / custom / CustomXmlEvent.java
1 /*******************************************************************************
2 * Copyright (c) 2010 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.linuxtools.tmf.ui.parsers.custom;
14
15 import org.eclipse.linuxtools.tmf.event.TmfEvent;
16 import org.eclipse.linuxtools.tmf.event.TmfEventReference;
17 import org.eclipse.linuxtools.tmf.event.TmfEventSource;
18 import org.eclipse.linuxtools.tmf.event.TmfEventType;
19 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
20
21 public class CustomXmlEvent extends CustomEvent {
22
23 public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {
24 super(definition, other);
25 }
26
27 public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) {
28 super(definition, timestamp, source, type, reference);
29 }
30
31 public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) {
32 super(definition, originalTS, effectiveTS, source, type, reference);
33 }
34
35 public void parseInput(String value, String name, int inputAction, String inputFormat) {
36 if (value.length() == 0) {
37 return;
38 }
39 if (inputAction == CustomTraceDefinition.ACTION_SET) {
40 fData.put(name, value);
41 if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
42 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
43 }
44 } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {
45 String s = fData.get(name);
46 if (s != null) {
47 fData.put(name, s + value);
48 } else {
49 fData.put(name, value);
50 }
51 if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
52 String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
53 if (timeStampInputFormat != null) {
54 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + inputFormat);
55 } else {
56 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
57 }
58 }
59 } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
60 String s = fData.get(name);
61 if (s != null) {
62 fData.put(name, s + " | " + value); //$NON-NLS-1$
63 } else {
64 fData.put(name, value);
65 }
66 if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
67 String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
68 if (timeStampInputFormat != null) {
69 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + inputFormat); //$NON-NLS-1$
70 } else {
71 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
72 }
73 }
74 }
75 }
76
77 }
This page took 0.03435 seconds and 6 git commands to generate.