- Introduced TmfExperiment (single trace for now)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.tests / stubs / org / eclipse / linuxtools / tmf / trace / TmfEventStreamStub.java
CommitLineData
4c5b8099
FC
1/*******************************************************************************
2 * Copyright (c) 2009 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:
165c977c 10 * Francois Chouinard - Initial API and implementation
4c5b8099
FC
11 *******************************************************************************/
12
165c977c 13package org.eclipse.linuxtools.tmf.trace;
4c5b8099
FC
14
15import java.io.FileNotFoundException;
16import java.io.IOException;
165c977c
FC
17import java.io.RandomAccessFile;
18import java.util.Map;
19
4c5b8099
FC
20
21/**
22 * <b><u>TmfEventStreamStub</u></b>
23 * <p>
24 * TODO: Implement me. Please.
25 */
62d1696a 26public class TmfEventStreamStub extends TmfTrace {
4c5b8099
FC
27
28 // ========================================================================
29 // Attributes
30 // ========================================================================
31
165c977c
FC
32 // The actual stream
33 private final RandomAccessFile fStream;
34
4c5b8099
FC
35 // ========================================================================
36 // Constructors
37 // ========================================================================
38
165c977c 39 /**
4c5b8099 40 * @param filename
165c977c
FC
41 * @param parser
42 * @throws FileNotFoundException
4c5b8099
FC
43 */
44 public TmfEventStreamStub(String filename, ITmfEventParser parser) throws FileNotFoundException {
165c977c 45 this(filename, parser, DEFAULT_CACHE_SIZE);
4c5b8099
FC
46 }
47
48 /**
49 * @param filename
165c977c
FC
50 * @param parser
51 * @param cacheSize
52 * @throws FileNotFoundException
4c5b8099
FC
53 */
54 public TmfEventStreamStub(String filename, ITmfEventParser parser, int cacheSize) throws FileNotFoundException {
55 super(filename, parser, cacheSize);
165c977c
FC
56 fStream = new RandomAccessFile(filename, "r");
57 indexStream(true);
4c5b8099
FC
58 }
59
60 // ========================================================================
61 // Accessors
62 // ========================================================================
63
165c977c
FC
64 public RandomAccessFile getStream() {
65 return fStream;
66 }
67
4c5b8099
FC
68 // ========================================================================
69 // Operators
70 // ========================================================================
71
165c977c
FC
72 /* (non-Javadoc)
73 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
74 */
75 public StreamContext seekLocation(Object location) {
76 StreamContext context = null;
77 try {
78 fStream.seek((location != null) ? (Long) location : 0);
82b08e62 79 context = new StreamContext(getCurrentLocation(), 0);
165c977c
FC
80 } catch (IOException e) {
81 // TODO Auto-generated catch block
82 e.printStackTrace();
83 }
84 return context;
4c5b8099
FC
85 }
86
165c977c
FC
87 /* (non-Javadoc)
88 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
89 */
4c5b8099
FC
90 public Object getCurrentLocation() {
91 try {
165c977c 92 return new Long(fStream.getFilePointer());
4c5b8099
FC
93 } catch (IOException e) {
94 // TODO Auto-generated catch block
95 e.printStackTrace();
96 }
97 return null;
98 }
99
100 // ========================================================================
101 // Helper functions
102 // ========================================================================
103
165c977c
FC
104 /* (non-Javadoc)
105 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
106 */
107 public Map<String, Object> getAttributes() {
108 // TODO Auto-generated method stub
109 return null;
110 }
111
4c5b8099 112}
This page took 0.030237 seconds and 5 git commands to generate.