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
CommitLineData
d18dd09b 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2009, 2015 Ericsson
54a7a54c 3 *
d18dd09b
ASL
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
54a7a54c 8 *
d18dd09b
ASL
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
2bdf0193 13package org.eclipse.tracecompass.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;
2bdf0193
AM
22import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
23import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
24import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
25import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
26import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
27import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
28import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
29import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
d18dd09b
ASL
30
31/**
32 * <b><u>TmfEventProviderStub</u></b>
33 * <p>
34 * TODO: Implement me. Please.
35 */
cad06250 36@SuppressWarnings("javadoc")
6256d8ad 37public class TmfEventProviderStub extends TmfEventProvider {
d18dd09b 38
d18dd09b
ASL
39 private TmfTraceStub fTrace;
40
085d898f 41 public TmfEventProviderStub(final String path) throws IOException {
2771b032 42 super(path, ITmfEvent.class);
085d898f
FC
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());
ab186fbb 46 fTrace = new TmfTraceStub(test.getPath(), 0, true, null);
b4f71e4a
FC
47 } catch (final TmfTraceException e) {
48 e.printStackTrace();
085d898f
FC
49 } catch (final URISyntaxException e) {
50 e.printStackTrace();
51 }
d18dd09b
ASL
52 }
53
54 public TmfEventProviderStub() throws IOException {
9c4d52ee 55 this(TmfTestTrace.A_TEST_10K.getFullPath());
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 68 @Override
fd3f1eff
AM
69 public ITmfContext armRequest(final ITmfEventRequest request) {
70 final ITmfContext context = fTrace.seekEvent(request.getRange().getStartTime());
71 return context;
085d898f 72 }
d18dd09b 73
085d898f 74 @Override
6256d8ad 75 public ITmfEvent getNext(final ITmfContext context) {
085d898f
FC
76 return fTrace.getNext(context);
77 }
d18dd09b 78
6badfac0 79 @Override
8a580390
BH
80 public boolean matches(ITmfEvent event) {
81 return (super.matches(event) || event.getTrace() == fTrace);
6badfac0
BH
82 }
83
6256d8ad 84}
This page took 0.10306 seconds and 5 git commands to generate.