Commit | Line | Data |
---|---|---|
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 | ||
13 | package org.eclipse.linuxtools.tmf.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.event.TmfEvent; | |
2fb2eb37 FC |
23 | import org.eclipse.linuxtools.tmf.request.ITmfDataRequest; |
24 | import org.eclipse.linuxtools.tmf.request.ITmfEventRequest; | |
d18dd09b ASL |
25 | import org.eclipse.linuxtools.tmf.tests.TmfCoreTestPlugin; |
26 | import org.eclipse.linuxtools.tmf.trace.ITmfContext; | |
27 | import org.eclipse.linuxtools.tmf.trace.TmfTraceStub; | |
28 | ||
29 | /** | |
30 | * <b><u>TmfEventProviderStub</u></b> | |
31 | * <p> | |
32 | * TODO: Implement me. Please. | |
33 | */ | |
34 | public class TmfEventProviderStub extends TmfEventProvider<TmfEvent> { | |
35 | ||
36 | private static final String DIRECTORY = "testfiles"; | |
85fb0e54 | 37 | private static final String TEST_STREAM = "A-Test-10K"; |
d18dd09b ASL |
38 | |
39 | private TmfTraceStub fTrace; | |
40 | ||
41 | public TmfEventProviderStub(String path) throws IOException { | |
fc6ccf6f | 42 | super(TmfEvent.class); |
cbd4ad82 | 43 | URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null); |
d18dd09b ASL |
44 | try { |
45 | File test = new File(FileLocator.toFileURL(location).toURI()); | |
46 | fTrace = new TmfTraceStub(test.getPath(), true); | |
47 | } catch (URISyntaxException e) { | |
48 | e.printStackTrace(); | |
49 | } | |
50 | } | |
51 | ||
52 | public TmfEventProviderStub() throws IOException { | |
53 | this(DIRECTORY + File.separator + TEST_STREAM); | |
54 | } | |
951d134a FC |
55 | |
56 | @Override | |
2fb2eb37 FC |
57 | public void dispose() { |
58 | fTrace.dispose(); | |
59 | super.dispose(); | |
951d134a | 60 | } |
d18dd09b ASL |
61 | |
62 | // ------------------------------------------------------------------------ | |
63 | // TmfEventProvider | |
64 | // ------------------------------------------------------------------------ | |
65 | ||
66 | @Override | |
2fb2eb37 FC |
67 | public ITmfContext armRequest(ITmfDataRequest<TmfEvent> request) { |
68 | if (request instanceof ITmfEventRequest<?>) { | |
69 | ITmfContext context = fTrace.seekEvent(((ITmfEventRequest<?>) request).getRange().getStartTime()); | |
d18dd09b ASL |
70 | return context; |
71 | } | |
72 | return null; | |
73 | } | |
74 | ||
75 | @Override | |
76 | public TmfEvent getNext(ITmfContext context) { | |
77 | return fTrace.getNext(context); | |
78 | } | |
79 | ||
80 | } |