Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
c8422608 | 2 | * Copyright (c) 2010, 2013 Ericsson |
be222f56 PT |
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 java.text.SimpleDateFormat; | |
16 | import java.util.List; | |
17 | ||
18 | import org.eclipse.linuxtools.internal.tmf.ui.Messages; | |
3bd46eef | 19 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; |
be222f56 | 20 | |
a0a88f65 AM |
21 | /** |
22 | * Base class for custom trace definitions. | |
23 | * | |
24 | * @author Patrick Tassé | |
25 | */ | |
be222f56 PT |
26 | public abstract class CustomTraceDefinition { |
27 | ||
a0a88f65 | 28 | /** "set" action */ |
be222f56 | 29 | public static final int ACTION_SET = 0; |
a0a88f65 AM |
30 | |
31 | /** "append" action */ | |
be222f56 | 32 | public static final int ACTION_APPEND = 1; |
a0a88f65 AM |
33 | |
34 | /** "append with separator" action */ | |
be222f56 PT |
35 | public static final int ACTION_APPEND_WITH_SEPARATOR = 2; |
36 | ||
a0a88f65 | 37 | /** Timestamp tag */ |
be222f56 | 38 | public static final String TAG_TIMESTAMP = Messages.CustomTraceDefinition_timestampTag; |
a0a88f65 AM |
39 | |
40 | /** Message tag */ | |
be222f56 | 41 | public static final String TAG_MESSAGE = Messages.CustomTraceDefinition_messageTag; |
a0a88f65 AM |
42 | |
43 | /** "Other" tag */ | |
be222f56 PT |
44 | public static final String TAG_OTHER = Messages.CustomTraceDefinition_otherTag; |
45 | ||
a0a88f65 | 46 | /** Name of this trace definition */ |
be222f56 | 47 | public String definitionName; |
a0a88f65 AM |
48 | |
49 | /** List of output columns */ | |
be222f56 | 50 | public List<OutputColumn> outputs; |
a0a88f65 AM |
51 | |
52 | /** Timestamp format */ | |
be222f56 PT |
53 | public String timeStampOutputFormat; |
54 | ||
a0a88f65 AM |
55 | /** |
56 | * Definition of an output column | |
57 | */ | |
be222f56 | 58 | public static class OutputColumn { |
a0a88f65 AM |
59 | |
60 | /** Name of this column */ | |
be222f56 PT |
61 | public String name; |
62 | ||
a0a88f65 AM |
63 | /** |
64 | * Default constructor (empty) | |
65 | */ | |
be222f56 PT |
66 | public OutputColumn() {} |
67 | ||
a0a88f65 AM |
68 | /** |
69 | * Constructor | |
70 | * | |
71 | * @param name Name of this output column | |
72 | */ | |
be222f56 PT |
73 | public OutputColumn(String name) { |
74 | this.name = name; | |
75 | } | |
76 | ||
77 | @Override | |
78 | public String toString() { | |
79 | return name; | |
80 | } | |
81 | } | |
82 | ||
a0a88f65 AM |
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 | */ | |
be222f56 PT |
90 | public String formatTimeStamp(TmfTimestamp timestamp) { |
91 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(timeStampOutputFormat); | |
92 | return simpleDateFormat.format(timestamp.getValue()); | |
93 | } | |
94 | ||
a0a88f65 AM |
95 | /** |
96 | * Save this custom trace in the default path. | |
97 | */ | |
be222f56 | 98 | public abstract void save(); |
a0a88f65 AM |
99 | |
100 | /** | |
101 | * Save this custom trace in the supplied path. | |
102 | * | |
103 | * @param path | |
104 | * The path to save to | |
105 | */ | |
be222f56 PT |
106 | public abstract void save(String path); |
107 | } |