1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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
;
20 import org
.eclipse
.linuxtools
.tmf
.parser
.ITmfEventParser
;
23 * <b><u>TmfTraceStub</u></b>
25 * Dummy test trace. Use in conjunction with TmfEventParserStub.
27 public class TmfTraceStub
extends TmfTrace
<TmfEvent
> {
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
34 private final RandomAccessFile fTrace
;
36 // The associated event parser
37 private final ITmfEventParser fParser
;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
45 * @throws FileNotFoundException
47 public TmfTraceStub(String filename
) throws FileNotFoundException
{
48 this(filename
, DEFAULT_CACHE_SIZE
, false);
54 * @throws FileNotFoundException
56 public TmfTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
57 this(filename
, cacheSize
, false);
62 * @throws FileNotFoundException
64 public TmfTraceStub(String filename
, boolean waitForCompletion
) throws FileNotFoundException
{
65 this(filename
, DEFAULT_CACHE_SIZE
, waitForCompletion
);
71 * @throws FileNotFoundException
73 public TmfTraceStub(String filename
, int cacheSize
, boolean waitForCompletion
) throws FileNotFoundException
{
74 super(TmfEvent
.class, filename
, cacheSize
);
75 fTrace
= new RandomAccessFile(filename
, "r");
76 fParser
= new TmfEventParserStub();
77 indexTrace(waitForCompletion
);
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
84 public RandomAccessFile
getStream() {
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
95 public TmfTraceContext
seekLocation(Object location
) {
97 synchronized(fTrace
) {
98 // Position the trace, read the event (to obtain its timestamp)
99 // and then re-position the trace (not great...)
100 fTrace
.seek((location
!= null) ?
(Long
) location
: 0);
101 TmfTraceContext context
= new TmfTraceContext(getCurrentLocation());
104 } catch (IOException e
) {
111 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
114 public Object
getCurrentLocation() {
116 return new Long(fTrace
.getFilePointer());
117 } catch (IOException e
) {
118 // TODO Auto-generated catch block
125 * @see org.eclipse.linuxtools.tmf.trace.TmfTrace#parseEvent()
128 public TmfEvent
parseEvent(TmfTraceContext context
) {
130 // paserNextEvent updates the context
131 TmfEvent event
= fParser
.parseNextEvent(this, context
);
134 catch (IOException e
) {
This page took 0.03574 seconds and 5 git commands to generate.