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
.IDomainInfo
;
23 * Implementation of the trace domain interface (IDomainInfo) to store domain
27 * @author Bernd Hufmann
29 public class DomainInfo
extends TraceInfo
implements IDomainInfo
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The channels information of the domain.
37 private List
<IChannelInfo
> fChannels
= new ArrayList
<IChannelInfo
>();
38 private boolean fIsKernel
= false;
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
45 * @param name - name of domain
47 public DomainInfo(String name
) {
53 * @param other - the instance to copy
55 public DomainInfo(DomainInfo other
) {
57 for (int i
= 0; i
< other
.fChannels
.size(); i
++) {
58 if (other
.fChannels
.get(i
) instanceof ChannelInfo
) {
59 fChannels
.add(new ChannelInfo((ChannelInfo
)other
.fChannels
.get(i
)));
61 fChannels
.add(other
.fChannels
.get(i
));
64 fIsKernel
= other
.fIsKernel
;
69 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#isKernel()
72 public boolean isKernel() {
78 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
81 public void setIsKernel(boolean isKernel
) {
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
90 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#getChannels()
93 public IChannelInfo
[] getChannels() {
94 return fChannels
.toArray(new IChannelInfo
[fChannels
.size()]);
99 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setChannels(java.util.List)
102 public void setChannels(List
<IChannelInfo
> channels
) {
103 for (Iterator
<IChannelInfo
> iterator
= channels
.iterator(); iterator
.hasNext();) {
104 IChannelInfo channelInfo
= (IChannelInfo
) iterator
.next();
105 fChannels
.add(channelInfo
);
111 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo)
114 public void addChannel(IChannelInfo channel
) {
115 fChannels
.add(channel
);
120 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
123 public int hashCode() {
124 final int prime
= 31;
125 int result
= super.hashCode();
126 result
= prime
* result
+ ((fChannels
== null) ?
0 : fChannels
.hashCode());
127 result
= prime
* result
+ (fIsKernel ?
1231 : 1237);
133 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
136 public boolean equals(Object obj
) {
140 if (!super.equals(obj
)) {
143 if (getClass() != obj
.getClass()) {
146 DomainInfo other
= (DomainInfo
) obj
;
147 if (fChannels
== null) {
148 if (other
.fChannels
!= null) {
151 } else if (!fChannels
.equals(other
.fChannels
)) {
154 if (fIsKernel
!= other
.fIsKernel
) {
162 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
164 @SuppressWarnings("nls")
166 public String
toString() {
167 StringBuffer output
= new StringBuffer();
168 output
.append("[DomainInfo(");
169 output
.append(super.toString());
170 output
.append(",Channels=");
171 if (fChannels
.isEmpty()) {
172 output
.append("None");
174 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
175 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
176 output
.append(channel
.toString());
179 output
.append(",isKernel=");
180 output
.append(String
.valueOf(fIsKernel
));
182 return output
.toString();
This page took 0.042258 seconds and 5 git commands to generate.