1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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
.control
.core
.model
.impl
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.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
<>();
38 private boolean fIsKernel
= false;
39 private BufferType fBufferType
= BufferType
.BUFFER_TYPE_UNKNOWN
;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
46 * @param name - name of domain
48 public DomainInfo(String name
) {
54 * @param other - the instance to copy
56 public DomainInfo(DomainInfo other
) {
58 for (int i
= 0; i
< other
.fChannels
.size(); i
++) {
59 if (other
.fChannels
.get(i
) instanceof ChannelInfo
) {
60 fChannels
.add(new ChannelInfo((ChannelInfo
)other
.fChannels
.get(i
)));
62 fChannels
.add(other
.fChannels
.get(i
));
65 fIsKernel
= other
.fIsKernel
;
66 fBufferType
= other
.fBufferType
;
70 public boolean isKernel() {
75 public void setIsKernel(boolean isKernel
) {
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 public IChannelInfo
[] getChannels() {
85 return fChannels
.toArray(new IChannelInfo
[fChannels
.size()]);
89 public void setChannels(List
<IChannelInfo
> channels
) {
91 for (Iterator
<IChannelInfo
> iterator
= channels
.iterator(); iterator
.hasNext();) {
92 IChannelInfo channelInfo
= iterator
.next();
93 fChannels
.add(channelInfo
);
98 public void addChannel(IChannelInfo channel
) {
99 fChannels
.add(channel
);
103 public int hashCode() {
104 final int prime
= 31;
105 int result
= super.hashCode();
106 result
= prime
* result
+ fChannels
.hashCode();
107 result
= prime
* result
+ (fIsKernel ?
1231 : 1237);
108 result
= prime
* result
+ ((fBufferType
== null) ?
0 : (fBufferType
.ordinal() + 1));
113 public boolean equals(Object obj
) {
117 if (!super.equals(obj
)) {
120 if (getClass() != obj
.getClass()) {
123 DomainInfo other
= (DomainInfo
) obj
;
124 if (!fChannels
.equals(other
.fChannels
)) {
127 if (fIsKernel
!= other
.fIsKernel
) {
130 if (fBufferType
!= other
.fBufferType
) {
137 public BufferType
getBufferType() {
139 return BufferType
.BUFFER_SHARED
;
145 public void setBufferType(BufferType bufferType
) {
146 fBufferType
= bufferType
;
149 @SuppressWarnings("nls")
151 public String
toString() {
152 StringBuffer output
= new StringBuffer();
153 output
.append("[DomainInfo(");
154 output
.append(super.toString());
155 output
.append(",Channels=");
156 if (fChannels
.isEmpty()) {
157 output
.append("None");
159 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
160 IChannelInfo channel
= iterator
.next();
161 output
.append(channel
.toString());
164 output
.append(",isKernel=");
165 output
.append(String
.valueOf(fIsKernel
));
166 if ((fBufferType
!= null) && !fBufferType
.equals(BufferType
.BUFFER_TYPE_UNKNOWN
) && !fBufferType
.equals(BufferType
.BUFFER_SHARED
)) {
167 output
.append(",BufferType=");
168 output
.append(fBufferType
);
171 return output
.toString();
This page took 0.04407 seconds and 5 git commands to generate.