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 // ------------------------------------------------------------------------
92 @SuppressWarnings("unchecked")
93 public TmfContext
seekLocation(ITmfLocation location
) {
95 synchronized(fTrace
) {
96 // Position the trace at the requested location and
97 // returns the corresponding context
98 long loc
= (location
!= null) ?
((TmfLocation
<Long
>) location
).getValue() : 0;
99 if (loc
!= fTrace
.getFilePointer()) {
102 TmfContext context
= new TmfContext(getCurrentLocation(), 0);
105 } catch (IOException e
) {
112 public TmfLocation
<Long
> getCurrentLocation() {
114 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
115 } catch (IOException e
) {
122 public TmfEvent
parseEvent(TmfContext context
) {
124 // paserNextEvent updates the context
125 TmfEvent event
= fParser
.parseNextEvent(this, context
);
128 catch (IOException e
) {
This page took 0.034154 seconds and 6 git commands to generate.