Internalize API for trace control and move control to lttng2
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / 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.internal.lttng2.ui.views.control.model.impl;
13
14 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
15 import org.eclipse.linuxtools.internal.lttng2.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.internal.lttng2.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.internal.lttng2.ui.views.control.model.IEventInfo#setState(org.eclipse.linuxtools.internal.lttng2.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.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
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
91 /*
92 * (non-Javadoc)
93 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo#setState(java.lang.String)
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)
107 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#hashCode()
108 */
109 @Override
110 public int hashCode() {
111 final int prime = 31;
112 int result = super.hashCode();
113 result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
114 return result;
115 }
116
117 /*
118 * (non-Javadoc)
119 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
120 */
121 @Override
122 public boolean equals(Object obj) {
123 if (this == obj) {
124 return true;
125 }
126 if (!super.equals(obj)) {
127 return false;
128 }
129 if (getClass() != obj.getClass()) {
130 return false;
131 }
132 EventInfo other = (EventInfo) obj;
133 if (fState != other.fState) {
134 return false;
135 }
136 return true;
137 }
138
139 /*
140 * (non-Javadoc)
141 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventInfo#toString()
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 }
This page took 0.033999 seconds and 5 git commands to generate.