~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomXmlEvent.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.internal.tmf.ui.parsers.custom;
14
 
 
15
 
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
16
 
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
17
 
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
18
 
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
19
 
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
20
 
 
21
 
public class CustomXmlEvent extends CustomEvent {
22
 
 
23
 
    public CustomXmlEvent(CustomXmlTraceDefinition definition) {
24
 
        super(definition);
25
 
        setType(new CustomXmlEventType(definition));
26
 
    }
27
 
 
28
 
    public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {
29
 
        super(definition, other);
30
 
    }
31
 
 
32
 
    public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
33
 
        super(definition, parentTrace, timestamp, source, type, reference);
34
 
    }
35
 
 
36
 
    @Override
37
 
    public void setContent(ITmfEventField content) {
38
 
        super.setContent(content);
39
 
    }
40
 
 
41
 
    public void parseInput(String value, String name, int inputAction, String inputFormat) {
42
 
        if (value.length() == 0) {
43
 
            return;
44
 
        }
45
 
        if (inputAction == CustomTraceDefinition.ACTION_SET) {
46
 
            fData.put(name, value);
47
 
            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
48
 
                fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
49
 
            }
50
 
        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {
51
 
            String s = fData.get(name);
52
 
            if (s != null) {
53
 
                fData.put(name, s + value);
54
 
            } else {
55
 
                fData.put(name, value);
56
 
            }
57
 
            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
58
 
                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
59
 
                if (timeStampInputFormat != null) {
60
 
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + inputFormat);
61
 
                } else {
62
 
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
63
 
                }
64
 
            }
65
 
        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
66
 
            String s = fData.get(name);
67
 
            if (s != null) {
68
 
                fData.put(name, s + " | " + value); //$NON-NLS-1$
69
 
            } else {
70
 
                fData.put(name, value);
71
 
            }
72
 
            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
73
 
                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
74
 
                if (timeStampInputFormat != null) {
75
 
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + inputFormat); //$NON-NLS-1$
76
 
                } else {
77
 
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
78
 
                }
79
 
            }
80
 
        }
81
 
    }
82
 
 
83
 
}
 
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.internal.tmf.ui.parsers.custom;
 
14
 
 
15
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
 
16
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 
17
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 
18
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 
19
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 
20
 
 
21
public class CustomXmlEvent extends CustomEvent {
 
22
 
 
23
    public CustomXmlEvent(CustomXmlTraceDefinition definition) {
 
24
        super(definition);
 
25
        setType(new CustomXmlEventType(definition));
 
26
    }
 
27
 
 
28
    public CustomXmlEvent(CustomXmlTraceDefinition definition, TmfEvent other) {
 
29
        super(definition, other);
 
30
    }
 
31
 
 
32
    public CustomXmlEvent(CustomXmlTraceDefinition definition, ITmfTrace<?> parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
 
33
        super(definition, parentTrace, timestamp, source, type, reference);
 
34
    }
 
35
 
 
36
    @Override
 
37
    public void setContent(ITmfEventField content) {
 
38
        super.setContent(content);
 
39
    }
 
40
 
 
41
    public void parseInput(String value, String name, int inputAction, String inputFormat) {
 
42
        if (value.length() == 0) {
 
43
            return;
 
44
        }
 
45
        if (inputAction == CustomTraceDefinition.ACTION_SET) {
 
46
            fData.put(name, value);
 
47
            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
 
48
                fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
 
49
            }
 
50
        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND) {
 
51
            String s = fData.get(name);
 
52
            if (s != null) {
 
53
                fData.put(name, s + value);
 
54
            } else {
 
55
                fData.put(name, value);
 
56
            }
 
57
            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
 
58
                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
 
59
                if (timeStampInputFormat != null) {
 
60
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + inputFormat);
 
61
                } else {
 
62
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
 
63
                }
 
64
            }
 
65
        } else if (inputAction == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
 
66
            String s = fData.get(name);
 
67
            if (s != null) {
 
68
                fData.put(name, s + " | " + value); //$NON-NLS-1$
 
69
            } else {
 
70
                fData.put(name, value);
 
71
            }
 
72
            if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
 
73
                String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
 
74
                if (timeStampInputFormat != null) {
 
75
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + inputFormat); //$NON-NLS-1$
 
76
                } else {
 
77
                    fData.put(TIMESTAMP_INPUT_FORMAT_KEY, inputFormat);
 
78
                }
 
79
            }
 
80
        }
 
81
    }
 
82
 
 
83
}