Fix a pile of Javadoc warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / request / TmfEventRequest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.core.request;
14
15 import org.eclipse.linuxtools.internal.tmf.core.Tracer;
16 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
17 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
18
19 /**
20 * An extension of TmfDataRequest for timestamped events.
21 *
22 * @param <T> The request event type
23 *
24 * @version 1.0
25 * @author Francois Chouinard
26 */
27 public abstract class TmfEventRequest<T extends ITmfEvent> extends TmfDataRequest<T> implements ITmfEventRequest<T> {
28
29 // ------------------------------------------------------------------------
30 // Attributes
31 // ------------------------------------------------------------------------
32
33 private final TmfTimeRange fRange; // The requested events time range
34
35 // ------------------------------------------------------------------------
36 // Constructors
37 // ------------------------------------------------------------------------
38
39 /**
40 * Request all the events of a given type (high priority)
41 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
42 *
43 * @param dataType the requested data type
44 */
45 public TmfEventRequest(Class<T> dataType) {
46 this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
47 }
48
49 /**
50 * Request all the events of a given type (given priority)
51 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
52 *
53 * @param dataType the requested data type
54 * @param priority the requested execution priority
55 */
56 public TmfEventRequest(Class<T> dataType, ExecutionType priority) {
57 this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
58 }
59
60 /**
61 * Request all the events of a given type for the given time range (high priority)
62 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
63 *
64 * @param dataType the requested data type
65 * @param range the time range of the requested events
66 */
67 public TmfEventRequest(Class<T> dataType, TmfTimeRange range) {
68 this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
69 }
70
71 /**
72 * Request all the events of a given type for the given time range (given priority)
73 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
74 *
75 * @param dataType the requested data type
76 * @param range the time range of the requested events
77 * @param priority the requested execution priority
78 */
79 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, ExecutionType priority) {
80 this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
81 }
82
83 /**
84 * Request 'n' events of a given type from the given time range (high priority)
85 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
86 *
87 * @param dataType the requested data type
88 * @param range the time range of the requested events
89 * @param nbRequested the number of events requested
90 */
91 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested) {
92 this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
93 }
94
95 /**
96 * Request 'n' events of a given type for the given time range (given priority)
97 * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
98 *
99 * @param dataType the requested data type
100 * @param range the time range of the requested events
101 * @param nbRequested the number of events requested
102 * @param priority the requested execution priority
103 */
104 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, ExecutionType priority) {
105 this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, priority);
106 }
107
108 /**
109 * Request 'n' events of a given type for the given time range (high priority).
110 * Events are returned in blocks of the given size.
111 *
112 * @param dataType the requested data type
113 * @param range the time range of the requested events
114 * @param nbRequested the number of events requested
115 * @param blockSize the number of events per block
116 */
117 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize) {
118 this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
119 }
120
121 /**
122 * Request 'n' events of a given type for the given time range (high priority).
123 * Events are returned in blocks of the given size.
124 *
125 * @param dataType the requested data type
126 * @param range the time range of the requested events
127 * @param index the index of the first event to retrieve
128 * @param nbRequested the number of events requested
129 * @param blockSize the number of events per block
130 */
131 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize) {
132 this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
133 }
134
135 /**
136 * Request 'n' events of a given type for the given time range (given priority).
137 * Events are returned in blocks of the given size.
138 *
139 * @param dataType the requested data type
140 * @param range the time range of the requested events
141 * @param nbRequested the number of events requested
142 * @param blockSize the number of events per block
143 * @param priority the requested execution priority
144 */
145 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType priority) {
146 this(dataType, range, 0, nbRequested, blockSize, priority);
147 }
148
149 /**
150 * Request 'n' events of a given type for the given time range (given priority).
151 * Events are returned in blocks of the given size.
152 *
153 * @param dataType the requested data type
154 * @param range the time range of the requested events
155 * @param index the index of the first event to retrieve
156 * @param nbRequested the number of events requested
157 * @param blockSize the number of events per block
158 * @param priority the requested execution priority
159 */
160 public TmfEventRequest(Class<T> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize, ExecutionType priority) {
161 super(dataType, index, nbRequested, blockSize, priority);
162 fRange = range;
163
164 if (Tracer.isRequestTraced()) {
165 String type = getClass().getName();
166 type = type.substring(type.lastIndexOf('.') + 1);
167 @SuppressWarnings("nls")
168 String message = "CREATED "
169 + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
170 + " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
171 + " Range=" + getRange()
172 + " DataType=" + getDataType().getSimpleName();
173 Tracer.traceRequest(this, message);
174 }
175 }
176
177 // ------------------------------------------------------------------------
178 // Accessors
179 // ------------------------------------------------------------------------
180
181 /**
182 * @return the requested time range
183 */
184 @Override
185 public TmfTimeRange getRange() {
186 return fRange;
187 }
188
189 // ------------------------------------------------------------------------
190 // Setters
191 // ------------------------------------------------------------------------
192
193 /**
194 * this method is called by the event provider to set the index corresponding
195 * to the time range start time once it is known
196 *
197 * @param index the start index
198 */
199 @Override
200 public void setStartIndex(int index) {
201 setIndex(index);
202 }
203
204 // ------------------------------------------------------------------------
205 // Object
206 // ------------------------------------------------------------------------
207
208 @Override
209 // All requests have a unique id
210 public int hashCode() {
211 return getRequestId();
212 }
213
214 @Override
215 public boolean equals(Object other) {
216 if (other instanceof TmfEventRequest<?>) {
217 TmfEventRequest<?> request = (TmfEventRequest<?>) other;
218 return super.equals(other) && request.fRange.equals(fRange);
219 }
220 return false;
221 }
222
223 @Override
224 @SuppressWarnings("nls")
225 public String toString() {
226 return "[TmfEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
227 + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
228 }
229
230 }
This page took 0.03642 seconds and 6 git commands to generate.