- Minor modification of the FW API (better trace/parser integration)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.tests / stubs / org / eclipse / linuxtools / tmf / trace / TmfTraceStub.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.event.TmfEvent;
21
22 /**
23 * <b><u>TmfTraceStub</u></b>
24 * <p>
25 * TODO: Implement me. Please.
26 */
27 public class TmfTraceStub extends TmfTrace {
28
29 // ========================================================================
30 // Attributes
31 // ========================================================================
32
33 // The actual stream
34 private final RandomAccessFile fTrace;
35
36 // The associated event parser
37 private final ITmfEventParser fParser;
38
39 // ========================================================================
40 // Constructors
41 // ========================================================================
42
43 /**
44 * @param filename
45 * @throws FileNotFoundException
46 */
47 public TmfTraceStub(String filename) throws FileNotFoundException {
48 this(filename, DEFAULT_PAGE_SIZE);
49 }
50
51 /**
52 * @param filename
53 * @param cacheSize
54 * @throws FileNotFoundException
55 */
56 public TmfTraceStub(String filename, int cacheSize) throws FileNotFoundException {
57 super(filename, cacheSize);
58 fTrace = new RandomAccessFile(filename, "r");
59 fParser = new TmfEventParserStub();
60 indexStream();
61 }
62
63 // ========================================================================
64 // Accessors
65 // ========================================================================
66
67 public RandomAccessFile getStream() {
68 return fTrace;
69 }
70
71 // ========================================================================
72 // Operators
73 // ========================================================================
74
75 /* (non-Javadoc)
76 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
77 */
78 public TmfTraceContext seekLocation(Object location) {
79 TmfTraceContext context = null;
80 try {
81 fTrace.seek((location != null) ? (Long) location : 0);
82 context = new TmfTraceContext(getCurrentLocation(), 0);
83 } catch (IOException e) {
84 // TODO Auto-generated catch block
85 e.printStackTrace();
86 }
87 return context;
88 }
89
90 /* (non-Javadoc)
91 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
92 */
93 public Object getCurrentLocation() {
94 try {
95 return new Long(fTrace.getFilePointer());
96 } catch (IOException e) {
97 // TODO Auto-generated catch block
98 e.printStackTrace();
99 }
100 return null;
101 }
102
103 /* (non-Javadoc)
104 * @see org.eclipse.linuxtools.tmf.trace.TmfTrace#parseEvent()
105 */
106 public TmfEvent parseNextEvent() {
107 try {
108 TmfEvent event = fParser.getNextEvent(this);
109 return event;
110 }
111 catch (IOException e) {
112 e.printStackTrace();
113 }
114 return null;
115 }
116
117 // ========================================================================
118 // Helper functions
119 // ========================================================================
120
121 /* (non-Javadoc)
122 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
123 */
124 public Map<String, Object> getAttributes() {
125 // TODO Auto-generated method stub
126 return null;
127 }
128
129 }
This page took 0.032203 seconds and 5 git commands to generate.