8a39349d26df83fddb4f4ff9ae2a87b24a648b66
1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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 final 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
;
68 public boolean isKernel() {
73 public void setIsKernel(boolean isKernel
) {
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 public IChannelInfo
[] getChannels() {
83 return fChannels
.toArray(new IChannelInfo
[fChannels
.size()]);
87 public void setChannels(List
<IChannelInfo
> channels
) {
89 for (Iterator
<IChannelInfo
> iterator
= channels
.iterator(); iterator
.hasNext();) {
90 IChannelInfo channelInfo
= iterator
.next();
91 fChannels
.add(channelInfo
);
96 public void addChannel(IChannelInfo channel
) {
97 fChannels
.add(channel
);
101 public int hashCode() {
102 final int prime
= 31;
103 int result
= super.hashCode();
104 result
= prime
* result
+ fChannels
.hashCode();
105 result
= prime
* result
+ (fIsKernel ?
1231 : 1237);
110 public boolean equals(Object obj
) {
114 if (!super.equals(obj
)) {
117 if (getClass() != obj
.getClass()) {
120 DomainInfo other
= (DomainInfo
) obj
;
121 if (!fChannels
.equals(other
.fChannels
)) {
124 if (fIsKernel
!= other
.fIsKernel
) {
130 @SuppressWarnings("nls")
132 public String
toString() {
133 StringBuffer output
= new StringBuffer();
134 output
.append("[DomainInfo(");
135 output
.append(super.toString());
136 output
.append(",Channels=");
137 if (fChannels
.isEmpty()) {
138 output
.append("None");
140 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
141 IChannelInfo channel
= iterator
.next();
142 output
.append(channel
.toString());
145 output
.append(",isKernel=");
146 output
.append(String
.valueOf(fIsKernel
));
148 return output
.toString();
This page took 0.033332 seconds and 4 git commands to generate.