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.ITraceInfo#formatString()
121 @SuppressWarnings("nls")
123 public String
formatString() {
124 StringBuffer output
= new StringBuffer();
125 //=== Domain: Kernel ===
126 output
.append("\n=== Domain: ");
127 output
.append(getName());
128 output
.append(" ===\n");
131 output
.append("Channels:\n");
133 output
.append("-------------");
134 if (fChannels
.isEmpty()) {
135 output
.append("\nNone");
137 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
138 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
139 output
.append(channel
.formatString());
143 return output
.toString();
148 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
151 public int hashCode() {
152 final int prime
= 31;
153 int result
= super.hashCode();
154 result
= prime
* result
+ ((fChannels
== null) ?
0 : fChannels
.hashCode());
155 result
= prime
* result
+ (fIsKernel ?
1231 : 1237);
161 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
164 public boolean equals(Object obj
) {
168 if (!super.equals(obj
)) {
171 if (getClass() != obj
.getClass()) {
174 DomainInfo other
= (DomainInfo
) obj
;
175 if (fChannels
== null) {
176 if (other
.fChannels
!= null) {
179 } else if (!fChannels
.equals(other
.fChannels
)) {
182 if (fIsKernel
!= other
.fIsKernel
) {
190 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
192 @SuppressWarnings("nls")
194 public String
toString() {
195 StringBuffer output
= new StringBuffer();
196 output
.append("[DomainInfo(");
197 output
.append(super.toString());
198 output
.append(",Channels=");
199 if (fChannels
.isEmpty()) {
200 output
.append("None");
202 for (Iterator
<IChannelInfo
> iterator
= fChannels
.iterator(); iterator
.hasNext();) {
203 IChannelInfo channel
= (IChannelInfo
) iterator
.next();
204 output
.append(channel
.toString());
207 output
.append(",isKernel=");
208 output
.append(String
.valueOf(fIsKernel
));
210 return output
.toString();
This page took 0.03653 seconds and 6 git commands to generate.