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
.IDomainInfo
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ISessionInfo
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceSessionState
;
23 * <b><u>SessionInfo</u></b>
25 * Implementation of the trace session interface (ISessionInfo) to store session
29 public class SessionInfo
extends TraceInfo
implements ISessionInfo
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The trace session state.
37 private TraceSessionState fState
= TraceSessionState
.INACTIVE
;
39 * The trace session path for storing traces.
41 private String fSessionPath
= ""; //$NON-NLS-1$
43 * The domains information of this session.
45 private List
<IDomainInfo
> fDomains
= new ArrayList
<IDomainInfo
>();
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
52 * @param name - name of base event
54 public SessionInfo(String name
) {
60 * @param other - the instance to copy
62 public SessionInfo(SessionInfo other
) {
64 fState
= other
.fState
;
65 fSessionPath
= other
.fSessionPath
;
67 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
68 IDomainInfo domain
= iterator
.next();
69 if (domain
instanceof DomainInfo
) {
70 fDomains
.add(new DomainInfo((DomainInfo
)domain
));
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#getSessionState()
85 public TraceSessionState
getSessionState() {
91 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#setSessionState(org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState)
94 public void setSessionState(TraceSessionState state
) {
100 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#setSessionState(java.lang.String)
103 public void setSessionState(String stateName
) {
104 if (TraceSessionState
.INACTIVE
.getInName().equals(stateName
)) {
105 fState
= TraceSessionState
.INACTIVE
;
106 } else if (TraceSessionState
.ACTIVE
.getInName().equals(stateName
)) {
107 fState
= TraceSessionState
.ACTIVE
;
113 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#getSessionPath()
116 public String
getSessionPath() {
122 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#setSessionPath(java.lang.String)
125 public void setSessionPath(String path
) {
131 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#getDomains()
134 public IDomainInfo
[] getDomains() {
135 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
140 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#setDomains(java.util.List)
143 public void setDomains(List
<IDomainInfo
> domains
) {
144 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
145 IDomainInfo domainInfo
= (IDomainInfo
) iterator
.next();
146 fDomains
.add(domainInfo
);
150 // ------------------------------------------------------------------------
152 // ------------------------------------------------------------------------
155 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo#addDomain(org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo)
158 public void addDomain(IDomainInfo domainInfo
) {
159 fDomains
.add(domainInfo
);
164 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#hashCode()
167 public int hashCode() {
169 result
= 37 * result
+ super.hashCode();
170 result
= 37 * result
+ fSessionPath
.hashCode();
171 result
= 37 * result
+ fState
.hashCode();
172 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
173 IDomainInfo domain
= (IDomainInfo
) iterator
.next();
174 result
= 37 * result
+ domain
.hashCode();
181 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
184 public boolean equals(Object other
) {
185 if (!(other
instanceof SessionInfo
)) {
188 SessionInfo otherInfo
= (SessionInfo
) other
;
189 if (!super.equals(otherInfo
)) {
193 if (!fSessionPath
.equals(otherInfo
.fSessionPath
)) {
197 if (fState
.ordinal() != otherInfo
.fState
.ordinal()) {
201 if (fDomains
.size() != otherInfo
.fDomains
.size()) {
204 for (int i
= 0; i
< fDomains
.size(); i
++) {
205 if (!fDomains
.get(i
).equals(otherInfo
.fDomains
.get(i
))) {
214 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceInfo#toString()
216 @SuppressWarnings("nls")
218 public String
toString() {
219 StringBuffer output
= new StringBuffer();
220 output
.append("[SessionInfo(");
221 output
.append(super.toString());
222 output
.append(",State=");
223 output
.append(fState
);
224 output
.append(",Domains=");
225 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
226 IDomainInfo channel
= (IDomainInfo
) iterator
.next();
227 output
.append(channel
.toString());
230 return output
.toString();
This page took 0.035531 seconds and 6 git commands to generate.