1 /**********************************************************************
2 * Copyright (c) 2012 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
;
23 * <b><u>ChannelInfo</u></b>
25 * Implementation of the trace channel interface (IChannelInfo) to store channel
29 public class ChannelInfo
extends TraceInfo
implements IChannelInfo
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The overwrite mode of the channel.
37 private boolean fOverwriteMode
;
39 * The sub-buffer size of the channel.
41 private long fSubBufferSize
;
43 * The number of sub-buffers of the channel.
45 private int fNumberOfSubBuffers
;
47 * The switch timer interval of the channel.
49 private long fSwitchTimer
;
51 * The read timer interval of the channel.
53 private long fReadTimer
;
55 * The Output type of the channel.
57 private String fOutputType
= ""; //$NON-NLS-1$
59 * The channel enable state.
61 private TraceEnablement fState
= TraceEnablement
.DISABLED
;
63 * The events information of the channel.
65 private List
<IEventInfo
> fEvents
= new ArrayList
<IEventInfo
>();
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
73 * @param name - name channel
75 public ChannelInfo(String name
) {
81 * @param other - the instance to copy
83 public ChannelInfo(ChannelInfo other
) {
85 fOverwriteMode
= other
.fOverwriteMode
;
86 fSubBufferSize
= other
.fSubBufferSize
;
87 fNumberOfSubBuffers
= other
.fNumberOfSubBuffers
;
88 fSwitchTimer
= other
.fSwitchTimer
;
89 fReadTimer
= other
.fReadTimer
;
90 fOutputType
= (other
.fOutputType
== null ?
null : String
.valueOf(other
.fOutputType
));
91 fState
= other
.fState
;
92 for (Iterator
<IEventInfo
> iterator
= other
.fEvents
.iterator(); iterator
.hasNext();) {
93 IEventInfo event
= iterator
.next();
94 if (event
instanceof EventInfo
) {
95 fEvents
.add(new EventInfo((EventInfo
)event
));
102 // ------------------------------------------------------------------------
104 // ------------------------------------------------------------------------
107 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOverwriteMode()
110 public boolean isOverwriteMode() {
111 return fOverwriteMode
;
116 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOverwriteMode(boolean)
119 public void setOverwriteMode(boolean mode
) {
120 fOverwriteMode
= mode
;
125 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSubBufferSize()
128 public long getSubBufferSize() {
129 return fSubBufferSize
;
134 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSubBufferSize(long)
137 public void setSubBufferSize(long bufferSize
) {
138 fSubBufferSize
= bufferSize
;
144 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getNumberOfSubBuffers()
147 public int getNumberOfSubBuffers() {
148 return fNumberOfSubBuffers
;
153 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setNumberOfSubBuffers(int)
156 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
157 fNumberOfSubBuffers
= numberOfSubBuffers
;
162 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getSwitchTimer()
165 public long getSwitchTimer() {
171 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setSwitchTimer(long)
174 public void setSwitchTimer(long timer
) {
175 fSwitchTimer
= timer
;
180 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getReadTimer()
183 public long getReadTimer() {
189 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setReadTimer(long)
192 public void setReadTimer(long timer
) {
198 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getOutputType()
201 public String
getOutputType() {
207 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setOutputType(java.lang.String)
210 public void setOutputType(String type
) {
216 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getState()
219 public TraceEnablement
getState() {
225 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEnablement)
228 public void setState(TraceEnablement state
) {
234 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setState(java.lang.String)
237 public void setState(String stateName
) {
238 fState
= TraceEnablement
.ENABLED
;
239 if (TraceEnablement
.DISABLED
.getInName().equals(stateName
)) {
240 fState
= TraceEnablement
.DISABLED
;
241 } else if (TraceEnablement
.ENABLED
.getInName().equals(stateName
)) {
242 fState
= TraceEnablement
.ENABLED
;
248 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#getEvents()
251 public IEventInfo
[] getEvents() {
252 return fEvents
.toArray(new IEventInfo
[fEvents
.size()]);
257 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#setEvents(java.util.List)
260 public void setEvents(List
<IEventInfo
> events
) {
261 for (Iterator
<IEventInfo
> iterator
= events
.iterator(); iterator
.hasNext();) {
262 IEventInfo eventInfo
= (IEventInfo
) iterator
.next();
263 fEvents
.add(eventInfo
);
269 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo)
272 public void addEvent(IEventInfo channel
) {
273 fEvents
.add(channel
);
278 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
281 public int hashCode() {
282 final int prime
= 31;
283 int result
= super.hashCode();
284 result
= prime
* result
+ ((fEvents
== null) ?
0 : fEvents
.hashCode());
285 result
= prime
* result
+ fNumberOfSubBuffers
;
286 result
= prime
* result
+ ((fOutputType
== null) ?
0 : fOutputType
.hashCode());
287 result
= prime
* result
+ (fOverwriteMode ?
1231 : 1237);
288 result
= prime
* result
+ (int) (fReadTimer ^
(fReadTimer
>>> 32));
289 result
= prime
* result
+ ((fState
== null) ?
0 : (fState
.ordinal() + 1));
290 result
= prime
* result
+ (int) (fSubBufferSize ^
(fSubBufferSize
>>> 32));
291 result
= prime
* result
+ (int) (fSwitchTimer ^
(fSwitchTimer
>>> 32));
297 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
300 public boolean equals(Object obj
) {
304 if (!super.equals(obj
)) {
307 if (getClass() != obj
.getClass()) {
310 ChannelInfo other
= (ChannelInfo
) obj
;
311 if (fEvents
== null) {
312 if (other
.fEvents
!= null) {
315 } else if (!fEvents
.equals(other
.fEvents
)) {
318 if (fNumberOfSubBuffers
!= other
.fNumberOfSubBuffers
) {
321 if (fOutputType
== null) {
322 if (other
.fOutputType
!= null) {
325 } else if (!fOutputType
.equals(other
.fOutputType
)) {
328 if (fOverwriteMode
!= other
.fOverwriteMode
) {
331 if (fReadTimer
!= other
.fReadTimer
) {
334 if (fState
!= other
.fState
) {
337 if (fSubBufferSize
!= other
.fSubBufferSize
) {
340 if (fSwitchTimer
!= other
.fSwitchTimer
) {
348 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
350 @SuppressWarnings("nls")
352 public String
toString() {
353 StringBuffer output
= new StringBuffer();
354 output
.append("[ChannelInfo(");
355 output
.append(super.toString());
356 output
.append(",State=");
357 output
.append(fState
);
358 output
.append(",OverwriteMode=");
359 output
.append(fOverwriteMode
);
360 output
.append(",SubBuffersSize=");
361 output
.append(fSubBufferSize
);
362 output
.append(",NumberOfSubBuffers=");
363 output
.append(fNumberOfSubBuffers
);
364 output
.append(",SwitchTimer=");
365 output
.append(fSwitchTimer
);
366 output
.append(",ReadTimer=");
367 output
.append(fReadTimer
);
368 output
.append(",output=");
369 output
.append(fOutputType
);
370 output
.append(",Events=");
371 if (fEvents
.isEmpty()) {
372 output
.append("None");
374 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
375 IEventInfo event
= (IEventInfo
) iterator
.next();
376 output
.append(event
.toString());
380 return output
.toString();
This page took 0.046096 seconds and 6 git commands to generate.