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 (fchouinard@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.stubs
;
15 import java
.io
.FileNotFoundException
;
16 import java
.io
.IOException
;
17 import java
.io
.RandomAccessFile
;
19 import org
.eclipse
.linuxtools
.lttng
.event
.LttngEvent
;
20 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.parser
.ITmfEventParser
;
22 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfLocation
;
23 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
24 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfLocation
;
25 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTrace
;
28 * <b><u>LTTngTraceStub</u></b>
30 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
32 public class LTTngTraceStub
extends TmfTrace
<LttngEvent
> {
34 // ========================================================================
36 // ========================================================================
39 private final RandomAccessFile fTrace
;
41 // The associated event parser
42 private final ITmfEventParser fParser
;
44 // ========================================================================
46 // ========================================================================
51 * @throws FileNotFoundException
53 public LTTngTraceStub(String filename
) throws FileNotFoundException
{
54 this(filename
, DEFAULT_CACHE_SIZE
);
61 * @throws FileNotFoundException
63 public LTTngTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
64 super(LttngEvent
.class, filename
, cacheSize
);
65 fTrace
= new RandomAccessFile(filename
, "r");
66 fParser
= new LTTngEventParserStub();
70 // ========================================================================
72 // ========================================================================
74 public RandomAccessFile
getStream() {
78 // ========================================================================
80 // ========================================================================
83 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
85 @SuppressWarnings("unchecked")
86 public TmfContext
seekLocation(ITmfLocation location
) {
87 TmfContext context
= null;
89 synchronized(fTrace
) {
90 fTrace
.seek((location
!= null) ?
((TmfLocation
<Long
>) location
).getValue() : 0);
91 context
= new TmfContext(getCurrentLocation(), 0);
92 // TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
93 // TmfEvent event = parseEvent(context2);
94 // context.setTimestamp(event.getTimestamp());
96 } catch (IOException e
) {
97 // TODO Auto-generated catch block
104 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
107 public ITmfLocation
getCurrentLocation() {
109 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
110 } catch (IOException e
) {
111 // TODO Auto-generated catch block
118 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
121 public TmfEvent
parseEvent(TmfContext context
) {
123 // paserNextEvent updates the context
124 TmfEvent event
= fParser
.parseNextEvent(this, context
);
125 // if (event != null) {
126 // context.setTimestamp(event.getTimestamp());
130 catch (IOException e
) {
137 * @see java.lang.Object#toString()
140 public String
toString() {
141 return "[LTTngTraceStub]";
144 // // ========================================================================
145 // // Helper functions
146 // // ========================================================================
149 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
151 // public Map<String, Object> getAttributes() {
152 // // TODO Auto-generated method stub
This page took 0.040546 seconds and 6 git commands to generate.