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 @SuppressWarnings("unchecked")
94 public TmfContext
seekLocation(ITmfLocation
<?
> location
) {
96 synchronized(fTrace
) {
97 // Position the trace at the requested location and
98 // returns the corresponding context
99 long loc
= (location
!= null) ?
((TmfLocation
<Long
>) location
).getLocation() : 0;
100 if (loc
!= fTrace
.getFilePointer()) {
103 TmfContext context
= new TmfContext(getCurrentLocation(), 0);
106 } catch (IOException e
) {
113 public TmfLocation
<Long
> getCurrentLocation() {
115 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
116 } catch (IOException e
) {
123 public TmfEvent
parseEvent(TmfContext context
) {
125 // paserNextEvent updates the context
126 TmfEvent event
= fParser
.parseNextEvent(this, context
);
129 catch (IOException e
) {
This page took 0.033087 seconds and 5 git commands to generate.