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
>();
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
43 * @param name - name of domain
45 public DomainInfo(String name
) {
51 * @param other - the instance to copy
53 public DomainInfo(DomainInfo other
) {
55 for (int i
= 0; i
< other
.fChannels
.size(); i
++) {
56 if (other
.fChannels
.get(i
) instanceof ChannelInfo
) {
57 fChannels
.add(new ChannelInfo((ChannelInfo
)other
.fChannels
.get(i
)));
59 fChannels
.add(other
.fChannels
.get(i
));
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
69 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#getChannels()
72 public IChannelInfo
[] getChannels() {
73 return fChannels
.toArray(new IChannelInfo
[fChannels
.size()]);
78 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#setChannels(java.util.List)
81 public void setChannels(List
<IChannelInfo
> channels
) {
82 for (Iterator
<IChannelInfo
> iterator
= channels
.iterator(); iterator
.hasNext();) {
83 IChannelInfo channelInfo
= (IChannelInfo
) iterator
.next();
84 fChannels
.add(channelInfo
);
90 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo)
93 public void addChannel(IChannelInfo channel
) {
94 fChannels
.add(channel
);
99 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
102 public int hashCode() {
104 result
= 37 * result
+ super.hashCode();
105 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
106 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
107 result
= 37 * result
+ channel
.hashCode();
114 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
117 public boolean equals(Object other
) {
118 if (!(other
instanceof DomainInfo
)) {
122 DomainInfo otherInfo
= (DomainInfo
) other
;
123 if (!super.equals(otherInfo
)) {
127 if (fChannels
.size() != otherInfo
.fChannels
.size()) {
130 for (int i
= 0; i
< fChannels
.size(); i
++) {
131 if (!fChannels
.get(i
).equals(otherInfo
.fChannels
.get(i
))) {
140 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
142 @SuppressWarnings("nls")
144 public String
toString() {
145 StringBuffer output
= new StringBuffer();
146 output
.append("[DomainInfo(");
147 output
.append(super.toString());
148 output
.append(",Channels=");
149 if (fChannels
.isEmpty()) {
150 output
.append("None");
152 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
153 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
154 output
.append(channel
.toString());
158 return output
.toString();
This page took 0.034488 seconds and 6 git commands to generate.