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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Iterator
;
17 import java
.util
.List
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
25 * Implementation of the trace session interface (ISessionInfo) to store session
29 * @author Bernd Hufmann
31 public class SessionInfo
extends TraceInfo
implements ISessionInfo
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * The trace session state.
39 private TraceSessionState fState
= TraceSessionState
.INACTIVE
;
41 * The trace session path for storing traces.
43 private String fSessionPath
= ""; //$NON-NLS-1$
45 * The domains information of this session.
47 private final List
<IDomainInfo
> fDomains
= new ArrayList
<IDomainInfo
>();
49 * Flag to indicate whether trace is streamed over network or not.
51 private boolean fIsStreamedTrace
= false;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * @param name - name of base event
60 public SessionInfo(String name
) {
66 * @param other - the instance to copy
68 public SessionInfo(SessionInfo other
) {
70 fState
= other
.fState
;
71 fSessionPath
= other
.fSessionPath
;
72 fIsStreamedTrace
= other
.fIsStreamedTrace
;
74 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
75 IDomainInfo domain
= iterator
.next();
76 if (domain
instanceof DomainInfo
) {
77 fDomains
.add(new DomainInfo((DomainInfo
)domain
));
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionState()
92 public TraceSessionState
getSessionState() {
98 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState)
101 public void setSessionState(TraceSessionState state
) {
107 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(java.lang.String)
110 public void setSessionState(String stateName
) {
111 if (TraceSessionState
.INACTIVE
.getInName().equals(stateName
)) {
112 fState
= TraceSessionState
.INACTIVE
;
113 } else if (TraceSessionState
.ACTIVE
.getInName().equals(stateName
)) {
114 fState
= TraceSessionState
.ACTIVE
;
120 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionPath()
123 public String
getSessionPath() {
129 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionPath(java.lang.String)
132 public void setSessionPath(String path
) {
138 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getDomains()
141 public IDomainInfo
[] getDomains() {
142 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
147 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setDomains(java.util.List)
150 public void setDomains(List
<IDomainInfo
> domains
) {
152 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
153 IDomainInfo domainInfo
= iterator
.next();
154 fDomains
.add(domainInfo
);
160 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo#isStreamedTrace()
163 public boolean isStreamedTrace() {
164 return fIsStreamedTrace
;
169 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo#setIsStreamedTrace(boolean)
173 public void setStreamedTrace(boolean isStreamedTrace
) {
174 fIsStreamedTrace
= isStreamedTrace
;
177 // ------------------------------------------------------------------------
179 // ------------------------------------------------------------------------
182 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#addDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo)
185 public void addDomain(IDomainInfo domainInfo
) {
186 fDomains
.add(domainInfo
);
191 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#hashCode()
194 public int hashCode() {
195 final int prime
= 31;
196 int result
= super.hashCode();
197 result
= prime
* result
+ fDomains
.hashCode();
198 result
= prime
* result
+ (fIsStreamedTrace ?
1231 : 1237);
199 result
= prime
* result
+ ((fSessionPath
== null) ?
0 : fSessionPath
.hashCode());
200 result
= prime
* result
+ ((fState
== null) ?
0 : fState
.hashCode());
206 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#equals(java.lang.Object)
209 public boolean equals(Object obj
) {
213 if (!super.equals(obj
)) {
216 if (getClass() != obj
.getClass()) {
219 SessionInfo other
= (SessionInfo
) obj
;
220 if (!fDomains
.equals(other
.fDomains
)) {
223 if (fIsStreamedTrace
!= other
.fIsStreamedTrace
) {
226 if (fSessionPath
== null) {
227 if (other
.fSessionPath
!= null) {
230 } else if (!fSessionPath
.equals(other
.fSessionPath
)) {
233 if (fState
!= other
.fState
) {
241 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
243 @SuppressWarnings("nls")
245 public String
toString() {
246 StringBuffer output
= new StringBuffer();
247 output
.append("[SessionInfo(");
248 output
.append(super.toString());
249 output
.append(",State=");
250 output
.append(fState
);
251 output
.append(",isStreamedTrace=");
252 output
.append(fIsStreamedTrace
);
253 output
.append(",Domains=");
254 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
255 IDomainInfo domain
= iterator
.next();
256 output
.append(domain
.toString());
259 return output
.toString();
This page took 0.036177 seconds and 5 git commands to generate.