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.ITraceInfo#formatString()
280 @SuppressWarnings("nls")
282 public String
formatString() {
283 StringBuffer output
= new StringBuffer();
284 //- channel0: [enabled]
285 output
.append("\n- ");
286 output
.append(getName());
287 output
.append(": [");
288 output
.append(getState().getInName());
289 output
.append("]\n");
291 output
.append("\n Attributes:\n");
293 output
.append(" overwrite mode: ");
294 output
.append(isOverwriteMode() ?
"1" : "0");
295 // subbufers size: 262144
296 output
.append("\n subbufers size: ");
297 output
.append(getSubBufferSize());
298 // number of subbufers: 4
299 output
.append("\n number of subbufers: ");
300 output
.append(getNumberOfSubBuffers());
301 // switch timer interval: 0
302 output
.append("\n switch timer interval: ");
303 output
.append(getSwitchTimer());
304 // read timer interval: 200
305 output
.append("\n read timer interval: ");
306 output
.append(getReadTimer());
308 output
.append("\n output: ");
309 output
.append(getOutputType());
310 output
.append("\n\n");
312 output
.append(" Events:");
313 if (fEvents
.isEmpty()) {
314 output
.append("\n None");
316 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
317 IEventInfo event
= (IEventInfo
) iterator
.next();
318 output
.append(event
.formatString());
323 return output
.toString();
328 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
331 public int hashCode() {
332 final int prime
= 31;
333 int result
= super.hashCode();
334 result
= prime
* result
+ ((fEvents
== null) ?
0 : fEvents
.hashCode());
335 result
= prime
* result
+ fNumberOfSubBuffers
;
336 result
= prime
* result
+ ((fOutputType
== null) ?
0 : fOutputType
.hashCode());
337 result
= prime
* result
+ (fOverwriteMode ?
1231 : 1237);
338 result
= prime
* result
+ (int) (fReadTimer ^
(fReadTimer
>>> 32));
339 result
= prime
* result
+ ((fState
== null) ?
0 : (fState
.ordinal() + 1));
340 result
= prime
* result
+ (int) (fSubBufferSize ^
(fSubBufferSize
>>> 32));
341 result
= prime
* result
+ (int) (fSwitchTimer ^
(fSwitchTimer
>>> 32));
347 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
350 public boolean equals(Object obj
) {
354 if (!super.equals(obj
)) {
357 if (getClass() != obj
.getClass()) {
360 ChannelInfo other
= (ChannelInfo
) obj
;
361 if (fEvents
== null) {
362 if (other
.fEvents
!= null) {
365 } else if (!fEvents
.equals(other
.fEvents
)) {
368 if (fNumberOfSubBuffers
!= other
.fNumberOfSubBuffers
) {
371 if (fOutputType
== null) {
372 if (other
.fOutputType
!= null) {
375 } else if (!fOutputType
.equals(other
.fOutputType
)) {
378 if (fOverwriteMode
!= other
.fOverwriteMode
) {
381 if (fReadTimer
!= other
.fReadTimer
) {
384 if (fState
!= other
.fState
) {
387 if (fSubBufferSize
!= other
.fSubBufferSize
) {
390 if (fSwitchTimer
!= other
.fSwitchTimer
) {
398 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
400 @SuppressWarnings("nls")
402 public String
toString() {
403 StringBuffer output
= new StringBuffer();
404 output
.append("[ChannelInfo(");
405 output
.append(super.toString());
406 output
.append(",State=");
407 output
.append(fState
);
408 output
.append(",OverwriteMode=");
409 output
.append(fOverwriteMode
);
410 output
.append(",SubBuffersSize=");
411 output
.append(fSubBufferSize
);
412 output
.append(",NumberOfSubBuffers=");
413 output
.append(fNumberOfSubBuffers
);
414 output
.append(",SwitchTimer=");
415 output
.append(fSwitchTimer
);
416 output
.append(",ReadTimer=");
417 output
.append(fReadTimer
);
418 output
.append(",output=");
419 output
.append(fOutputType
);
420 output
.append(",Events=");
421 if (fEvents
.isEmpty()) {
422 output
.append("None");
424 for (Iterator
<IEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
425 IEventInfo event
= (IEventInfo
) iterator
.next();
426 output
.append(event
.toString());
430 return output
.toString();
This page took 0.041079 seconds and 5 git commands to generate.