Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / internal / lttng / ui / views / control / model / impl / ProbeEventInfo.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.lttng.ui.views.control.model.impl;
13
14 import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo;
15
16 /**
17 * <b><u>ProbleEventInfo</u></b>
18 * <p>
19 * Implementation of the trace event interface (IProbeEventInfo) to store probe event
20 * related data.
21 * </p>
22 */
23 public class ProbeEventInfo extends EventInfo implements IProbeEventInfo {
24
25 // ------------------------------------------------------------------------
26 // Attributes
27 // ------------------------------------------------------------------------
28 /**
29 * The dynamic probe address (null if symbol is used).
30 */
31 private String fAddress;
32 /**
33 * The dynamic probe offset (if symbol is used).
34 */
35 private String fOffset;
36
37 /**
38 * The symbol name (null if address is used)
39 */
40 private String fSymbol;
41
42
43 // ------------------------------------------------------------------------
44 // Constructors
45 // ------------------------------------------------------------------------
46 /**
47 * Constructor
48 * @param name - name of event
49 */
50 public ProbeEventInfo(String name) {
51 super(name);
52 }
53
54 /**
55 * Copy constructor
56 * @param other - the instance to copy
57 */
58 public ProbeEventInfo(ProbeEventInfo other) {
59 super(other);
60 fAddress = other.fAddress;
61 fOffset = other.fOffset;
62 fSymbol = other.fSymbol;
63 }
64
65 // ------------------------------------------------------------------------
66 // Accessors
67 // ------------------------------------------------------------------------
68
69 /*
70 * (non-Javadoc)
71 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getAddress()
72 */
73 @Override
74 public String getAddress() {
75 return fAddress;
76 }
77
78 /*
79 * (non-Javadoc)
80 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setAddress(java.lang.String)
81 */
82 @Override
83 public void setAddress(String address) {
84 fAddress = address;
85 }
86
87 /*
88 * (non-Javadoc)
89 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getOffset()
90 */
91 @Override
92 public String getOffset() {
93 return fOffset;
94 }
95
96 /*
97 * (non-Javadoc)
98 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setOffset(java.lang.String)
99 */
100 @Override
101 public void setOffset(String offset) {
102 fOffset = offset;
103 }
104
105 /*
106 * (non-Javadoc)
107 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#getSymbol()
108 */
109 @Override
110 public String getSymbol() {
111 return fSymbol;
112 }
113
114 /*
115 * (non-Javadoc)
116 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.IProbeEventInfo#setSymbol(java.lang.String)
117 */
118 @Override
119 public void setSymbol(String symbol) {
120 fSymbol = symbol;
121 }
122
123 // ------------------------------------------------------------------------
124 // Operation
125 // ------------------------------------------------------------------------
126 /*
127 * (non-Javadoc)
128 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.ITraceInfo#formatString()
129 */
130 @SuppressWarnings("nls")
131 @Override
132 public String formatString() {
133 StringBuffer output = new StringBuffer();
134 // name (type: probe) [enabled]");
135 // address:
136 output.append(super.formatString());
137 if (fAddress != null) {
138 output.append("\n addr: ");
139 output.append(fAddress);
140 } else {
141 output.append("\n offset: ");
142 output.append(fOffset);
143 output.append("\n");
144 output.append(" symbol: ");
145 output.append(fSymbol);
146 }
147 return output.toString();
148 }
149
150 /*
151 * (non-Javadoc)
152 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#hashCode()
153 */
154 @Override
155 public int hashCode() {
156 final int prime = 31;
157 int result = super.hashCode();
158 result = prime * result + ((fAddress == null) ? 0 : fAddress.hashCode());
159 result = prime * result + ((fOffset == null) ? 0 : fOffset.hashCode());
160 result = prime * result + ((fSymbol == null) ? 0 : fSymbol.hashCode());
161 return result;
162 }
163
164 /*
165 * (non-Javadoc)
166 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventInfo#equals(java.lang.Object)
167 */
168 @Override
169 public boolean equals(Object obj) {
170 if (this == obj) {
171 return true;
172 }
173 if (!super.equals(obj)) {
174 return false;
175 }
176 if (getClass() != obj.getClass()) {
177 return false;
178 }
179 ProbeEventInfo other = (ProbeEventInfo) obj;
180 if (fAddress == null) {
181 if (other.fAddress != null) {
182 return false;
183 }
184 } else if (!fAddress.equals(other.fAddress)) {
185 return false;
186 }
187 if (fOffset == null) {
188 if (other.fOffset != null) {
189 return false;
190 }
191 } else if (!fOffset.equals(other.fOffset)) {
192 return false;
193 }
194 if (fSymbol == null) {
195 if (other.fSymbol != null) {
196 return false;
197 }
198 } else if (!fSymbol.equals(other.fSymbol)) {
199 return false;
200 }
201 return true;
202 }
203
204
205 /*
206 * (non-Javadoc)
207 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.EventInfo#toString()
208 */
209 @SuppressWarnings("nls")
210 @Override
211 public String toString() {
212 StringBuffer output = new StringBuffer();
213 output.append("[ProbeEventInfo(");
214 output.append(super.toString());
215 if (fAddress != null) {
216 output.append(",fAddress=");
217 output.append(fAddress);
218 } else {
219 output.append(",fOffset=");
220 output.append(fOffset);
221 output.append(",fSymbol=");
222 output.append(fSymbol);
223 }
224 output.append(")]");
225 return output.toString();
226 }
227
228
229 }
This page took 0.036372 seconds and 5 git commands to generate.