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