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 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOverwriteMode()
111 public boolean isOverwriteMode() {
112 return fOverwriteMode
;
117 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOverwriteMode(boolean)
120 public void setOverwriteMode(boolean mode
) {
121 fOverwriteMode
= mode
;
126 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSubBufferSize()
129 public long getSubBufferSize() {
130 return fSubBufferSize
;
135 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSubBufferSize(long)
138 public void setSubBufferSize(long bufferSize
) {
139 fSubBufferSize
= bufferSize
;
145 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getNumberOfSubBuffers()
148 public int getNumberOfSubBuffers() {
149 return fNumberOfSubBuffers
;
154 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setNumberOfSubBuffers(int)
157 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
158 fNumberOfSubBuffers
= numberOfSubBuffers
;
163 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSwitchTimer()
166 public long getSwitchTimer() {
172 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSwitchTimer(long)
175 public void setSwitchTimer(long timer
) {
176 fSwitchTimer
= timer
;
181 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getReadTimer()
184 public long getReadTimer() {
190 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setReadTimer(long)
193 public void setReadTimer(long timer
) {
199 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOutputType()
202 public String
getOutputType() {
208 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOutputType(java.lang.String)
211 public void setOutputType(String type
) {
217 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getState()
220 public TraceEnablement
getState() {
226 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement)
229 public void setState(TraceEnablement state
) {
235 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(java.lang.String)
238 public void setState(String stateName
) {
239 fState
= TraceEnablement
.ENABLED
;
240 if (TraceEnablement
.DISABLED
.getInName().equals(stateName
)) {
241 fState
= TraceEnablement
.DISABLED
;
242 } else if (TraceEnablement
.ENABLED
.getInName().equals(stateName
)) {
243 fState
= TraceEnablement
.ENABLED
;
249 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getEvents()
252 public IEventInfo
[] getEvents() {
253 return fEvents
.toArray(new IEventInfo
[fEvents
.size()]);
258 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setEvents(java.util.List)
261 public void setEvents(List
<IEventInfo
> events
) {
263 for (Iterator
<IEventInfo
> iterator
= events
.iterator(); iterator
.hasNext();) {
264 IEventInfo eventInfo
= iterator
.next();
265 fEvents
.add(eventInfo
);
271 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo)
274 public void addEvent(IEventInfo channel
) {
275 fEvents
.add(channel
);
280 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
283 public int hashCode() {
284 final int prime
= 31;
285 int result
= super.hashCode();
286 result
= prime
* result
+ fEvents
.hashCode();
287 result
= prime
* result
+ fNumberOfSubBuffers
;
288 result
= prime
* result
+ ((fOutputType
== null) ?
0 : fOutputType
.hashCode());
289 result
= prime
* result
+ (fOverwriteMode ?
1231 : 1237);
290 result
= prime
* result
+ (int) (fReadTimer ^
(fReadTimer
>>> 32));
291 result
= prime
* result
+ ((fState
== null) ?
0 : (fState
.ordinal() + 1));
292 result
= prime
* result
+ (int) (fSubBufferSize ^
(fSubBufferSize
>>> 32));
293 result
= prime
* result
+ (int) (fSwitchTimer ^
(fSwitchTimer
>>> 32));
299 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
302 public boolean equals(Object obj
) {
306 if (!super.equals(obj
)) {
309 if (getClass() != obj
.getClass()) {
312 ChannelInfo other
= (ChannelInfo
) obj
;
313 if (!fEvents
.equals(other
.fEvents
)) {
316 if (fNumberOfSubBuffers
!= other
.fNumberOfSubBuffers
) {
319 if (fOutputType
== null) {
320 if (other
.fOutputType
!= null) {
323 } else if (!fOutputType
.equals(other
.fOutputType
)) {
326 if (fOverwriteMode
!= other
.fOverwriteMode
) {
329 if (fReadTimer
!= other
.fReadTimer
) {
332 if (fState
!= other
.fState
) {
335 if (fSubBufferSize
!= other
.fSubBufferSize
) {
338 if (fSwitchTimer
!= other
.fSwitchTimer
) {
346 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
348 @SuppressWarnings("nls")
350 public String
toString() {
351 StringBuffer output
= new StringBuffer();
352 output
.append("[ChannelInfo(");
353 output
.append(super.toString());
354 output
.append(",State=");
355 output
.append(fState
);
356 output
.append(",OverwriteMode=");
357 output
.append(fOverwriteMode
);
358 output
.append(",SubBuffersSize=");
359 output
.append(fSubBufferSize
);
360 output
.append(",NumberOfSubBuffers=");
361 output
.append(fNumberOfSubBuffers
);
362 output
.append(",SwitchTimer=");
363 output
.append(fSwitchTimer
);
364 output
.append(",ReadTimer=");
365 output
.append(fReadTimer
);
366 output
.append(",output=");
367 output
.append(fOutputType
);
368 output
.append(",Events=");
369 if (fEvents
.isEmpty()) {
370 output
.append("None");
372 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
373 IEventInfo event
= iterator
.next();
374 output
.append(event
.toString());
378 return output
.toString();
This page took 0.040316 seconds and 6 git commands to generate.