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
.ITmfTrace
;
24 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfContext
;
25 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfLocation
;
26 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTrace
;
29 * <b><u>LTTngTraceStub</u></b>
31 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
33 public class LTTngTraceStub
extends TmfTrace
<LttngEvent
> {
35 // ========================================================================
37 // ========================================================================
40 private final RandomAccessFile fTrace
;
42 // The associated event parser
43 private final ITmfEventParser fParser
;
45 // ========================================================================
47 // ========================================================================
52 * @throws FileNotFoundException
54 public LTTngTraceStub(String filename
) throws FileNotFoundException
{
55 this(filename
, DEFAULT_CACHE_SIZE
);
62 * @throws FileNotFoundException
64 public LTTngTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
65 super(filename
, LttngEvent
.class, filename
, cacheSize
);
66 fTrace
= new RandomAccessFile(filename
, "r");
67 fParser
= new LTTngEventParserStub();
71 public ITmfTrace
createTraceCopy() {
72 ITmfTrace returnedValue
= null;
74 returnedValue
= new LTTngTraceStub(this.getName());
76 catch (FileNotFoundException e
) {
82 // ========================================================================
84 // ========================================================================
86 public RandomAccessFile
getStream() {
90 // ========================================================================
92 // ========================================================================
95 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
98 @SuppressWarnings("unchecked")
99 public TmfContext
seekLocation(ITmfLocation
<?
> location
) {
100 TmfContext context
= null;
102 synchronized(fTrace
) {
103 fTrace
.seek((location
!= null) ?
((TmfLocation
<Long
>) location
).getLocation() : 0);
104 context
= new TmfContext(getCurrentLocation(), 0);
105 // TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
106 // TmfEvent event = parseEvent(context2);
107 // context.setTimestamp(event.getTimestamp());
109 } catch (IOException e
) {
110 // TODO Auto-generated catch block
117 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
120 public ITmfLocation
<?
> getCurrentLocation() {
122 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
123 } catch (IOException e
) {
124 // TODO Auto-generated catch block
131 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
134 public TmfEvent
parseEvent(TmfContext context
) {
136 // paserNextEvent updates the context
137 TmfEvent event
= fParser
.parseNextEvent(this, context
);
138 // if (event != null) {
139 // context.setTimestamp(event.getTimestamp());
143 catch (IOException e
) {
150 * @see java.lang.Object#toString()
153 public String
toString() {
154 return "[LTTngTraceStub]";
157 // // ========================================================================
158 // // Helper functions
159 // // ========================================================================
162 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
164 // public Map<String, Object> getAttributes() {
165 // // TODO Auto-generated method stub
This page took 0.034344 seconds and 5 git commands to generate.