Improve package tangle index for LTTng 2.0 control design
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.core / src / org / eclipse / linuxtools / internal / lttng2 / core / control / model / impl / DomainInfo.java
CommitLineData
eb1bab5b
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
9315aeee 12package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
eb1bab5b
BH
13
14import java.util.ArrayList;
15import java.util.Iterator;
16import java.util.List;
17
9315aeee
BH
18import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
19import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
eb1bab5b
BH
20
21/**
22 * <b><u>DomainInfo</u></b>
23 * <p>
24 * Implementation of the trace domain interface (IDomainInfo) to store domain
25 * related data.
26 * </p>
27 */
28public class DomainInfo extends TraceInfo implements IDomainInfo {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33 /**
34 * The channels information of the domain.
35 */
36 private List<IChannelInfo> fChannels = new ArrayList<IChannelInfo>();
bbb3538a 37 private boolean fIsKernel = false;
eb1bab5b
BH
38
39 // ------------------------------------------------------------------------
40 // Constructors
41 // ------------------------------------------------------------------------
42 /**
43 * Constructor
44 * @param name - name of domain
45 */
46 public DomainInfo(String name) {
47 super(name);
48 }
49
50 /**
51 * Copy constructor
52 * @param other - the instance to copy
53 */
54 public DomainInfo(DomainInfo other) {
55 super(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)));
59 } else {
60 fChannels.add(other.fChannels.get(i));
61 }
62 }
bbb3538a
BH
63 fIsKernel = other.fIsKernel;
64 }
65
66 /*
67 * (non-Javadoc)
115b4a01 68 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#isKernel()
bbb3538a
BH
69 */
70 @Override
71 public boolean isKernel() {
72 return fIsKernel;
73 }
74
75 /*
76 * (non-Javadoc)
115b4a01 77 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
bbb3538a
BH
78 */
79 @Override
80 public void setIsKernel(boolean isKernel) {
81 fIsKernel = isKernel;
eb1bab5b
BH
82 }
83
84 // ------------------------------------------------------------------------
85 // Accessors
86 // ------------------------------------------------------------------------
87 /*
88 * (non-Javadoc)
115b4a01 89 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#getChannels()
eb1bab5b
BH
90 */
91 @Override
92 public IChannelInfo[] getChannels() {
93 return fChannels.toArray(new IChannelInfo[fChannels.size()]);
94 }
95
96 /*
97 * (non-Javadoc)
115b4a01 98 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#setChannels(java.util.List)
eb1bab5b
BH
99 */
100 @Override
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);
105 }
106 }
107
108 /*
109 * (non-Javadoc)
115b4a01 110 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo#addChannel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo)
eb1bab5b
BH
111 */
112 @Override
113 public void addChannel(IChannelInfo channel) {
114 fChannels.add(channel);
115 }
116
117 /*
118 * (non-Javadoc)
115b4a01 119 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
eb1bab5b
BH
120 */
121 @Override
122 public int hashCode() {
d132bcc7
BH
123 final int prime = 31;
124 int result = super.hashCode();
125 result = prime * result + ((fChannels == null) ? 0 : fChannels.hashCode());
126 result = prime * result + (fIsKernel ? 1231 : 1237);
eb1bab5b
BH
127 return result;
128 }
129
130 /*
131 * (non-Javadoc)
115b4a01 132 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
eb1bab5b
BH
133 */
134 @Override
d132bcc7
BH
135 public boolean equals(Object obj) {
136 if (this == obj) {
137 return true;
eb1bab5b 138 }
d132bcc7 139 if (!super.equals(obj)) {
eb1bab5b
BH
140 return false;
141 }
d132bcc7 142 if (getClass() != obj.getClass()) {
eb1bab5b
BH
143 return false;
144 }
d132bcc7
BH
145 DomainInfo other = (DomainInfo) obj;
146 if (fChannels == null) {
147 if (other.fChannels != null) {
eb1bab5b
BH
148 return false;
149 }
d132bcc7
BH
150 } else if (!fChannels.equals(other.fChannels)) {
151 return false;
eb1bab5b 152 }
d132bcc7 153 if (fIsKernel != other.fIsKernel) {
bbb3538a
BH
154 return false;
155 }
eb1bab5b
BH
156 return true;
157 }
d132bcc7 158
eb1bab5b
BH
159 /*
160 * (non-Javadoc)
115b4a01 161 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
eb1bab5b
BH
162 */
163 @SuppressWarnings("nls")
164 @Override
165 public String toString() {
166 StringBuffer output = new StringBuffer();
167 output.append("[DomainInfo(");
168 output.append(super.toString());
169 output.append(",Channels=");
170 if (fChannels.isEmpty()) {
171 output.append("None");
172 } else {
173 for (Iterator<IChannelInfo> iterator = fChannels.iterator(); iterator.hasNext();) {
174 IChannelInfo channel = (IChannelInfo) iterator.next();
175 output.append(channel.toString());
176 }
177 }
bbb3538a
BH
178 output.append(",isKernel=");
179 output.append(String.valueOf(fIsKernel));
eb1bab5b
BH
180 output.append(")]");
181 return output.toString();
182 }
d132bcc7 183
eb1bab5b 184}
This page took 0.065659 seconds and 5 git commands to generate.