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