Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / EventInfo.java
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 **********************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
13
14 import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
15 import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
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)
59 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo#getState()
60 */
61 @Override
62 public TraceEnablement getState() {
63 return fState;
64 }
65
66 /*
67 * (non-Javadoc)
68 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo#setState(org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement)
69 */
70 @Override
71 public void setState(TraceEnablement state) {
72 fState = state;
73 }
74
75 /*
76 * (non-Javadoc)
77 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo#setState(java.lang.String)
78 */
79 @Override
80 public void setState(String stateName) {
81 fState = TraceEnablement.DISABLED;
82 if (TraceEnablement.DISABLED.getInName().equals(stateName)) {
83 fState = TraceEnablement.DISABLED;
84 } else if (TraceEnablement.ENABLED.getInName().equals(stateName)) {
85 fState = TraceEnablement.ENABLED;
86 }
87 }
88
89 /*
90 * (non-Javadoc)
91 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#hashCode()
92 */
93 @Override
94 public int hashCode() {
95 int result = 17;
96 result = 37 * result + super.hashCode();
97 result = 37 * result + fState.ordinal();
98 return result;
99 }
100
101 /*
102 * (non-Javadoc)
103 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
104 */
105 @Override
106 public boolean equals(Object other) {
107 if (!(other instanceof EventInfo)) {
108 return false;
109 }
110
111 EventInfo otherInfo = (EventInfo) other;
112 if (!super.equals(otherInfo)) {
113 return false;
114 }
115
116 if (fState.ordinal() != otherInfo.fState.ordinal()) {
117 return false;
118 }
119 return true;
120 }
121
122
123 /*
124 * (non-Javadoc)
125 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventInfo#toString()
126 */
127 @SuppressWarnings("nls")
128 @Override
129 public String toString() {
130 StringBuffer output = new StringBuffer();
131 output.append("[EventInfo(");
132 output.append(super.toString());
133 output.append(",State=");
134 output.append(fState);
135 output.append(")]");
136 return output.toString();
137 }
138 }
This page took 0.033856 seconds and 6 git commands to generate.