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
.internal
.lttng
.stubs
;
15 import java
.io
.FileNotFoundException
;
16 import java
.io
.IOException
;
17 import java
.io
.RandomAccessFile
;
19 import org
.eclipse
.core
.resources
.IResource
;
20 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
.LttngEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.parser
.ITmfEventParser
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfLocation
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
30 * <b><u>LTTngTraceStub</u></b>
32 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
34 @SuppressWarnings("nls")
35 public class LTTngTraceStub
extends TmfTrace
<LttngEvent
> {
37 // ========================================================================
39 // ========================================================================
42 private final RandomAccessFile fTrace
;
44 // The associated event parser
45 private final ITmfEventParser
<LttngEvent
> fParser
;
47 // ========================================================================
49 // ========================================================================
54 * @throws FileNotFoundException
56 public LTTngTraceStub(final IResource resource
) throws FileNotFoundException
{
57 this(resource
, DEFAULT_TRACE_CACHE_SIZE
);
64 * @throws FileNotFoundException
66 public LTTngTraceStub(final IResource resource
, final int cacheSize
) throws FileNotFoundException
{
67 // super(resource, LttngEvent.class, resource.getName(), cacheSize, true);
68 super(resource
, LttngEvent
.class, resource
.getName(), cacheSize
);
69 fTrace
= new RandomAccessFile(resource
.getName(), "r");
70 fParser
= new LTTngEventParserStub();
73 public void indexTrace() {
74 fIndexer
.buildIndex(true);
77 // ========================================================================
79 // ========================================================================
81 public RandomAccessFile
getStream() {
85 // ========================================================================
87 // ========================================================================
90 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
93 @SuppressWarnings("unchecked")
94 public TmfContext
seekLocation(final ITmfLocation
<?
> location
) {
95 TmfContext context
= null;
97 synchronized(fTrace
) {
98 fTrace
.seek((location
!= null) ?
((TmfLocation
<Long
>) location
).getLocation() : 0);
99 context
= new TmfContext(getCurrentLocation(), 0);
100 // TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
101 // TmfEvent event = parseEvent(context2);
102 // context.setTimestamp(event.getTimestamp());
104 } catch (final IOException e
) {
105 // TODO Auto-generated catch block
112 public TmfContext
seekLocation(final double ratio
) {
113 // TODO Auto-generated method stub
118 public double getLocationRatio(final ITmfLocation
<?
> location
) {
119 // TODO Auto-generated method stub
124 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
127 public ITmfLocation
<?
> getCurrentLocation() {
129 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
130 } catch (final IOException e
) {
131 // TODO Auto-generated catch block
138 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
141 public ITmfEvent
parseEvent(final ITmfContext context
) {
143 // paserNextEvent updates the context
144 final LttngEvent event
= (LttngEvent
) fParser
.parseNextEvent(this, context
);
145 // if (event != null) {
146 // context.setTimestamp(event.getTimestamp());
150 catch (final IOException e
) {
157 * @see java.lang.Object#toString()
160 public String
toString() {
161 return "[LTTngTraceStub]";
164 // // ========================================================================
165 // // Helper functions
166 // // ========================================================================
169 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
171 // public Map<String, Object> getAttributes() {
172 // // TODO Auto-generated method stub
This page took 0.034957 seconds and 5 git commands to generate.