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