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
.TmfTrace
;
23 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTraceContext
;
26 * <b><u>LTTngTraceStub</u></b>
28 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
30 public class LTTngTraceStub
extends TmfTrace
<LttngEvent
> {
32 // ========================================================================
34 // ========================================================================
37 private final RandomAccessFile fTrace
;
39 // The associated event parser
40 private final ITmfEventParser fParser
;
42 // ========================================================================
44 // ========================================================================
49 * @throws FileNotFoundException
51 public LTTngTraceStub(String filename
) throws FileNotFoundException
{
52 this(filename
, DEFAULT_CACHE_SIZE
);
59 * @throws FileNotFoundException
61 public LTTngTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
62 super(LttngEvent
.class, filename
, cacheSize
);
63 fTrace
= new RandomAccessFile(filename
, "r");
64 fParser
= new LTTngEventParserStub();
68 // ========================================================================
70 // ========================================================================
72 public RandomAccessFile
getStream() {
76 // ========================================================================
78 // ========================================================================
81 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
83 public TmfTraceContext
seekLocation(Object location
) {
84 TmfTraceContext context
= null;
86 synchronized(fTrace
) {
87 fTrace
.seek((location
!= null) ?
(Long
) location
: 0);
88 context
= new TmfTraceContext(getCurrentLocation(), 0);
89 // TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
90 // TmfEvent event = parseEvent(context2);
91 // context.setTimestamp(event.getTimestamp());
93 } catch (IOException e
) {
94 // TODO Auto-generated catch block
101 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
104 public Object
getCurrentLocation() {
106 return new Long(fTrace
.getFilePointer());
107 } catch (IOException e
) {
108 // TODO Auto-generated catch block
115 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
118 public TmfEvent
parseEvent(TmfTraceContext context
) {
120 // paserNextEvent updates the context
121 TmfEvent event
= fParser
.parseNextEvent(this, context
);
122 // if (event != null) {
123 // context.setTimestamp(event.getTimestamp());
127 catch (IOException e
) {
134 * @see java.lang.Object#toString()
137 public String
toString() {
138 return "[LTTngTraceStub]";
141 // // ========================================================================
142 // // Helper functions
143 // // ========================================================================
146 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
148 // public Map<String, Object> getAttributes() {
149 // // TODO Auto-generated method stub
This page took 0.033489 seconds and 5 git commands to generate.