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
.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
.internal
.lttng2
.ui
.views
.control
.model
.IDomainInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ISessionInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.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.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionState()
85 public TraceSessionState
getSessionState() {
91 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionState(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState)
94 public void setSessionState(TraceSessionState state
) {
100 * @see org.eclipse.linuxtools.internal.lttng2.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.internal.lttng2.ui.views.control.model.ISessionInfo#getSessionPath()
116 public String
getSessionPath() {
122 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#setSessionPath(java.lang.String)
125 public void setSessionPath(String path
) {
131 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo#getDomains()
134 public IDomainInfo
[] getDomains() {
135 return fDomains
.toArray(new IDomainInfo
[fDomains
.size()]);
140 * @see org.eclipse.linuxtools.internal.lttng2.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.internal.lttng2.ui.views.control.model.ISessionInfo#addDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo)
158 public void addDomain(IDomainInfo domainInfo
) {
159 fDomains
.add(domainInfo
);
164 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceInfo#formatString()
167 @SuppressWarnings("nls")
168 public String
formatString() {
169 StringBuffer output
= new StringBuffer();
170 // Tracing session mysession: [active]
171 output
.append("Tracing session ");
172 output
.append(getName());
173 output
.append(": [");
174 output
.append(getSessionState().getInName());
175 output
.append("]\n");
177 // Trace path: /home/user/lttng-traces/mysession-20120129-084256
178 output
.append(" Trace path: ");
179 output
.append(getSessionPath());
182 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
183 IDomainInfo domain
= (IDomainInfo
) iterator
.next();
184 output
.append(domain
.formatString());
186 return output
.toString();
191 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
194 public int hashCode() {
195 final int prime
= 31;
196 int result
= super.hashCode();
197 result
= prime
* result
+ ((fDomains
== null) ?
0 : fDomains
.hashCode());
198 result
= prime
* result
+ ((fSessionPath
== null) ?
0 : fSessionPath
.hashCode());
199 result
= prime
* result
+ ((fState
== null) ?
0 : (fState
.ordinal() + 1));
205 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
208 public boolean equals(Object obj
) {
212 if (!super.equals(obj
)) {
215 if (getClass() != obj
.getClass()) {
218 SessionInfo other
= (SessionInfo
) obj
;
219 if (fDomains
== null) {
220 if (other
.fDomains
!= null) {
223 } else if (!fDomains
.equals(other
.fDomains
)) {
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(",Domains=");
252 for (Iterator
<IDomainInfo
> iterator
= fDomains
.iterator(); iterator
.hasNext();) {
253 IDomainInfo domain
= (IDomainInfo
) iterator
.next();
254 output
.append(domain
.toString());
257 return output
.toString();
This page took 0.062654 seconds and 5 git commands to generate.