import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
* Dummy test trace. Use in conjunction with TmfEventParserStub.
*/
@SuppressWarnings("nls")
-public class TmfTraceStub extends TmfTrace<TmfEvent> {
+public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<TmfEvent> {
// ------------------------------------------------------------------------
// Attributes
// The actual stream
private RandomAccessFile fTrace;
- // The associated event parser
- private ITmfEventParser<TmfEvent> fParser;
+// // The associated event parser
+// private ITmfEventParser<TmfEvent> fParser;
// The synchronization lock
private final ReentrantLock fLock = new ReentrantLock();
*/
public TmfTraceStub() {
super();
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
public TmfTraceStub(final String path, final int cacheSize, final long interval) throws FileNotFoundException {
super(null, TmfEvent.class, path, cacheSize, interval);
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException {
super(null, TmfEvent.class, path, cacheSize);
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException {
super(resource, TmfEvent.class, path, cacheSize);
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
* @param parser
* @throws FileNotFoundException
*/
+ @SuppressWarnings("unchecked")
public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion,
final ITmfEventParser<TmfEvent> parser, final ITmfTraceIndexer<?> indexer) throws FileNotFoundException {
super(null, TmfEvent.class, path, cacheSize, 0, indexer);
fTrace = new RandomAccessFile(path, "r");
- fParser = (parser != null) ? parser : new TmfEventParserStub();
+ fParser = (ITmfEventParser<ITmfEvent>) ((parser != null) ? parser : new TmfEventParserStub(this));
}
/**
public TmfTraceStub(final TmfTraceStub trace) throws FileNotFoundException {
super(trace);
fTrace = new RandomAccessFile(getPath(), "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
public void indexTrace() {
@Override
public void initTrace(final IResource resource, final String path, final Class<TmfEvent> type) throws FileNotFoundException {
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
super.initTrace(resource, path, type);
}
@Override
@SuppressWarnings("unchecked")
- public TmfContext seekLocation(final ITmfLocation<?> location) {
+ public TmfContext seekEvent(final ITmfLocation<?> location) {
try {
fLock.lock();
try {
@Override
- public TmfContext seekLocation(final double ratio) {
+ public TmfContext seekEvent(final double ratio) {
fLock.lock();
try {
if (fTrace != null) {
final ITmfLocation<?> location = new TmfLocation<Long>(Long.valueOf((long) (ratio * fTrace.length())));
- final TmfContext context = seekLocation(location);
+ final TmfContext context = seekEvent(location);
context.setRank(ITmfContext.UNKNOWN_RANK);
return context;
}
try {
// parseNextEvent will update the context
if (fTrace != null) {
- final ITmfEvent event = fParser.parseNextEvent(this, context.clone());
+ final ITmfEvent event = fParser.parseEvent(context.clone());
return event;
}
- }
- catch (final IOException e) {
- e.printStackTrace();
+// }
+// catch (final IOException e) {
+// e.printStackTrace();
} finally {
fLock.unlock();
}