1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
;
14 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IBaseEventInfo
;
15 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceEventType
;
16 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceLogLevel
;
19 * <b><u>BaseEventInfo</u></b>
21 * Implementation of the basic trace event interface (IEventInfo) to store event
25 public class BaseEventInfo
extends TraceInfo
implements IBaseEventInfo
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 * The trace event type.
33 private TraceEventType fEventType
= TraceEventType
.UNKNOWN
;
35 * The trace log level.
37 private TraceLogLevel fLogLevel
= TraceLogLevel
.TRACE_DEBUG
;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * @param name - name of base event
46 public BaseEventInfo(String name
) {
52 * @param other - the instance to copy
54 public BaseEventInfo(BaseEventInfo other
) {
56 fEventType
= other
.fEventType
;
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
64 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo#getEventType()
67 public TraceEventType
getEventType() {
73 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo#setEventType(org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType)
76 public void setEventType(TraceEventType type
) {
82 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo#setEventType(java.lang.String)
85 public void setEventType(String typeName
) {
86 if(TraceEventType
.TRACEPOINT
.getInName().equals(typeName
)) {
87 fEventType
= TraceEventType
.TRACEPOINT
;
89 fEventType
= TraceEventType
.UNKNOWN
;
95 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo#getLogLevel()
98 public TraceLogLevel
getLogLevel() {
104 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo#setLogLevel(org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel)
107 public void setLogLevel(TraceLogLevel level
) {
113 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo#setLogLevel(java.lang.String)
116 public void setLogLevel(String levelName
) {
117 if(TraceLogLevel
.TRACE_EMERG
.getInName().equals(levelName
)) {
118 fLogLevel
= TraceLogLevel
.TRACE_EMERG
;
119 } else if(TraceLogLevel
.TRACE_ALERT
.getInName().equals(levelName
)) {
120 fLogLevel
= TraceLogLevel
.TRACE_ALERT
;
121 } else if(TraceLogLevel
.TRACE_CRIT
.getInName().equals(levelName
)) {
122 fLogLevel
= TraceLogLevel
.TRACE_CRIT
;
123 } else if(TraceLogLevel
.TRACE_ERR
.getInName().equals(levelName
)) {
124 fLogLevel
= TraceLogLevel
.TRACE_ERR
;
125 } else if(TraceLogLevel
.TRACE_WARNING
.getInName().equals(levelName
)) {
126 fLogLevel
= TraceLogLevel
.TRACE_WARNING
;
127 } else if(TraceLogLevel
.TRACE_NOTICE
.getInName().equals(levelName
)) {
128 fLogLevel
= TraceLogLevel
.TRACE_NOTICE
;
129 } else if(TraceLogLevel
.TRACE_INFO
.getInName().equals(levelName
)) {
130 fLogLevel
= TraceLogLevel
.TRACE_INFO
;
131 } else if(TraceLogLevel
.TRACE_DEBUG_SYSTEM
.getInName().equals(levelName
)) {
132 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_SYSTEM
;
133 } else if(TraceLogLevel
.TRACE_DEBUG_PROGRAM
.getInName().equals(levelName
)) {
134 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_PROGRAM
;
135 } else if(TraceLogLevel
.TRACE_DEBUG_PROCESS
.getInName().equals(levelName
)) {
136 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_PROCESS
;
137 } else if(TraceLogLevel
.TRACE_DEBUG_MODULE
.getInName().equals(levelName
)) {
138 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_MODULE
;
139 } else if(TraceLogLevel
.TRACE_DEBUG_UNIT
.getInName().equals(levelName
)) {
140 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_UNIT
;
141 } else if(TraceLogLevel
.TRACE_DEBUG_FUNCTION
.getInName().equals(levelName
)) {
142 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_FUNCTION
;
143 } else if(TraceLogLevel
.TRACE_DEBUG_LINE
.getInName().equals(levelName
)) {
144 fLogLevel
= TraceLogLevel
.TRACE_DEBUG_LINE
;
145 } else if(TraceLogLevel
.TRACE_DEBUG
.getInName().equals(levelName
)) {
146 fLogLevel
= TraceLogLevel
.TRACE_DEBUG
;
147 } else if(TraceLogLevel
.LEVEL_UNKNOWN
.getInName().equals(levelName
)) {
148 fLogLevel
= TraceLogLevel
.LEVEL_UNKNOWN
;
150 fLogLevel
= TraceLogLevel
.TRACE_DEBUG
;
156 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
159 public int hashCode() {
161 result
= 37 * result
+ super.hashCode();
162 result
= 37 * result
+ fEventType
.ordinal();
163 result
= 37 * result
+ fLogLevel
.ordinal();
169 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
172 public boolean equals(Object other
) {
173 if (!(other
instanceof BaseEventInfo
)) {
177 BaseEventInfo otherInfo
= (BaseEventInfo
) other
;
178 if (!super.equals(otherInfo
)) {
182 if (fEventType
.ordinal() != otherInfo
.fEventType
.ordinal()) {
186 if (fLogLevel
.ordinal() != otherInfo
.fLogLevel
.ordinal()) {
194 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
196 @SuppressWarnings("nls")
198 public String
toString() {
199 StringBuffer output
= new StringBuffer();
200 output
.append("[BaseEventInfo(");
201 output
.append(super.toString());
202 output
.append(",type=");
203 output
.append(fEventType
);
204 output
.append(",level=");
205 output
.append(fLogLevel
);
207 return output
.toString();