Fix NLS-related Javadoc warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.core / src / org / eclipse / linuxtools / internal / lttng2 / core / control / model / impl / UstProviderInfo.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 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
13
14 import java.util.ArrayList;
15 import java.util.Iterator;
16 import java.util.List;
17
18 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
19 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
20
21 /**
22 * <p>
23 * Implementation of the Ust Provider interface (IUstProviderInfo) to store UST
24 * provider related data.
25 * </p>
26 *
27 * @author Bernd Hufmann
28 */
29 public class UstProviderInfo extends TraceInfo implements IUstProviderInfo {
30
31 // ------------------------------------------------------------------------
32 // Attributes
33 // ------------------------------------------------------------------------
34 /**
35 * The process ID of the UST provider.
36 */
37 private int fPid = 0;
38 /**
39 * List of event information.
40 */
41 private final List<IBaseEventInfo> fEvents = new ArrayList<IBaseEventInfo>();
42
43 // ------------------------------------------------------------------------
44 // Constructors
45 // ------------------------------------------------------------------------
46 /**
47 * Constructor
48 * @param name - name of UST provider
49 */
50 public UstProviderInfo(String name) {
51 super(name);
52 }
53
54 /**
55 * Copy constructor
56 * @param other - the instance to copy
57 */
58 public UstProviderInfo(UstProviderInfo other) {
59 super(other);
60 fPid = other.fPid;
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));
65 } else {
66 fEvents.add(event);
67 }
68 }
69 }
70
71 // ------------------------------------------------------------------------
72 // Accessors
73 // ------------------------------------------------------------------------
74
75 /*
76 * (non-Javadoc)
77 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#getPid()
78 */
79 @Override
80 public int getPid() {
81 return fPid;
82 }
83
84 /*
85 * (non-Javadoc)
86 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#setPid(int)
87 */
88 @Override
89 public void setPid(int pid) {
90 fPid = pid;
91 }
92
93 /*
94 * (non-Javadoc)
95 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#getEvents()
96 */
97 @Override
98 public IBaseEventInfo[] getEvents() {
99 return fEvents.toArray(new IBaseEventInfo[fEvents.size()]);
100 }
101
102 /*
103 * (non-Javadoc)
104 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#setEvents(java.util.List)
105 */
106 @Override
107 public void setEvents(List<IBaseEventInfo> events) {
108 fEvents.clear();
109 for (Iterator<IBaseEventInfo> iterator = events.iterator(); iterator.hasNext();) {
110 IBaseEventInfo eventInfo = iterator.next();
111 fEvents.add(eventInfo);
112 }
113 }
114
115 /*
116 * (non-Javadoc)
117 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IUstProviderInfo#addEvent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IBaseEventInfo)
118 */
119 @Override
120 public void addEvent(IBaseEventInfo event) {
121 fEvents.add(event);
122 }
123
124 // ------------------------------------------------------------------------
125 // Operations
126 // ------------------------------------------------------------------------
127
128 /*
129 * (non-Javadoc)
130 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
131 */
132 @Override
133 public int hashCode() {
134 final int prime = 31;
135 int result = super.hashCode();
136 result = prime * result + fEvents.hashCode();
137 result = prime * result + fPid;
138 return result;
139 }
140
141 /*
142 * (non-Javadoc)
143 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
144 */
145 @Override
146 public boolean equals(Object obj) {
147 if (this == obj) {
148 return true;
149 }
150 if (!super.equals(obj)) {
151 return false;
152 }
153 if (getClass() != obj.getClass()) {
154 return false;
155 }
156 UstProviderInfo other = (UstProviderInfo) obj;
157 if (!fEvents.equals(other.fEvents)) {
158 return false;
159 }
160 if (fPid != other.fPid) {
161 return false;
162 }
163 return true;
164 }
165
166 /*
167 * (non-Javadoc)
168 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
169 */
170 @SuppressWarnings("nls")
171 @Override
172 public String toString() {
173 StringBuffer output = new StringBuffer();
174 output.append("[EventInfo(");
175 output.append(super.toString());
176 output.append(",PID=");
177 output.append(fPid);
178 output.append(",Events=");
179 if (fEvents.isEmpty()) {
180 output.append("None");
181 } else {
182 for (Iterator<IBaseEventInfo> iterator = fEvents.iterator(); iterator.hasNext();) {
183 IBaseEventInfo event = iterator.next();
184 output.append(event.toString());
185 }
186 }
187 output.append(")]");
188 return output.toString();
189 }
190
191
192 }
This page took 0.036793 seconds and 5 git commands to generate.