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
.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.lttng.ui.views.control.model.IDomainInfo#isKernel()
71 public boolean isKernel() {
77 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
80 public void setIsKernel(boolean isKernel
) {
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#getChannels()
92 public IChannelInfo
[] getChannels() {
93 return fChannels
.toArray(new IChannelInfo
[fChannels
.size()]);
98 * @see org.eclipse.linuxtools.lttng.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.lttng.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo)
113 public void addChannel(IChannelInfo channel
) {
114 fChannels
.add(channel
);
119 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
122 public int hashCode() {
124 result
= 37 * result
+ super.hashCode();
125 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
126 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
127 result
= 37 * result
+ channel
.hashCode();
129 result
+= 37 * result
+ (fIsKernel ?
1 : 0);
135 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
138 public boolean equals(Object other
) {
139 if (!(other
instanceof DomainInfo
)) {
143 DomainInfo otherInfo
= (DomainInfo
) other
;
144 if (!super.equals(otherInfo
)) {
148 if (fChannels
.size() != otherInfo
.fChannels
.size()) {
151 for (int i
= 0; i
< fChannels
.size(); i
++) {
152 if (!fChannels
.get(i
).equals(otherInfo
.fChannels
.get(i
))) {
157 if (fIsKernel
!= otherInfo
.fIsKernel
) {
165 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
167 @SuppressWarnings("nls")
169 public String
toString() {
170 StringBuffer output
= new StringBuffer();
171 output
.append("[DomainInfo(");
172 output
.append(super.toString());
173 output
.append(",Channels=");
174 if (fChannels
.isEmpty()) {
175 output
.append("None");
177 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
178 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
179 output
.append(channel
.toString());
182 output
.append(",isKernel=");
183 output
.append(String
.valueOf(fIsKernel
));
185 return output
.toString();
This page took 0.034872 seconds and 6 git commands to generate.