8ac03fbb9dc314783e540c52bbd75205728c07b7
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
.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
== null) ?
0 : 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
== null) {
157 if (other
.fEvents
!= null) {
160 } else if (!fEvents
.equals(other
.fEvents
)) {
163 if (fPid
!= other
.fPid
) {
171 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
173 @SuppressWarnings("nls")
175 public String
toString() {
176 StringBuffer output
= new StringBuffer();
177 output
.append("[EventInfo(");
178 output
.append(super.toString());
179 output
.append(",PID=");
181 output
.append(",Events=");
182 if (fEvents
.isEmpty()) {
183 output
.append("None");
185 for (Iterator
<IBaseEventInfo
> iterator
= fEvents
.iterator(); iterator
.hasNext();) {
186 IBaseEventInfo event
= iterator
.next();
187 output
.append(event
.toString());
191 return output
.toString();
This page took 0.033917 seconds and 4 git commands to generate.