Commit | Line | Data |
---|---|---|
8c8bf09f ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 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: | |
1f506a43 | 10 | * Francois Chouinard - Initial API and implementation |
8c8bf09f ASL |
11 | *******************************************************************************/ |
12 | ||
13 | package org.eclipse.linuxtools.tmf.event; | |
14 | ||
15 | /** | |
16 | * <b><u>TmfEvent</u></b> | |
17 | * <p> | |
1f506a43 | 18 | * The basic event structure in the TMF. In its canonical form, an event has: |
8c8bf09f ASL |
19 | * <ul> |
20 | * <li> a normalized timestamp | |
21 | * <li> a source (reporter) | |
22 | * <li> a type | |
23 | * <li> a content | |
24 | * </ul> | |
25 | * For convenience, a free-form reference field is also provided. It could be | |
26 | * used as e.g. a location marker in the event stream to distinguish between | |
27 | * otherwise identical events. | |
8c8bf09f | 28 | */ |
0ab46cd3 | 29 | public class TmfEvent extends TmfData { |
8c8bf09f | 30 | |
4ab33d2b | 31 | // ======================================================================== |
8c8bf09f | 32 | // Attributes |
4ab33d2b | 33 | // ======================================================================== |
8c8bf09f | 34 | |
1f506a43 FC |
35 | private final TmfTimestamp fEffectiveTimestamp; |
36 | private final TmfTimestamp fOriginalTimestamp; | |
4ab33d2b AO |
37 | private final TmfEventSource fSource; |
38 | private final TmfEventType fType; | |
39 | private final TmfEventContent fContent; | |
40 | private final TmfEventReference fReference; | |
8c8bf09f | 41 | |
4ab33d2b | 42 | // ======================================================================== |
8c8bf09f | 43 | // Constructors |
4ab33d2b | 44 | // ======================================================================== |
8c8bf09f ASL |
45 | |
46 | /** | |
4ab33d2b AO |
47 | * @param timestamp |
48 | * @param source | |
49 | * @param type | |
50 | * @param content | |
51 | * @param reference | |
8c8bf09f | 52 | */ |
1f506a43 FC |
53 | public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, |
54 | TmfEventType type, TmfEventContent content, TmfEventReference reference) | |
8c8bf09f | 55 | { |
1f506a43 FC |
56 | fOriginalTimestamp = originalTS; |
57 | fEffectiveTimestamp = effectiveTS; | |
58 | fSource = source; | |
59 | fType = type; | |
60 | fContent = content; | |
61 | fReference = reference; | |
62 | } | |
63 | ||
64 | /** | |
65 | * @param timestamp | |
66 | * @param source | |
67 | * @param type | |
68 | * @param content | |
69 | * @param reference | |
70 | */ | |
71 | public TmfEvent(TmfTimestamp timestamp, TmfEventSource source, | |
72 | TmfEventType type, TmfEventContent content, TmfEventReference reference) | |
73 | { | |
4e3aa37d FC |
74 | this(timestamp, timestamp, source, type, content, reference); |
75 | } | |
76 | ||
77 | /** | |
78 | */ | |
79 | public TmfEvent(TmfEvent other) | |
80 | { | |
81 | this(other.fOriginalTimestamp, other.fEffectiveTimestamp, other.fSource, | |
82 | other.fType, other.fContent, other.fReference); | |
8c8bf09f ASL |
83 | } |
84 | ||
4ab33d2b | 85 | // ======================================================================== |
8c8bf09f | 86 | // Accessors |
4ab33d2b | 87 | // ======================================================================== |
8c8bf09f ASL |
88 | |
89 | /** | |
4ab33d2b | 90 | * @return |
8c8bf09f ASL |
91 | */ |
92 | public TmfTimestamp getTimestamp() { | |
1f506a43 FC |
93 | return fEffectiveTimestamp; |
94 | } | |
95 | ||
96 | /** | |
97 | * @return | |
98 | */ | |
99 | public TmfTimestamp getOriginalTimestamp() { | |
100 | return fOriginalTimestamp; | |
8c8bf09f ASL |
101 | } |
102 | ||
103 | /** | |
4ab33d2b | 104 | * @return |
8c8bf09f ASL |
105 | */ |
106 | public TmfEventSource getSource() { | |
107 | return fSource; | |
108 | } | |
109 | ||
110 | /** | |
4ab33d2b | 111 | * @return |
8c8bf09f ASL |
112 | */ |
113 | public TmfEventType getType() { | |
114 | return fType; | |
115 | } | |
116 | ||
117 | /** | |
4ab33d2b | 118 | * @return |
8c8bf09f ASL |
119 | */ |
120 | public TmfEventContent getContent() { | |
121 | return fContent; | |
122 | } | |
123 | ||
124 | /** | |
4ab33d2b | 125 | * @return |
8c8bf09f ASL |
126 | */ |
127 | public TmfEventReference getReference() { | |
128 | return fReference; | |
129 | } | |
1f506a43 | 130 | |
4e3aa37d FC |
131 | // TODO: Design a proper format... |
132 | @Override | |
133 | public String toString() { | |
134 | return fEffectiveTimestamp.toString(); | |
135 | } | |
8c8bf09f | 136 | } |