Refactor TmfTrace and dependencies - introduce ITmfTraceIndexer
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / stubs / org / eclipse / linuxtools / tmf / tests / stubs / component / TmfEventProviderStub.java
CommitLineData
d18dd09b
ASL
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
4918b8f2 13package org.eclipse.linuxtools.tmf.tests.stubs.component;
d18dd09b
ASL
14
15import java.io.File;
16import java.io.IOException;
17import java.net.URISyntaxException;
18import java.net.URL;
19
20import org.eclipse.core.runtime.FileLocator;
21import org.eclipse.core.runtime.Path;
6c13869b
FC
22import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
23import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
24import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
25import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
26import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
27import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
4918b8f2 28import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
d18dd09b
ASL
29
30/**
31 * <b><u>TmfEventProviderStub</u></b>
32 * <p>
33 * TODO: Implement me. Please.
34 */
3b38ea61 35@SuppressWarnings("nls")
d18dd09b
ASL
36public class TmfEventProviderStub extends TmfEventProvider<TmfEvent> {
37
38 private static final String DIRECTORY = "testfiles";
85fb0e54 39 private static final String TEST_STREAM = "A-Test-10K";
d18dd09b
ASL
40
41 private TmfTraceStub fTrace;
42
085d898f
FC
43 public TmfEventProviderStub(final String path) throws IOException {
44 super(path, TmfEvent.class);
45 final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
46 try {
47 final File test = new File(FileLocator.toFileURL(location).toURI());
20658947 48 fTrace = new TmfTraceStub(test.getPath(), 0, true);
085d898f
FC
49 } catch (final URISyntaxException e) {
50 e.printStackTrace();
51 }
d18dd09b
ASL
52 }
53
54 public TmfEventProviderStub() throws IOException {
085d898f 55 this(DIRECTORY + File.separator + TEST_STREAM);
d18dd09b 56 }
951d134a
FC
57
58 @Override
2fb2eb37 59 public void dispose() {
085d898f
FC
60 fTrace.dispose();
61 super.dispose();
951d134a 62 }
085d898f 63
d18dd09b
ASL
64 // ------------------------------------------------------------------------
65 // TmfEventProvider
66 // ------------------------------------------------------------------------
67
085d898f
FC
68 @Override
69 public ITmfContext armRequest(final ITmfDataRequest<TmfEvent> request) {
70 if (request instanceof ITmfEventRequest<?>) {
71 final ITmfContext context = fTrace.seekEvent(((ITmfEventRequest<?>) request).getRange().getStartTime());
72 return context;
73 }
74 return null;
75 }
d18dd09b 76
085d898f
FC
77 @Override
78 public TmfEvent getNext(final ITmfContext context) {
79 return fTrace.getNext(context);
80 }
d18dd09b
ASL
81
82}
This page took 0.038823 seconds and 5 git commands to generate.