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.IEventInfo; |
15 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement; | |
eb1bab5b BH |
16 | |
17 | /** | |
18 | * <b><u>EventInfo</u></b> | |
19 | * <p> | |
20 | * Implementation of the trace event interface (IEventInfo) to store event | |
21 | * related data. | |
22 | * </p> | |
23 | */ | |
24 | public class EventInfo extends BaseEventInfo implements IEventInfo { | |
25 | ||
26 | // ------------------------------------------------------------------------ | |
27 | // Attributes | |
28 | // ------------------------------------------------------------------------ | |
29 | /** | |
30 | * The enable state of the event. | |
31 | */ | |
32 | private TraceEnablement fState = TraceEnablement.DISABLED; | |
33 | ||
34 | // ------------------------------------------------------------------------ | |
35 | // Constructors | |
36 | // ------------------------------------------------------------------------ | |
37 | /** | |
38 | * Constructor | |
39 | * @param name - name of event | |
40 | */ | |
41 | public EventInfo(String name) { | |
42 | super(name); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Copy constructor | |
47 | * @param other - the instance to copy | |
48 | */ | |
49 | public EventInfo(EventInfo other) { | |
50 | super(other); | |
51 | fState = other.fState; | |
52 | } | |
53 | ||
54 | // ------------------------------------------------------------------------ | |
55 | // Accessors | |
56 | // ------------------------------------------------------------------------ | |
57 | /* | |
58 | * (non-Javadoc) | |
115b4a01 | 59 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#getState() |
eb1bab5b BH |
60 | */ |
61 | @Override | |
62 | public TraceEnablement getState() { | |
63 | return fState; | |
64 | } | |
65 | ||
66 | /* | |
67 | * (non-Javadoc) | |
115b4a01 | 68 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#setState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement) |
eb1bab5b BH |
69 | */ |
70 | @Override | |
71 | public void setState(TraceEnablement state) { | |
72 | fState = state; | |
73 | } | |
74 | ||
d132bcc7 BH |
75 | /* |
76 | * (non-Javadoc) | |
115b4a01 | 77 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString() |
d132bcc7 BH |
78 | */ |
79 | @SuppressWarnings("nls") | |
80 | @Override | |
81 | public String formatString() { | |
82 | StringBuffer output = new StringBuffer(); | |
83 | // ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint) [enabled]"); | |
84 | output.append(super.formatString()); | |
85 | output.append(" ["); | |
86 | output.append(fState.getInName()); | |
87 | output.append("]"); | |
88 | return output.toString(); | |
89 | } | |
90 | ||
eb1bab5b BH |
91 | /* |
92 | * (non-Javadoc) | |
115b4a01 | 93 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#setState(java.lang.String) |
eb1bab5b BH |
94 | */ |
95 | @Override | |
96 | public void setState(String stateName) { | |
97 | fState = TraceEnablement.DISABLED; | |
98 | if (TraceEnablement.DISABLED.getInName().equals(stateName)) { | |
99 | fState = TraceEnablement.DISABLED; | |
100 | } else if (TraceEnablement.ENABLED.getInName().equals(stateName)) { | |
101 | fState = TraceEnablement.ENABLED; | |
102 | } | |
103 | } | |
104 | ||
105 | /* | |
106 | * (non-Javadoc) | |
115b4a01 | 107 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#hashCode() |
eb1bab5b BH |
108 | */ |
109 | @Override | |
110 | public int hashCode() { | |
d132bcc7 BH |
111 | final int prime = 31; |
112 | int result = super.hashCode(); | |
113 | result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1)); | |
eb1bab5b BH |
114 | return result; |
115 | } | |
116 | ||
117 | /* | |
118 | * (non-Javadoc) | |
115b4a01 | 119 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object) |
eb1bab5b BH |
120 | */ |
121 | @Override | |
d132bcc7 BH |
122 | public boolean equals(Object obj) { |
123 | if (this == obj) { | |
124 | return true; | |
125 | } | |
126 | if (!super.equals(obj)) { | |
eb1bab5b BH |
127 | return false; |
128 | } | |
d132bcc7 | 129 | if (getClass() != obj.getClass()) { |
eb1bab5b BH |
130 | return false; |
131 | } | |
d132bcc7 BH |
132 | EventInfo other = (EventInfo) obj; |
133 | if (fState != other.fState) { | |
eb1bab5b BH |
134 | return false; |
135 | } | |
136 | return true; | |
137 | } | |
d132bcc7 | 138 | |
eb1bab5b BH |
139 | /* |
140 | * (non-Javadoc) | |
115b4a01 | 141 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#toString() |
eb1bab5b BH |
142 | */ |
143 | @SuppressWarnings("nls") | |
144 | @Override | |
145 | public String toString() { | |
146 | StringBuffer output = new StringBuffer(); | |
147 | output.append("[EventInfo("); | |
148 | output.append(super.toString()); | |
149 | output.append(",State="); | |
150 | output.append(fState); | |
151 | output.append(")]"); | |
152 | return output.toString(); | |
153 | } | |
154 | } |