tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.core / src / org / eclipse / linuxtools / internal / lttng2 / core / control / model / impl / SessionInfo.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
14
15 import java.util.ArrayList;
16 import java.util.Iterator;
17 import java.util.List;
18
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;
22
23 /**
24 * <p>
25 * Implementation of the trace session interface (ISessionInfo) to store session
26 * related data.
27 * </p>
28 *
29 * @author Bernd Hufmann
30 */
31 public class SessionInfo extends TraceInfo implements ISessionInfo {
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36 /**
37 * The trace session state.
38 */
39 private TraceSessionState fState = TraceSessionState.INACTIVE;
40 /**
41 * The trace session path for storing traces.
42 */
43 private String fSessionPath = ""; //$NON-NLS-1$
44 /**
45 * The domains information of this session.
46 */
47 private final List<IDomainInfo> fDomains = new ArrayList<IDomainInfo>();
48 /**
49 * Flag to indicate whether trace is streamed over network or not.
50 */
51 private boolean fIsStreamedTrace = false;
52
53 // ------------------------------------------------------------------------
54 // Constructors
55 // ------------------------------------------------------------------------
56 /**
57 * Constructor
58 * @param name - name of base event
59 */
60 public SessionInfo(String name) {
61 super(name);
62 }
63
64 /**
65 * Copy constructor
66 * @param other - the instance to copy
67 */
68 public SessionInfo(SessionInfo other) {
69 super(other);
70 fState = other.fState;
71 fSessionPath = other.fSessionPath;
72 fIsStreamedTrace = other.fIsStreamedTrace;
73
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));
78 } else {
79 fDomains.add(domain);
80 }
81 }
82 }
83
84 // ------------------------------------------------------------------------
85 // Accessors
86 // ------------------------------------------------------------------------
87
88 @Override
89 public TraceSessionState getSessionState() {
90 return fState;
91 }
92
93 @Override
94 public void setSessionState(TraceSessionState state) {
95 fState = state;
96 }
97
98 @Override
99 public void setSessionState(String stateName) {
100 if (TraceSessionState.INACTIVE.getInName().equals(stateName)) {
101 fState = TraceSessionState.INACTIVE;
102 } else if (TraceSessionState.ACTIVE.getInName().equals(stateName)) {
103 fState = TraceSessionState.ACTIVE;
104 }
105 }
106
107 @Override
108 public String getSessionPath() {
109 return fSessionPath;
110 }
111
112 @Override
113 public void setSessionPath(String path) {
114 fSessionPath = path;
115 }
116
117 @Override
118 public IDomainInfo[] getDomains() {
119 return fDomains.toArray(new IDomainInfo[fDomains.size()]);
120 }
121
122 @Override
123 public void setDomains(List<IDomainInfo> domains) {
124 fDomains.clear();
125 for (Iterator<IDomainInfo> iterator = domains.iterator(); iterator.hasNext();) {
126 IDomainInfo domainInfo = iterator.next();
127 fDomains.add(domainInfo);
128 }
129 }
130
131 @Override
132 public boolean isStreamedTrace() {
133 return fIsStreamedTrace;
134 }
135
136 @Override
137 public void setStreamedTrace(boolean isStreamedTrace) {
138 fIsStreamedTrace = isStreamedTrace;
139 }
140
141 // ------------------------------------------------------------------------
142 // Operations
143 // ------------------------------------------------------------------------
144
145 @Override
146 public void addDomain(IDomainInfo domainInfo) {
147 fDomains.add(domainInfo);
148 }
149
150 @Override
151 public int hashCode() {
152 final int prime = 31;
153 int result = super.hashCode();
154 result = prime * result + fDomains.hashCode();
155 result = prime * result + (fIsStreamedTrace ? 1231 : 1237);
156 result = prime * result + ((fSessionPath == null) ? 0 : fSessionPath.hashCode());
157 result = prime * result + ((fState == null) ? 0 : fState.hashCode());
158 return result;
159 }
160
161 @Override
162 public boolean equals(Object obj) {
163 if (this == obj) {
164 return true;
165 }
166 if (!super.equals(obj)) {
167 return false;
168 }
169 if (getClass() != obj.getClass()) {
170 return false;
171 }
172 SessionInfo other = (SessionInfo) obj;
173 if (!fDomains.equals(other.fDomains)) {
174 return false;
175 }
176 if (fIsStreamedTrace != other.fIsStreamedTrace) {
177 return false;
178 }
179 if (fSessionPath == null) {
180 if (other.fSessionPath != null) {
181 return false;
182 }
183 } else if (!fSessionPath.equals(other.fSessionPath)) {
184 return false;
185 }
186 if (fState != other.fState) {
187 return false;
188 }
189 return true;
190 }
191
192 @SuppressWarnings("nls")
193 @Override
194 public String toString() {
195 StringBuffer output = new StringBuffer();
196 output.append("[SessionInfo(");
197 output.append(super.toString());
198 output.append(",State=");
199 output.append(fState);
200 output.append(",isStreamedTrace=");
201 output.append(fIsStreamedTrace);
202 output.append(",Domains=");
203 for (Iterator<IDomainInfo> iterator = fDomains.iterator(); iterator.hasNext();) {
204 IDomainInfo domain = iterator.next();
205 output.append(domain.toString());
206 }
207 output.append(")]");
208 return output.toString();
209 }
210 }
This page took 0.034767 seconds and 5 git commands to generate.