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
.lttng
.ui
.views
.control
.model
.impl
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IChannelInfo
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IEventInfo
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.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.lttng.ui.views.control.model.IChannelInfo#getOverwriteMode()
110 public boolean isOverwriteMode() {
111 return fOverwriteMode
;
116 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setOverwriteMode(boolean)
119 public void setOverwriteMode(boolean mode
) {
120 fOverwriteMode
= mode
;
125 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#getSubBufferSize()
128 public long getSubBufferSize() {
129 return fSubBufferSize
;
134 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setSubBufferSize(long)
137 public void setSubBufferSize(long bufferSize
) {
138 fSubBufferSize
= bufferSize
;
144 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#getNumberOfSubBuffers()
147 public int getNumberOfSubBuffers() {
148 return fNumberOfSubBuffers
;
153 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setNumberOfSubBuffers(int)
156 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
157 fNumberOfSubBuffers
= numberOfSubBuffers
;
162 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#getSwitchTimer()
165 public long getSwitchTimer() {
171 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setSwitchTimer(long)
174 public void setSwitchTimer(long timer
) {
175 fSwitchTimer
= timer
;
180 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#getReadTimer()
183 public long getReadTimer() {
189 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setReadTimer(long)
192 public void setReadTimer(long timer
) {
198 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#getOutputType()
201 public String
getOutputType() {
207 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setOutputType(java.lang.String)
210 public void setOutputType(String type
) {
216 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#getState()
219 public TraceEnablement
getState() {
225 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo#setState(org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement)
228 public void setState(TraceEnablement state
) {
234 * @see org.eclipse.linuxtools.lttng.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.lttng.ui.views.control.model.IChannelInfo#getEvents()
251 public IEventInfo
[] getEvents() {
252 return fEvents
.toArray(new IEventInfo
[fEvents
.size()]);
257 * @see org.eclipse.linuxtools.lttng.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.lttng.ui.views.control.model.IChannelInfo#addEvent(org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo)
272 public void addEvent(IEventInfo channel
) {
273 fEvents
.add(channel
);
278 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
281 public int hashCode() {
283 result
= 37 * result
+ super.hashCode();
284 result
= 37 * result
+ Boolean
.valueOf(fOverwriteMode
).hashCode();
285 result
= 37 * result
+ Long
.valueOf(fSubBufferSize
).hashCode();
286 result
= 37 * result
+ fNumberOfSubBuffers
;
287 result
= 37 * result
+ Long
.valueOf(fSwitchTimer
).hashCode();
288 result
= 37 * result
+ Long
.valueOf(fReadTimer
).hashCode();
289 result
= 37 * result
+ (fOutputType
!= null ? fOutputType
.hashCode() : 0);
290 result
= 37 * result
+ fState
.ordinal();
291 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
292 IEventInfo event
= (IEventInfo
) iterator
.next();
293 result
= 37 * result
+ event
.hashCode();
300 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
303 public boolean equals(Object other
) {
304 if (!(other
instanceof ChannelInfo
)) {
308 ChannelInfo otherInfo
= (ChannelInfo
) other
;
309 if (!super.equals(otherInfo
)) {
313 if (fOverwriteMode
!= otherInfo
.fOverwriteMode
) {
316 if (fSubBufferSize
!= otherInfo
.fSubBufferSize
) {
319 if (fNumberOfSubBuffers
!= otherInfo
.fNumberOfSubBuffers
) {
322 if (fSwitchTimer
!= otherInfo
.fSwitchTimer
) {
325 if (fReadTimer
!= otherInfo
.fReadTimer
) {
328 if (fState
.ordinal() != otherInfo
.fState
.ordinal()) {
331 if (!fOutputType
.equals(otherInfo
.fOutputType
)) {
334 if (fEvents
.size() != otherInfo
.fEvents
.size()) {
337 for (int i
= 0; i
< fEvents
.size(); i
++) {
338 if (!fEvents
.get(i
).equals(otherInfo
.fEvents
.get(i
))) {
347 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
349 @SuppressWarnings("nls")
351 public String
toString() {
352 StringBuffer output
= new StringBuffer();
353 output
.append("[ChannelInfo(");
354 output
.append(super.toString());
355 output
.append(",State=");
356 output
.append(fState
);
357 output
.append(",OverwriteMode=");
358 output
.append(fOverwriteMode
);
359 output
.append(",SubBuffersSize=");
360 output
.append(fSubBufferSize
);
361 output
.append(",NumberOfSubBuffers=");
362 output
.append(fNumberOfSubBuffers
);
363 output
.append(",SwitchTimer=");
364 output
.append(fSwitchTimer
);
365 output
.append(",ReadTimer=");
366 output
.append(fReadTimer
);
367 output
.append(",output=");
368 output
.append(fOutputType
);
369 output
.append(",Events=");
370 if (fEvents
.isEmpty()) {
371 output
.append("None");
373 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
374 IEventInfo event
= (IEventInfo
) iterator
.next();
375 output
.append(event
.toString());
379 return output
.toString();
This page took 0.039538 seconds and 6 git commands to generate.