Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / stubs / org / eclipse / linuxtools / tmf / stubs / component / TmfEventProviderStub.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.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.TmfEventProvider;
23 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
24 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
25 import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
26 import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
27 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
28 import org.eclipse.linuxtools.tmf.stubs.trace.TmfTraceStub;
29
30 /**
31 * <b><u>TmfEventProviderStub</u></b>
32 * <p>
33 * TODO: Implement me. Please.
34 */
35 @SuppressWarnings("nls")
36 public class TmfEventProviderStub extends TmfEventProvider<TmfEvent> {
37
38 private static final String DIRECTORY = "testfiles";
39 private static final String TEST_STREAM = "A-Test-10K";
40
41 private TmfTraceStub fTrace;
42
43 public TmfEventProviderStub(String path) throws IOException {
44 super(path, TmfEvent.class);
45 URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
46 try {
47 File test = new File(FileLocator.toFileURL(location).toURI());
48 fTrace = new TmfTraceStub(test.getPath(), true);
49 } catch (URISyntaxException e) {
50 e.printStackTrace();
51 }
52 }
53
54 public TmfEventProviderStub() throws IOException {
55 this(DIRECTORY + File.separator + TEST_STREAM);
56 }
57
58 @Override
59 public void dispose() {
60 fTrace.dispose();
61 super.dispose();
62 }
63
64 // ------------------------------------------------------------------------
65 // TmfEventProvider
66 // ------------------------------------------------------------------------
67
68 @Override
69 public ITmfContext armRequest(ITmfDataRequest<TmfEvent> request) {
70 if (request instanceof ITmfEventRequest<?>) {
71 ITmfContext context = fTrace.seekEvent(((ITmfEventRequest<?>) request).getRange().getStartTime());
72 return context;
73 }
74 return null;
75 }
76
77 @Override
78 public TmfEvent getNext(ITmfContext context) {
79 return fTrace.getNext(context);
80 }
81
82 }
This page took 0.036012 seconds and 6 git commands to generate.