63b096b1d165eb50b2f69a7303e691d1f842300e
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
.core
.event
.LttngEvent
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.parser
.ITmfEventParser
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfLocation
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
29 * <b><u>LTTngTraceStub</u></b>
31 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
33 @SuppressWarnings("nls")
34 public class LTTngTraceStub
extends TmfTrace
<LttngEvent
> {
36 // ========================================================================
38 // ========================================================================
41 private final RandomAccessFile fTrace
;
43 // The associated event parser
44 private final ITmfEventParser fParser
;
46 // ========================================================================
48 // ========================================================================
53 * @throws FileNotFoundException
55 public LTTngTraceStub(String filename
) throws FileNotFoundException
{
56 this(filename
, DEFAULT_INDEX_PAGE_SIZE
);
63 * @throws FileNotFoundException
65 public LTTngTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
66 super(filename
, LttngEvent
.class, filename
, cacheSize
);
67 fTrace
= new RandomAccessFile(filename
, "r");
68 fParser
= new LTTngEventParserStub();
73 public ITmfTrace
<LttngEvent
> copy() {
74 ITmfTrace
<LttngEvent
> returnedValue
= null;
76 returnedValue
= new LTTngTraceStub(this.getName());
78 catch (FileNotFoundException e
) {
84 // ========================================================================
86 // ========================================================================
88 public RandomAccessFile
getStream() {
92 // ========================================================================
94 // ========================================================================
97 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
100 @SuppressWarnings("unchecked")
101 public TmfContext
seekLocation(ITmfLocation
<?
> location
) {
102 TmfContext context
= null;
104 synchronized(fTrace
) {
105 fTrace
.seek((location
!= null) ?
((TmfLocation
<Long
>) location
).getLocation() : 0);
106 context
= new TmfContext(getCurrentLocation(), 0);
107 // TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
108 // TmfEvent event = parseEvent(context2);
109 // context.setTimestamp(event.getTimestamp());
111 } catch (IOException e
) {
112 // TODO Auto-generated catch block
119 public TmfContext
seekLocation(double ratio
) {
120 // TODO Auto-generated method stub
125 public double getLocationRatio(ITmfLocation
<?
> location
) {
126 // TODO Auto-generated method stub
131 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
134 public ITmfLocation
<?
> getCurrentLocation() {
136 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
137 } catch (IOException e
) {
138 // TODO Auto-generated catch block
145 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
148 public TmfEvent
parseEvent(TmfContext context
) {
150 // paserNextEvent updates the context
151 TmfEvent event
= fParser
.parseNextEvent(this, context
);
152 // if (event != null) {
153 // context.setTimestamp(event.getTimestamp());
157 catch (IOException e
) {
164 * @see java.lang.Object#toString()
167 public String
toString() {
168 return "[LTTngTraceStub]";
171 // // ========================================================================
172 // // Helper functions
173 // // ========================================================================
176 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
178 // public Map<String, Object> getAttributes() {
179 // // TODO Auto-generated method stub
This page took 0.034265 seconds and 5 git commands to generate.