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 * Dummy test trace. Use in conjunction with TmfEventParserStub.
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_CACHE_SIZE
, false);
52 * @throws FileNotFoundException
54 public TmfTraceStub(String filename
, boolean waitForCompletion
) throws FileNotFoundException
{
55 this(filename
, DEFAULT_CACHE_SIZE
, waitForCompletion
);
61 * @throws FileNotFoundException
63 public TmfTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
64 this(filename
, cacheSize
, false);
70 * @throws FileNotFoundException
72 public TmfTraceStub(String filename
, int cacheSize
, boolean waitForCompletion
) throws FileNotFoundException
{
73 super(filename
, cacheSize
, waitForCompletion
);
74 fTrace
= new RandomAccessFile(filename
, "r");
75 fParser
= new TmfEventParserStub();
79 // ========================================================================
81 // ========================================================================
83 public RandomAccessFile
getStream() {
87 // ========================================================================
89 // ========================================================================
92 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
94 public TmfTraceContext
seekLocation(Object location
) {
95 TmfTraceContext context
= null;
97 synchronized(fTrace
) {
98 fTrace
.seek((location
!= null) ?
(Long
) location
: 0);
99 context
= new TmfTraceContext(getCurrentLocation(), null, 0);
101 } catch (IOException e
) {
102 // TODO Auto-generated catch block
109 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
112 public Object
getCurrentLocation() {
114 return new Long(fTrace
.getFilePointer());
115 } catch (IOException e
) {
116 // TODO Auto-generated catch block
123 * @see org.eclipse.linuxtools.tmf.trace.TmfTrace#parseEvent()
126 public TmfEvent
parseEvent(TmfTraceContext context
) {
128 // paserNextEvent updates the context
129 TmfEvent event
= fParser
.parseNextEvent(this, context
);
131 context
.setTimestamp(event
.getTimestamp());
135 catch (IOException e
) {
141 // ========================================================================
143 // ========================================================================
This page took 0.032655 seconds and 5 git commands to generate.