1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IChannelInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IEventInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceEnablement
;
24 * Implementation of the trace channel interface (IChannelInfo) to store channel
28 * @author Bernd Hufmann
30 public class ChannelInfo
extends TraceInfo
implements IChannelInfo
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * The overwrite mode of the channel.
38 private boolean fOverwriteMode
;
40 * The sub-buffer size of the channel.
42 private long fSubBufferSize
;
44 * The number of sub-buffers of the channel.
46 private int fNumberOfSubBuffers
;
48 * The switch timer interval of the channel.
50 private long fSwitchTimer
;
52 * The read timer interval of the channel.
54 private long fReadTimer
;
56 * The Output type of the channel.
58 private String fOutputType
= ""; //$NON-NLS-1$
60 * The channel enable state.
62 private TraceEnablement fState
= TraceEnablement
.DISABLED
;
64 * The events information of the channel.
66 private final List
<IEventInfo
> fEvents
= new ArrayList
<IEventInfo
>();
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
74 * @param name - name channel
76 public ChannelInfo(String name
) {
82 * @param other - the instance to copy
84 public ChannelInfo(ChannelInfo other
) {
86 fOverwriteMode
= other
.fOverwriteMode
;
87 fSubBufferSize
= other
.fSubBufferSize
;
88 fNumberOfSubBuffers
= other
.fNumberOfSubBuffers
;
89 fSwitchTimer
= other
.fSwitchTimer
;
90 fReadTimer
= other
.fReadTimer
;
91 fOutputType
= (other
.fOutputType
== null ?
null : String
.valueOf(other
.fOutputType
));
92 fState
= other
.fState
;
93 for (Iterator
<IEventInfo
> iterator
= other
.fEvents
.iterator(); iterator
.hasNext();) {
94 IEventInfo event
= iterator
.next();
95 if (event
instanceof EventInfo
) {
96 fEvents
.add(new EventInfo((EventInfo
)event
));
103 // ------------------------------------------------------------------------
105 // ------------------------------------------------------------------------
108 public boolean isOverwriteMode() {
109 return fOverwriteMode
;
113 public void setOverwriteMode(boolean mode
) {
114 fOverwriteMode
= mode
;
118 public long getSubBufferSize() {
119 return fSubBufferSize
;
123 public void setSubBufferSize(long bufferSize
) {
124 fSubBufferSize
= bufferSize
;
128 public int getNumberOfSubBuffers() {
129 return fNumberOfSubBuffers
;
133 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
134 fNumberOfSubBuffers
= numberOfSubBuffers
;
138 public long getSwitchTimer() {
143 public void setSwitchTimer(long timer
) {
144 fSwitchTimer
= timer
;
148 public long getReadTimer() {
153 public void setReadTimer(long timer
) {
158 public String
getOutputType() {
163 public void setOutputType(String type
) {
168 public TraceEnablement
getState() {
173 public void setState(TraceEnablement state
) {
178 public void setState(String stateName
) {
179 fState
= TraceEnablement
.ENABLED
;
180 if (TraceEnablement
.DISABLED
.getInName().equals(stateName
)) {
181 fState
= TraceEnablement
.DISABLED
;
182 } else if (TraceEnablement
.ENABLED
.getInName().equals(stateName
)) {
183 fState
= TraceEnablement
.ENABLED
;
188 public IEventInfo
[] getEvents() {
189 return fEvents
.toArray(new IEventInfo
[fEvents
.size()]);
193 public void setEvents(List
<IEventInfo
> events
) {
195 for (Iterator
<IEventInfo
> iterator
= events
.iterator(); iterator
.hasNext();) {
196 IEventInfo eventInfo
= iterator
.next();
197 fEvents
.add(eventInfo
);
202 public void addEvent(IEventInfo channel
) {
203 fEvents
.add(channel
);
207 public int hashCode() {
208 final int prime
= 31;
209 int result
= super.hashCode();
210 result
= prime
* result
+ fEvents
.hashCode();
211 result
= prime
* result
+ fNumberOfSubBuffers
;
212 result
= prime
* result
+ ((fOutputType
== null) ?
0 : fOutputType
.hashCode());
213 result
= prime
* result
+ (fOverwriteMode ?
1231 : 1237);
214 result
= prime
* result
+ (int) (fReadTimer ^
(fReadTimer
>>> 32));
215 result
= prime
* result
+ ((fState
== null) ?
0 : (fState
.ordinal() + 1));
216 result
= prime
* result
+ (int) (fSubBufferSize ^
(fSubBufferSize
>>> 32));
217 result
= prime
* result
+ (int) (fSwitchTimer ^
(fSwitchTimer
>>> 32));
222 public boolean equals(Object obj
) {
226 if (!super.equals(obj
)) {
229 if (getClass() != obj
.getClass()) {
232 ChannelInfo other
= (ChannelInfo
) obj
;
233 if (!fEvents
.equals(other
.fEvents
)) {
236 if (fNumberOfSubBuffers
!= other
.fNumberOfSubBuffers
) {
239 if (fOutputType
== null) {
240 if (other
.fOutputType
!= null) {
243 } else if (!fOutputType
.equals(other
.fOutputType
)) {
246 if (fOverwriteMode
!= other
.fOverwriteMode
) {
249 if (fReadTimer
!= other
.fReadTimer
) {
252 if (fState
!= other
.fState
) {
255 if (fSubBufferSize
!= other
.fSubBufferSize
) {
258 if (fSwitchTimer
!= other
.fSwitchTimer
) {
264 @SuppressWarnings("nls")
266 public String
toString() {
267 StringBuffer output
= new StringBuffer();
268 output
.append("[ChannelInfo(");
269 output
.append(super.toString());
270 output
.append(",State=");
271 output
.append(fState
);
272 output
.append(",OverwriteMode=");
273 output
.append(fOverwriteMode
);
274 output
.append(",SubBuffersSize=");
275 output
.append(fSubBufferSize
);
276 output
.append(",NumberOfSubBuffers=");
277 output
.append(fNumberOfSubBuffers
);
278 output
.append(",SwitchTimer=");
279 output
.append(fSwitchTimer
);
280 output
.append(",ReadTimer=");
281 output
.append(fReadTimer
);
282 output
.append(",output=");
283 output
.append(fOutputType
);
284 output
.append(",Events=");
285 if (fEvents
.isEmpty()) {
286 output
.append("None");
288 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
289 IEventInfo event
= iterator
.next();
290 output
.append(event
.toString());
294 return output
.toString();
This page took 0.038037 seconds and 5 git commands to generate.