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 **********************************************************************/
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
.IBaseEventInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.IUstProviderInfo
;
23 * Implementation of the Ust Provider interface (IUstProviderInfo) to store UST
24 * provider related data.
27 * @author Bernd Hufmann
29 public class UstProviderInfo
extends TraceInfo
implements IUstProviderInfo
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The process ID of the UST provider.
39 * List of event information.
41 private final List
<IBaseEventInfo
> fEvents
= new ArrayList
<IBaseEventInfo
>();
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
48 * @param name - name of UST provider
50 public UstProviderInfo(String name
) {
56 * @param other - the instance to copy
58 public UstProviderInfo(UstProviderInfo other
) {
61 for (Iterator
<IBaseEventInfo
> iterator
= other
.fEvents
.iterator(); iterator
.hasNext();) {
62 IBaseEventInfo event
= iterator
.next();
63 if (event
instanceof BaseEventInfo
) {
64 fEvents
.add(new BaseEventInfo((BaseEventInfo
)event
));
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
77 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#getPid()
86 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#setPid(int)
89 public void setPid(int pid
) {
95 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#getEvents()
98 public IBaseEventInfo
[] getEvents() {
99 return fEvents
.toArray(new IBaseEventInfo
[fEvents
.size()]);
104 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#setEvents(java.util.List)
107 public void setEvents(List
<IBaseEventInfo
> events
) {
108 for (Iterator
<IBaseEventInfo
> iterator
= events
.iterator(); iterator
.hasNext();) {
109 IBaseEventInfo eventInfo
= iterator
.next();
110 fEvents
.add(eventInfo
);
116 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo)
119 public void addEvent(IBaseEventInfo event
) {
123 // ------------------------------------------------------------------------
125 // ------------------------------------------------------------------------
129 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
132 public int hashCode() {
133 final int prime
= 31;
134 int result
= super.hashCode();
135 result
= prime
* result
+ fEvents
.hashCode();
136 result
= prime
* result
+ fPid
;
142 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
145 public boolean equals(Object obj
) {
149 if (!super.equals(obj
)) {
152 if (getClass() != obj
.getClass()) {
155 UstProviderInfo other
= (UstProviderInfo
) obj
;
156 if (!fEvents
.equals(other
.fEvents
)) {
159 if (fPid
!= other
.fPid
) {
167 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
169 @SuppressWarnings("nls")
171 public String
toString() {
172 StringBuffer output
= new StringBuffer();
173 output
.append("[EventInfo(");
174 output
.append(super.toString());
175 output
.append(",PID=");
177 output
.append(",Events=");
178 if (fEvents
.isEmpty()) {
179 output
.append("None");
181 for (Iterator
<IBaseEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
182 IBaseEventInfo event
= iterator
.next();
183 output
.append(event
.toString());
187 return output
.toString();
This page took 0.036098 seconds and 6 git commands to generate.