tmf: Fix regression in event requests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / stubs / org / eclipse / linuxtools / tmf / tests / stubs / component / TmfDataProviderStub.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.tests.stubs.component;
14
15 import java.io.File;
16 import java.io.IOException;
17 import java.net.URISyntaxException;
18 import java.net.URL;
19
20 import org.eclipse.core.runtime.FileLocator;
21 import org.eclipse.core.runtime.Path;
22 import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
23 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
24 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
25 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
26 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
27 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
28 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
29 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
30 import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
31
32 /**
33 * <b><u>TmfDataProviderStub</u></b>
34 * <p>
35 * TODO: Implement me. Please.
36 */
37 @SuppressWarnings({"nls","javadoc"})
38 public class TmfDataProviderStub extends TmfDataProvider {
39
40 private static final String DIRECTORY = "testfiles";
41 private static final String TEST_STREAM = "M-Test-10K";
42
43 private TmfTraceStub fTrace;
44
45 public TmfDataProviderStub(final String path) throws IOException {
46 super("TmfDataProviderStub", TmfEvent.class);
47 final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
48 try {
49 final File test = new File(FileLocator.toFileURL(location).toURI());
50 fTrace = new TmfTraceStub(test.getPath(), 0, true);
51 } catch (final TmfTraceException e) {
52 e.printStackTrace();
53 } catch (final URISyntaxException e) {
54 e.printStackTrace();
55 }
56 }
57
58 public TmfDataProviderStub() throws IOException {
59 this(DIRECTORY + File.separator + TEST_STREAM);
60 }
61
62 // ------------------------------------------------------------------------
63 // TmfProvider
64 // ------------------------------------------------------------------------
65
66 @Override
67 public ITmfContext armRequest(final ITmfDataRequest request) {
68 if (request instanceof ITmfEventRequest) {
69 final ITmfContext context = fTrace.seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
70 return context;
71 }
72 return null;
73 }
74
75 @Override
76 public ITmfEvent getNext(final ITmfContext context) {
77 return fTrace.getNext(context);
78 }
79
80 @Override
81 public boolean isCompleted(final ITmfDataRequest request, final ITmfEvent data, final int nbRead) {
82 return false;
83 }
84
85 }
This page took 0.036957 seconds and 5 git commands to generate.