analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core.tests / stubs / org / eclipse / tracecompass / tmf / tests / stubs / component / TmfEventProviderStub.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2015 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.tracecompass.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.tracecompass.tmf.core.component.TmfEventProvider;
23 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
24 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
25 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
26 import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
27 import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
28 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
29 import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
30
31 /**
32 * <b><u>TmfEventProviderStub</u></b>
33 * <p>
34 * TODO: Implement me. Please.
35 */
36 @SuppressWarnings("javadoc")
37 public class TmfEventProviderStub extends TmfEventProvider {
38
39 private TmfTraceStub fTrace;
40
41 public TmfEventProviderStub(final String path) throws IOException {
42 super(path, ITmfEvent.class);
43 final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
44 try {
45 final File test = new File(FileLocator.toFileURL(location).toURI());
46 fTrace = new TmfTraceStub(test.getPath(), 0, true, null);
47 } catch (final TmfTraceException e) {
48 e.printStackTrace();
49 } catch (final URISyntaxException e) {
50 e.printStackTrace();
51 }
52 }
53
54 public TmfEventProviderStub() throws IOException {
55 this(TmfTestTrace.A_TEST_10K.getFullPath());
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(final ITmfEventRequest request) {
70 final ITmfContext context = fTrace.seekEvent(request.getRange().getStartTime());
71 return context;
72 }
73
74 @Override
75 public ITmfEvent getNext(final ITmfContext context) {
76 return fTrace.getNext(context);
77 }
78
79 @Override
80 public boolean matches(ITmfEvent event) {
81 return (super.matches(event) || event.getTrace() == fTrace);
82 }
83
84 }
This page took 0.032247 seconds and 5 git commands to generate.