Commit | Line | Data |
---|---|---|
d132bcc7 | 1 | /********************************************************************** |
11252342 AM |
2 | * Copyright (c) 2012, 2013 Ericsson |
3 | * | |
d132bcc7 BH |
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 | |
11252342 AM |
8 | * |
9 | * Contributors: | |
d132bcc7 BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
9315aeee | 12 | package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl; |
d132bcc7 | 13 | |
9315aeee | 14 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo; |
d132bcc7 BH |
15 | |
16 | /** | |
d132bcc7 BH |
17 | * <p> |
18 | * Implementation of the trace event interface (IProbeEventInfo) to store probe event | |
11252342 | 19 | * related data. |
d132bcc7 | 20 | * </p> |
11252342 | 21 | * |
dbd4432d | 22 | * @author Bernd Hufmann |
d132bcc7 BH |
23 | */ |
24 | public class ProbeEventInfo extends EventInfo implements IProbeEventInfo { | |
25 | ||
26 | // ------------------------------------------------------------------------ | |
27 | // Attributes | |
28 | // ------------------------------------------------------------------------ | |
29 | /** | |
30 | * The dynamic probe address (null if symbol is used). | |
31 | */ | |
32 | private String fAddress; | |
33 | /** | |
34 | * The dynamic probe offset (if symbol is used). | |
35 | */ | |
36 | private String fOffset; | |
11252342 | 37 | |
d132bcc7 BH |
38 | /** |
39 | * The symbol name (null if address is used) | |
40 | */ | |
41 | private String fSymbol; | |
11252342 AM |
42 | |
43 | ||
d132bcc7 BH |
44 | // ------------------------------------------------------------------------ |
45 | // Constructors | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
48 | * Constructor | |
49 | * @param name - name of event | |
50 | */ | |
51 | public ProbeEventInfo(String name) { | |
52 | super(name); | |
53 | } | |
11252342 | 54 | |
d132bcc7 BH |
55 | /** |
56 | * Copy constructor | |
57 | * @param other - the instance to copy | |
58 | */ | |
59 | public ProbeEventInfo(ProbeEventInfo other) { | |
60 | super(other); | |
61 | fAddress = other.fAddress; | |
62 | fOffset = other.fOffset; | |
63 | fSymbol = other.fSymbol; | |
64 | } | |
11252342 | 65 | |
d132bcc7 BH |
66 | // ------------------------------------------------------------------------ |
67 | // Accessors | |
68 | // ------------------------------------------------------------------------ | |
69 | ||
d132bcc7 BH |
70 | @Override |
71 | public String getAddress() { | |
72 | return fAddress; | |
73 | } | |
74 | ||
d132bcc7 BH |
75 | @Override |
76 | public void setAddress(String address) { | |
77 | fAddress = address; | |
78 | } | |
79 | ||
d132bcc7 BH |
80 | @Override |
81 | public String getOffset() { | |
82 | return fOffset; | |
83 | } | |
84 | ||
d132bcc7 BH |
85 | @Override |
86 | public void setOffset(String offset) { | |
87 | fOffset = offset; | |
88 | } | |
89 | ||
d132bcc7 BH |
90 | @Override |
91 | public String getSymbol() { | |
92 | return fSymbol; | |
93 | } | |
94 | ||
d132bcc7 BH |
95 | @Override |
96 | public void setSymbol(String symbol) { | |
97 | fSymbol = symbol; | |
98 | } | |
99 | ||
100 | // ------------------------------------------------------------------------ | |
101 | // Operation | |
102 | // ------------------------------------------------------------------------ | |
4ea599a5 | 103 | |
d132bcc7 BH |
104 | @Override |
105 | public int hashCode() { | |
106 | final int prime = 31; | |
107 | int result = super.hashCode(); | |
108 | result = prime * result + ((fAddress == null) ? 0 : fAddress.hashCode()); | |
109 | result = prime * result + ((fOffset == null) ? 0 : fOffset.hashCode()); | |
110 | result = prime * result + ((fSymbol == null) ? 0 : fSymbol.hashCode()); | |
111 | return result; | |
112 | } | |
113 | ||
d132bcc7 BH |
114 | @Override |
115 | public boolean equals(Object obj) { | |
116 | if (this == obj) { | |
117 | return true; | |
118 | } | |
119 | if (!super.equals(obj)) { | |
120 | return false; | |
121 | } | |
122 | if (getClass() != obj.getClass()) { | |
123 | return false; | |
124 | } | |
125 | ProbeEventInfo other = (ProbeEventInfo) obj; | |
126 | if (fAddress == null) { | |
127 | if (other.fAddress != null) { | |
128 | return false; | |
129 | } | |
130 | } else if (!fAddress.equals(other.fAddress)) { | |
131 | return false; | |
132 | } | |
133 | if (fOffset == null) { | |
134 | if (other.fOffset != null) { | |
135 | return false; | |
136 | } | |
137 | } else if (!fOffset.equals(other.fOffset)) { | |
138 | return false; | |
139 | } | |
140 | if (fSymbol == null) { | |
141 | if (other.fSymbol != null) { | |
142 | return false; | |
143 | } | |
144 | } else if (!fSymbol.equals(other.fSymbol)) { | |
145 | return false; | |
146 | } | |
147 | return true; | |
148 | } | |
149 | ||
d132bcc7 BH |
150 | @SuppressWarnings("nls") |
151 | @Override | |
152 | public String toString() { | |
153 | StringBuffer output = new StringBuffer(); | |
154 | output.append("[ProbeEventInfo("); | |
155 | output.append(super.toString()); | |
156 | if (fAddress != null) { | |
157 | output.append(",fAddress="); | |
158 | output.append(fAddress); | |
159 | } else { | |
160 | output.append(",fOffset="); | |
161 | output.append(fOffset); | |
162 | output.append(",fSymbol="); | |
163 | output.append(fSymbol); | |
164 | } | |
165 | output.append(")]"); | |
166 | return output.toString(); | |
167 | } | |
168 | ||
d132bcc7 | 169 | } |