Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 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 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b | 13 | |
115b4a01 BH |
14 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo; |
15 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType; | |
16 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel; | |
eb1bab5b BH |
17 | |
18 | /** | |
19 | * <b><u>BaseEventInfo</u></b> | |
20 | * <p> | |
21 | * Implementation of the basic trace event interface (IEventInfo) to store event | |
22 | * related data. | |
23 | * </p> | |
24 | */ | |
25 | public class BaseEventInfo extends TraceInfo implements IBaseEventInfo { | |
26 | ||
27 | // ------------------------------------------------------------------------ | |
28 | // Attributes | |
29 | // ------------------------------------------------------------------------ | |
30 | /** | |
31 | * The trace event type. | |
32 | */ | |
33 | private TraceEventType fEventType = TraceEventType.UNKNOWN; | |
34 | /** | |
35 | * The trace log level. | |
36 | */ | |
4775bcbf | 37 | private TraceLogLevel fLogLevel = TraceLogLevel.TRACE_DEBUG; |
eb1bab5b BH |
38 | |
39 | // ------------------------------------------------------------------------ | |
40 | // Constructors | |
41 | // ------------------------------------------------------------------------ | |
42 | /** | |
43 | * Constructor | |
44 | * @param name - name of base event | |
45 | */ | |
46 | public BaseEventInfo(String name) { | |
47 | super(name); | |
48 | } | |
49 | ||
50 | /** | |
51 | * Copy constructor | |
52 | * @param other - the instance to copy | |
53 | */ | |
54 | public BaseEventInfo(BaseEventInfo other) { | |
55 | super(other); | |
56 | fEventType = other.fEventType; | |
57 | } | |
58 | ||
59 | // ------------------------------------------------------------------------ | |
60 | // Accessors | |
61 | // ------------------------------------------------------------------------ | |
62 | /* | |
63 | * (non-Javadoc) | |
115b4a01 | 64 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#getEventType() |
eb1bab5b BH |
65 | */ |
66 | @Override | |
67 | public TraceEventType getEventType() { | |
68 | return fEventType; | |
69 | } | |
70 | ||
71 | /* | |
72 | * (non-Javadoc) | |
115b4a01 | 73 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setEventType(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType) |
eb1bab5b BH |
74 | */ |
75 | @Override | |
76 | public void setEventType(TraceEventType type) { | |
77 | fEventType = type; | |
78 | } | |
79 | ||
80 | /* | |
81 | * (non-Javadoc) | |
115b4a01 | 82 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setEventType(java.lang.String) |
eb1bab5b BH |
83 | */ |
84 | @Override | |
85 | public void setEventType(String typeName) { | |
86 | if(TraceEventType.TRACEPOINT.getInName().equals(typeName)) { | |
87 | fEventType = TraceEventType.TRACEPOINT; | |
3e91c9c0 BH |
88 | } else if(TraceEventType.SYSCALL.getInName().equals(typeName)) { |
89 | fEventType = TraceEventType.SYSCALL; | |
ccc66d01 BH |
90 | } else if (TraceEventType.PROBE.getInName().equals(typeName)) { |
91 | fEventType = TraceEventType.PROBE; | |
92 | } else { | |
eb1bab5b BH |
93 | fEventType = TraceEventType.UNKNOWN; |
94 | } | |
95 | } | |
96 | ||
97 | /* | |
98 | * (non-Javadoc) | |
115b4a01 | 99 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#getLogLevel() |
eb1bab5b BH |
100 | */ |
101 | @Override | |
102 | public TraceLogLevel getLogLevel() { | |
103 | return fLogLevel; | |
104 | } | |
105 | ||
106 | /* | |
107 | * (non-Javadoc) | |
115b4a01 | 108 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel) |
eb1bab5b BH |
109 | */ |
110 | @Override | |
111 | public void setLogLevel(TraceLogLevel level) { | |
112 | fLogLevel = level; | |
113 | } | |
114 | ||
115 | /* | |
116 | * (non-Javadoc) | |
115b4a01 | 117 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo#setLogLevel(java.lang.String) |
eb1bab5b BH |
118 | */ |
119 | @Override | |
120 | public void setLogLevel(String levelName) { | |
121 | if(TraceLogLevel.TRACE_EMERG.getInName().equals(levelName)) { | |
122 | fLogLevel = TraceLogLevel.TRACE_EMERG; | |
123 | } else if(TraceLogLevel.TRACE_ALERT.getInName().equals(levelName)) { | |
124 | fLogLevel = TraceLogLevel.TRACE_ALERT; | |
125 | } else if(TraceLogLevel.TRACE_CRIT.getInName().equals(levelName)) { | |
126 | fLogLevel = TraceLogLevel.TRACE_CRIT; | |
127 | } else if(TraceLogLevel.TRACE_ERR.getInName().equals(levelName)) { | |
128 | fLogLevel = TraceLogLevel.TRACE_ERR; | |
129 | } else if(TraceLogLevel.TRACE_WARNING.getInName().equals(levelName)) { | |
130 | fLogLevel = TraceLogLevel.TRACE_WARNING; | |
131 | } else if(TraceLogLevel.TRACE_NOTICE.getInName().equals(levelName)) { | |
132 | fLogLevel = TraceLogLevel.TRACE_NOTICE; | |
133 | } else if(TraceLogLevel.TRACE_INFO.getInName().equals(levelName)) { | |
134 | fLogLevel = TraceLogLevel.TRACE_INFO; | |
4775bcbf BH |
135 | } else if(TraceLogLevel.TRACE_DEBUG_SYSTEM.getInName().equals(levelName)) { |
136 | fLogLevel = TraceLogLevel.TRACE_DEBUG_SYSTEM; | |
137 | } else if(TraceLogLevel.TRACE_DEBUG_PROGRAM.getInName().equals(levelName)) { | |
138 | fLogLevel = TraceLogLevel.TRACE_DEBUG_PROGRAM; | |
139 | } else if(TraceLogLevel.TRACE_DEBUG_PROCESS.getInName().equals(levelName)) { | |
140 | fLogLevel = TraceLogLevel.TRACE_DEBUG_PROCESS; | |
141 | } else if(TraceLogLevel.TRACE_DEBUG_MODULE.getInName().equals(levelName)) { | |
142 | fLogLevel = TraceLogLevel.TRACE_DEBUG_MODULE; | |
143 | } else if(TraceLogLevel.TRACE_DEBUG_UNIT.getInName().equals(levelName)) { | |
144 | fLogLevel = TraceLogLevel.TRACE_DEBUG_UNIT; | |
145 | } else if(TraceLogLevel.TRACE_DEBUG_FUNCTION.getInName().equals(levelName)) { | |
146 | fLogLevel = TraceLogLevel.TRACE_DEBUG_FUNCTION; | |
147 | } else if(TraceLogLevel.TRACE_DEBUG_LINE.getInName().equals(levelName)) { | |
148 | fLogLevel = TraceLogLevel.TRACE_DEBUG_LINE; | |
eb1bab5b BH |
149 | } else if(TraceLogLevel.TRACE_DEBUG.getInName().equals(levelName)) { |
150 | fLogLevel = TraceLogLevel.TRACE_DEBUG; | |
4775bcbf BH |
151 | } else if(TraceLogLevel.LEVEL_UNKNOWN.getInName().equals(levelName)) { |
152 | fLogLevel = TraceLogLevel.LEVEL_UNKNOWN; | |
eb1bab5b | 153 | } else { |
4775bcbf | 154 | fLogLevel = TraceLogLevel.TRACE_DEBUG; |
eb1bab5b BH |
155 | } |
156 | } | |
157 | ||
d132bcc7 BH |
158 | /* |
159 | * (non-Javadoc) | |
115b4a01 | 160 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString() |
d132bcc7 BH |
161 | */ |
162 | @SuppressWarnings("nls") | |
163 | @Override | |
164 | public String formatString() { | |
165 | StringBuffer output = new StringBuffer(); | |
166 | // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)"); | |
167 | output.append("\n "); | |
168 | output.append(getName()); | |
169 | if (fLogLevel != TraceLogLevel.LEVEL_UNKNOWN) { | |
170 | output.append(" (loglevel: "); | |
171 | output.append(fLogLevel.getInName()); | |
172 | output.append(" ("); | |
173 | output.append(fLogLevel.ordinal()); | |
174 | output.append("))"); | |
175 | } | |
176 | output.append(" (type: "); | |
177 | output.append(fEventType.getInName()); | |
178 | output.append(")"); | |
179 | return output.toString(); | |
180 | } | |
181 | ||
eb1bab5b BH |
182 | /* |
183 | * (non-Javadoc) | |
115b4a01 | 184 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode() |
eb1bab5b BH |
185 | */ |
186 | @Override | |
187 | public int hashCode() { | |
d132bcc7 BH |
188 | final int prime = 31; |
189 | int result = super.hashCode(); | |
190 | result = prime * result + ((fEventType == null) ? 0 : (fEventType.ordinal() + 1)); | |
191 | result = prime * result + ((fLogLevel == null) ? 0 : (fLogLevel.ordinal() + 1)); | |
eb1bab5b | 192 | return result; |
d132bcc7 | 193 | } |
eb1bab5b BH |
194 | |
195 | /* | |
196 | * (non-Javadoc) | |
115b4a01 | 197 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object) |
eb1bab5b BH |
198 | */ |
199 | @Override | |
d132bcc7 BH |
200 | public boolean equals(Object obj) { |
201 | if (this == obj) { | |
202 | return true; | |
203 | } | |
204 | if (!super.equals(obj)) { | |
eb1bab5b BH |
205 | return false; |
206 | } | |
d132bcc7 | 207 | if (getClass() != obj.getClass()) { |
eb1bab5b BH |
208 | return false; |
209 | } | |
d132bcc7 BH |
210 | BaseEventInfo other = (BaseEventInfo) obj; |
211 | if (fEventType != other.fEventType) { | |
eb1bab5b BH |
212 | return false; |
213 | } | |
d132bcc7 | 214 | if (fLogLevel != other.fLogLevel) { |
eb1bab5b BH |
215 | return false; |
216 | } | |
217 | return true; | |
d132bcc7 | 218 | } |
eb1bab5b BH |
219 | |
220 | /* | |
221 | * (non-Javadoc) | |
115b4a01 | 222 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString() |
eb1bab5b BH |
223 | */ |
224 | @SuppressWarnings("nls") | |
225 | @Override | |
226 | public String toString() { | |
227 | StringBuffer output = new StringBuffer(); | |
228 | output.append("[BaseEventInfo("); | |
229 | output.append(super.toString()); | |
230 | output.append(",type="); | |
231 | output.append(fEventType); | |
232 | output.append(",level="); | |
233 | output.append(fLogLevel); | |
234 | output.append(")]"); | |
235 | return output.toString(); | |
236 | } | |
d132bcc7 BH |
237 | |
238 | ||
239 | ||
240 | ||
eb1bab5b | 241 | } |