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
.exceptions
.TmfTraceException
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfEventParser
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfLocation
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
31 * <b><u>LTTngTraceStub</u></b>
33 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
35 @SuppressWarnings("nls")
36 public class LTTngTraceStub
extends TmfTrace
<LttngEvent
> implements ITmfEventParser
<LttngEvent
> {
38 // ========================================================================
40 // ========================================================================
43 private final RandomAccessFile fTrace
;
45 // The associated event parser
46 private final ITmfEventParser
<LttngEvent
> fParser
;
48 // ========================================================================
50 // ========================================================================
55 * @throws FileNotFoundException
57 public LTTngTraceStub(final IResource resource
) throws TmfTraceException
{
58 this(resource
, DEFAULT_TRACE_CACHE_SIZE
);
65 * @throws FileNotFoundException
67 public LTTngTraceStub(final IResource resource
, final int cacheSize
) throws TmfTraceException
{
68 // super(resource, LttngEvent.class, resource.getName(), cacheSize, true);
69 super(resource
, LttngEvent
.class, resource
.getName(), cacheSize
);
71 fTrace
= new RandomAccessFile(resource
.getName(), "r");
72 } catch (FileNotFoundException e
) {
73 throw new TmfTraceException(e
.getMessage());
75 fParser
= new LTTngEventParserStub();
78 public void indexTrace() {
79 fIndexer
.buildIndex(true);
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
seekEvent(final 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 (final IOException e
) {
110 // TODO Auto-generated catch block
117 public TmfContext
seekEvent(final double ratio
) {
118 // TODO Auto-generated method stub
123 public double getLocationRatio(final ITmfLocation
<?
> location
) {
124 // TODO Auto-generated method stub
129 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
132 public ITmfLocation
<?
> getCurrentLocation() {
134 return new TmfLocation
<Long
>(fTrace
.getFilePointer());
135 } catch (final IOException e
) {
136 // TODO Auto-generated catch block
143 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
146 public ITmfEvent
parseEvent(final ITmfContext context
) {
148 // paserNextEvent updates the context
149 final LttngEvent event
= (LttngEvent
) fParser
.parseEvent(context
);
150 // if (event != null) {
151 // context.setTimestamp(event.getTimestamp());
155 // catch (final IOException e) {
156 // e.printStackTrace();
162 * @see java.lang.Object#toString()
165 public String
toString() {
166 return "[LTTngTraceStub]";
169 // // ========================================================================
170 // // Helper functions
171 // // ========================================================================
174 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
176 // public Map<String, Object> getAttributes() {
177 // // TODO Auto-generated method stub
This page took 0.049731 seconds and 5 git commands to generate.