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
;
22 * <b><u>DomainInfo</u></b>
24 * Implementation of the trace domain interface (IDomainInfo) to store domain
28 public class DomainInfo
extends TraceInfo
implements IDomainInfo
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 * The channels information of the domain.
36 private List
<IChannelInfo
> fChannels
= new ArrayList
<IChannelInfo
>();
37 private boolean fIsKernel
= false;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * @param name - name of domain
46 public DomainInfo(String name
) {
52 * @param other - the instance to copy
54 public DomainInfo(DomainInfo other
) {
56 for (int i
= 0; i
< other
.fChannels
.size(); i
++) {
57 if (other
.fChannels
.get(i
) instanceof ChannelInfo
) {
58 fChannels
.add(new ChannelInfo((ChannelInfo
)other
.fChannels
.get(i
)));
60 fChannels
.add(other
.fChannels
.get(i
));
63 fIsKernel
= other
.fIsKernel
;
68 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#isKernel()
71 public boolean isKernel() {
77 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
80 public void setIsKernel(boolean isKernel
) {
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#getChannels()
92 public IChannelInfo
[] getChannels() {
93 return fChannels
.toArray(new IChannelInfo
[fChannels
.size()]);
98 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setChannels(java.util.List)
101 public void setChannels(List
<IChannelInfo
> channels
) {
102 for (Iterator
<IChannelInfo
> iterator
= channels
.iterator(); iterator
.hasNext();) {
103 IChannelInfo channelInfo
= (IChannelInfo
) iterator
.next();
104 fChannels
.add(channelInfo
);
110 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo)
113 public void addChannel(IChannelInfo channel
) {
114 fChannels
.add(channel
);
119 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
122 public int hashCode() {
123 final int prime
= 31;
124 int result
= super.hashCode();
125 result
= prime
* result
+ ((fChannels
== null) ?
0 : fChannels
.hashCode());
126 result
= prime
* result
+ (fIsKernel ?
1231 : 1237);
132 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
135 public boolean equals(Object obj
) {
139 if (!super.equals(obj
)) {
142 if (getClass() != obj
.getClass()) {
145 DomainInfo other
= (DomainInfo
) obj
;
146 if (fChannels
== null) {
147 if (other
.fChannels
!= null) {
150 } else if (!fChannels
.equals(other
.fChannels
)) {
153 if (fIsKernel
!= other
.fIsKernel
) {
161 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
163 @SuppressWarnings("nls")
165 public String
toString() {
166 StringBuffer output
= new StringBuffer();
167 output
.append("[DomainInfo(");
168 output
.append(super.toString());
169 output
.append(",Channels=");
170 if (fChannels
.isEmpty()) {
171 output
.append("None");
173 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
174 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
175 output
.append(channel
.toString());
178 output
.append(",isKernel=");
179 output
.append(String
.valueOf(fIsKernel
));
181 return output
.toString();
This page took 0.043455 seconds and 6 git commands to generate.