tmf: Move TmfTraceType and custom parsers to tmf.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / parsers / custom / CustomTraceDefinition.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 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.core.parsers.custom;
14
15 import java.text.SimpleDateFormat;
16 import java.util.List;
17
18 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
19
20 /**
21 * Base class for custom trace definitions.
22 *
23 * @author Patrick Tassé
24 * @since 3.0
25 */
26 public abstract class CustomTraceDefinition {
27
28 /** "set" action */
29 public static final int ACTION_SET = 0;
30
31 /** "append" action */
32 public static final int ACTION_APPEND = 1;
33
34 /** "append with separator" action */
35 public static final int ACTION_APPEND_WITH_SEPARATOR = 2;
36
37 /** Timestamp tag */
38 public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag;
39
40 /** Message tag */
41 public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag;
42
43 /** "Other" tag */
44 public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag;
45
46 /** Name of this trace definition */
47 public String definitionName;
48
49 /** List of output columns */
50 public List<OutputColumn> outputs;
51
52 /** Timestamp format */
53 public String timeStampOutputFormat;
54
55 /**
56 * Definition of an output column
57 */
58 public static class OutputColumn {
59
60 /** Name of this column */
61 public String name;
62
63 /**
64 * Default constructor (empty)
65 */
66 public OutputColumn() {}
67
68 /**
69 * Constructor
70 *
71 * @param name Name of this output column
72 */
73 public OutputColumn(String name) {
74 this.name = name;
75 }
76
77 @Override
78 public String toString() {
79 return name;
80 }
81 }
82
83 /**
84 * Format a timestamp in this trace's current time stamp format.
85 *
86 * @param timestamp
87 * The timestamp to format
88 * @return The same timestamp as a formatted string
89 */
90 public String formatTimeStamp(TmfTimestamp timestamp) {
91 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat);
92 return simpleDateFormat.format(timestamp.getValue());
93 }
94
95 /**
96 * Save this custom trace in the default path.
97 */
98 public abstract void save();
99
100 /**
101 * Save this custom trace in the supplied path.
102 *
103 * @param path
104 * The path to save to
105 */
106 public abstract void save(String path);
107 }
This page took 0.036607 seconds and 5 git commands to generate.