1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.trace
;
15 import java
.io
.FileNotFoundException
;
16 import java
.io
.IOException
;
17 import java
.io
.RandomAccessFile
;
19 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
22 * <b><u>TmfTraceStub</u></b>
24 * TODO: Implement me. Please.
26 public class TmfTraceStub
extends TmfTrace
{
28 // ========================================================================
30 // ========================================================================
33 private final RandomAccessFile fTrace
;
35 // The associated event parser
36 private final ITmfEventParser fParser
;
38 // ========================================================================
40 // ========================================================================
44 * @throws FileNotFoundException
46 public TmfTraceStub(String filename
) throws FileNotFoundException
{
47 this(filename
, DEFAULT_PAGE_SIZE
);
53 * @throws FileNotFoundException
55 public TmfTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
56 super(filename
, cacheSize
, true);
57 fTrace
= new RandomAccessFile(filename
, "r");
58 fParser
= new TmfEventParserStub();
62 // ========================================================================
64 // ========================================================================
66 public RandomAccessFile
getStream() {
70 // ========================================================================
72 // ========================================================================
75 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
77 public TmfTraceContext
seekLocation(Object location
) {
78 TmfTraceContext context
= null;
80 synchronized(fTrace
) {
81 fTrace
.seek((location
!= null) ?
(Long
) location
: 0);
82 context
= new TmfTraceContext(getCurrentLocation(), null, 0);
84 } catch (IOException e
) {
85 // TODO Auto-generated catch block
92 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
95 public Object
getCurrentLocation() {
97 return new Long(fTrace
.getFilePointer());
98 } catch (IOException e
) {
99 // TODO Auto-generated catch block
106 * @see org.eclipse.linuxtools.tmf.trace.TmfTrace#parseEvent()
109 public synchronized TmfEvent
parseEvent(TmfTraceContext context
) {
111 fTrace
.seek((context
.location
!= null) ?
(Long
) context
.location
: 0);
112 TmfEvent event
= fParser
.parseNextEvent(this);
113 context
= new TmfTraceContext(getCurrentLocation(), null, 0);
116 catch (IOException e
) {
122 // ========================================================================
124 // ========================================================================
This page took 0.033244 seconds and 6 git commands to generate.