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
.tmf
.event
.TmfEvent
;
20 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfEventParser
;
21 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTrace
;
22 import org
.eclipse
.linuxtools
.tmf
.trace
.TmfTraceContext
;
25 * <b><u>LTTngTraceStub</u></b>
27 * Dummy test trace. Use in conjunction with LTTngEventParserStub.
29 public class LTTngTraceStub
extends TmfTrace
{
31 // ========================================================================
33 // ========================================================================
36 private final RandomAccessFile fTrace
;
38 // The associated event parser
39 private final ITmfEventParser fParser
;
41 // ========================================================================
43 // ========================================================================
48 * @throws FileNotFoundException
50 public LTTngTraceStub(String filename
) throws FileNotFoundException
{
51 this(filename
, DEFAULT_CACHE_SIZE
);
58 * @throws FileNotFoundException
60 public LTTngTraceStub(String filename
, int cacheSize
) throws FileNotFoundException
{
61 super(filename
, cacheSize
, false);
62 fTrace
= new RandomAccessFile(filename
, "r");
63 fParser
= new LTTngEventParserStub();
67 // ========================================================================
69 // ========================================================================
71 public RandomAccessFile
getStream() {
75 // ========================================================================
77 // ========================================================================
80 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
82 public TmfTraceContext
seekLocation(Object location
) {
83 TmfTraceContext context
= null;
85 synchronized(fTrace
) {
86 fTrace
.seek((location
!= null) ?
(Long
) location
: 0);
87 context
= new TmfTraceContext(getCurrentLocation(), null, 0);
89 } catch (IOException e
) {
90 // TODO Auto-generated catch block
97 * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
100 public Object
getCurrentLocation() {
102 return new Long(fTrace
.getFilePointer());
103 } catch (IOException e
) {
104 // TODO Auto-generated catch block
111 * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
114 public TmfEvent
parseEvent(TmfTraceContext context
) {
116 // paserNextEvent updates the context
117 TmfEvent event
= fParser
.parseNextEvent(this, context
);
119 context
.setTimestamp(event
.getTimestamp());
123 catch (IOException e
) {
130 * @see java.lang.Object#toString()
133 public String
toString() {
134 return "[LTTngTraceStub]";
137 // // ========================================================================
138 // // Helper functions
139 // // ========================================================================
142 // * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
144 // public Map<String, Object> getAttributes() {
145 // // TODO Auto-generated method stub
This page took 0.033995 seconds and 5 git commands to generate.