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
.internal
.lttng2
.core
.control
.model
.impl
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IDomainInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
24 * Implementation of the trace session interface (ISessionInfo) to store session
28 * @author Bernd Hufmann
30 public class SessionInfo
extends TraceInfo
implements ISessionInfo
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * The trace session state.
38 private TraceSessionState fState
= TraceSessionState
.INACTIVE
;
40 * The trace session path for storing traces.
42 private String fSessionPath
= ""; //$NON-NLS-1$
44 * The domains information of this session.
46 private final List
<IDomainInfo
> fDomains
= new ArrayList
<IDomainInfo
>();
48 * Flag to indicate whether trace is streamed over network or not.
50 private boolean fIsStreamedTrace
= false;
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
57 * @param name - name of base event
59 public SessionInfo(String name
) {
65 * @param other - the instance to copy
67 public SessionInfo(SessionInfo other
) {
69 fState
= other
.fState
;
70 fSessionPath
= other
.fSessionPath
;
71 fIsStreamedTrace
= other
.fIsStreamedTrace
;
73 for (Iterator
<IDomainInfo
> iterator
= other
.fDomains
.iterator(); iterator
.hasNext();) {
74 IDomainInfo domain
= iterator
.next();
75 if (domain
instanceof DomainInfo
) {
76 fDomains
.add(new DomainInfo((DomainInfo
)domain
));
83 // ------------------------------------------------------------------------
85 // ------------------------------------------------------------------------
88 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionState()
91 public TraceSessionState
getSessionState() {
97 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState)
100 public void setSessionState(TraceSessionState state
) {
106 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(java.lang.String)
109 public void setSessionState(String stateName
) {
110 if (TraceSessionState
.INACTIVE
.getInName().equals(stateName
)) {
111 fState
= TraceSessionState
.INACTIVE
;
112 } else if (TraceSessionState
.ACTIVE
.getInName().equals(stateName
)) {
113 fState
= TraceSessionState
.ACTIVE
;
119 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionPath()
122 public String
getSessionPath() {
128 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionPath(java.lang.String)
131 public void setSessionPath(String path
) {
137 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getDomains()
140 public IDomainInfo
[] getDomains() {
141 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
146 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setDomains(java.util.List)
149 public void setDomains(List
<IDomainInfo
> domains
) {
150 for (Iterator
<IDomainInfo
> iterator
= domains
.iterator(); iterator
.hasNext();) {
151 IDomainInfo domainInfo
= iterator
.next();
152 fDomains
.add(domainInfo
);
158 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo#isStreamedTrace()
161 public boolean isStreamedTrace() {
162 return fIsStreamedTrace
;
167 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo#setIsStreamedTrace(boolean)
171 public void setStreamedTrace(boolean isStreamedTrace
) {
172 fIsStreamedTrace
= isStreamedTrace
;
175 // ------------------------------------------------------------------------
177 // ------------------------------------------------------------------------
180 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#addDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo)
183 public void addDomain(IDomainInfo domainInfo
) {
184 fDomains
.add(domainInfo
);
189 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#hashCode()
192 public int hashCode() {
193 final int prime
= 31;
194 int result
= super.hashCode();
195 result
= prime
* result
+ fDomains
.hashCode();
196 result
= prime
* result
+ (fIsStreamedTrace ?
1231 : 1237);
197 result
= prime
* result
+ ((fSessionPath
== null) ?
0 : fSessionPath
.hashCode());
198 result
= prime
* result
+ ((fState
== null) ?
0 : fState
.hashCode());
204 * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#equals(java.lang.Object)
207 public boolean equals(Object obj
) {
211 if (!super.equals(obj
)) {
214 if (getClass() != obj
.getClass()) {
217 SessionInfo other
= (SessionInfo
) obj
;
218 if (!fDomains
.equals(other
.fDomains
)) {
221 if (fIsStreamedTrace
!= other
.fIsStreamedTrace
) {
224 if (fSessionPath
== null) {
225 if (other
.fSessionPath
!= null) {
228 } else if (!fSessionPath
.equals(other
.fSessionPath
)) {
231 if (fState
!= other
.fState
) {
239 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
241 @SuppressWarnings("nls")
243 public String
toString() {
244 StringBuffer output
= new StringBuffer();
245 output
.append("[SessionInfo(");
246 output
.append(super.toString());
247 output
.append(",State=");
248 output
.append(fState
);
249 output
.append(",Domains=");
250 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
251 IDomainInfo domain
= iterator
.next();
252 output
.append(domain
.toString());
255 return output
.toString();
This page took 0.054915 seconds and 5 git commands to generate.