[Bug304438] Introduced TmfLocation
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.tests / stubs / org / eclipse / linuxtools / tmf / component / TmfProviderStub.java
CommitLineData
e31e01e8
FC
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
13package org.eclipse.linuxtools.tmf.component;
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;
22import org.eclipse.linuxtools.tmf.event.TmfEvent;
23import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
24import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
25import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
26import org.eclipse.linuxtools.tmf.tests.TmfCoreTestPlugin;
9f584e4c
FC
27import org.eclipse.linuxtools.tmf.trace.ITmfContext;
28import org.eclipse.linuxtools.tmf.trace.TmfContext;
e31e01e8
FC
29import org.eclipse.linuxtools.tmf.trace.TmfTraceStub;
30
31/**
32 * <b><u>TmfProviderStub</u></b>
33 * <p>
34 * TODO: Implement me. Please.
35 */
36public class TmfProviderStub extends TmfProvider<TmfEvent> {
37
38 private TmfTraceStub fTrace;
39
40 public TmfProviderStub(String path) throws IOException {
41 super(TmfEvent.class);
42 URL location = FileLocator.find(TmfCoreTestPlugin.getPlugin().getBundle(), new Path(path), null);
43 try {
44 File test = new File(FileLocator.toFileURL(location).toURI());
45 fTrace = new TmfTraceStub(test.getPath(), true);
46 } catch (URISyntaxException e) {
47 e.printStackTrace();
48 }
49 }
50
51 @Override
52 public ITmfContext setContext(TmfDataRequest<TmfEvent> request) {
53 if (request instanceof TmfEventRequest<?>) {
9f584e4c 54 TmfContext context = fTrace.seekEvent(((TmfEventRequest<?>) request).getRange().getStartTime());
e31e01e8
FC
55 return context;
56 }
57 return null;
58 }
59
60 @Override
61 public TmfEvent getNext(ITmfContext context) {
62 return fTrace.getNext(context);
63 }
64
65 @Override
66 public boolean isCompleted(TmfDataRequest<TmfEvent> request, TmfEvent event) {
67 TmfTimestamp endTime = ((TmfEventRequest<?>) request).getRange().getEndTime();
68 return event.getTimestamp().compareTo(endTime, false) <= 0;
69 }
70
71}
This page took 0.029689 seconds and 5 git commands to generate.