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_INDEX_PAGE_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();
72 public ITmfTrace
createTraceCopy() {
73 ITmfTrace returnedValue
= null;
75 returnedValue
= new LTTngTraceStub(this.getName());
77 catch (FileNotFoundException e
) {
83 // ========================================================================
85 // ========================================================================
87 public RandomAccessFile
getStream() {
91 // ========================================================================
93 // ========================================================================
96 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
99 @SuppressWarnings("unchecked")
100 public TmfContext
seekLocation(ITmfLocation
<?
> location
) {
101 TmfContext context
= null;
103 synchronized(fTrace
) {
104 fTrace
.seek((location
!= null) ?
((TmfLocation
<Long
>) location
).getLocation() : 0);
105 context
= new TmfContext(getCurrentLocation(), 0);
106 // TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
107 // TmfEvent event = parseEvent(context2);
108 // context.setTimestamp(event.getTimestamp());
110 } catch (IOException e
) {
111 // TODO Auto-generated catch block
118 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
121 public ITmfLocation
<?
> getCurrentLocation() {
123 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
124 } catch (IOException e
) {
125 // TODO Auto-generated catch block
132 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
135 public TmfEvent
parseEvent(TmfContext context
) {
137 // paserNextEvent updates the context
138 TmfEvent event
= fParser
.parseNextEvent(this, context
);
139 // if (event != null) {
140 // context.setTimestamp(event.getTimestamp());
144 catch (IOException e
) {
151 * @see java.lang.Object#toString()
154 public String
toString() {
155 return "[LTTngTraceStub]";
158 // // ========================================================================
159 // // Helper functions
160 // // ========================================================================
163 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
165 // public Map<String, Object> getAttributes() {
166 // // TODO Auto-generated method stub
This page took 0.040629 seconds and 6 git commands to generate.