--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng.stubs;
+
+import java.io.IOException;
+
+import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * <b><u>TmfEventParserStub</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class LTTngEventParserStub implements ITmfEventParser<LttngEvent> {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext)
+ */
+ @Override
+ public ITmfEvent parseNextEvent(ITmfTrace<LttngEvent> stream, ITmfContext context)
+ throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+// // ========================================================================
+// // Attributes
+// // ========================================================================
+//
+// private final int NB_FORMATS = 10;
+// private final TmfEventFormat[] fFormats;
+//
+// // ========================================================================
+// // Constructors
+// // ========================================================================
+//
+// public LTTngEventParserStub() {
+// fFormats = new TmfEventFormat[NB_FORMATS];
+// for (int i = 0; i < NB_FORMATS; i++) {
+// Vector<String> format = new Vector<String>();
+// for (int j = 1; j <= i; j++) {
+// format.add(new String("Fmt-" + i + "-Fld-" + j));
+// }
+// String[] fields = new String[i];
+// fFormats[i] = new TmfEventFormat(format.toArray(fields));
+// }
+// }
+//
+// // ========================================================================
+// // Accessors
+// // ========================================================================
+//
+// // ========================================================================
+// // Operators
+// // ========================================================================
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
+// */
+// static final String typePrefix = "Type-";
+// public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
+//
+// if (! (eventStream instanceof LTTngTraceStub)) {
+// return null;
+// }
+//
+// // Highly inefficient...
+// RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
+// String name = eventStream.getName();
+// name = name.substring(name.lastIndexOf('/') + 1);
+//
+// synchronized(stream) {
+// long location = 0;
+// if (context != null)
+// location = (Long) (context.getLocation());
+// stream.seek(location);
+//
+// try {
+// // Read the individual fields
+// long ts = stream.readLong();
+// String source = stream.readUTF();
+// String type = stream.readUTF();
+// @SuppressWarnings("unused")
+// int reference = stream.readInt();
+//
+// // Read the event parts
+// int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
+// String[] fields = new String[typeIndex];
+// for (int i = 0; i < typeIndex; i++) {
+// fields[i] = stream.readUTF();
+// }
+//
+// // Format the content from the individual fields
+// String content = "[";
+// if (typeIndex > 0) {
+// content += fields[0];
+// }
+// for (int i = 1; i < typeIndex; i++) {
+// content += ", " + fields[i];
+// }
+// content += "]";
+//
+// // Update the context
+// context.setLocation(stream.getFilePointer());
+// context.incrIndex();
+// try {
+// long ts2 = stream.readLong();
+// context.setTimestamp(new LTTngTimestampStub(ts2));
+// } catch (EOFException e) {
+// context.setTimestamp(null);
+// }
+//
+// // Create the event
+// TmfEvent event = new TmfEvent(
+// new LTTngTimestampStub(ts),
+// new TmfEventSource(source),
+// new TmfEventType(type, fFormats[typeIndex]),
+// new TmfEventContent(content, fFormats[typeIndex]),
+// new TmfEventReference(name));
+//
+// return event;
+//
+// } catch (EOFException e) {
+// context.setTimestamp(null);
+// }
+// }
+// return null;
+// }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ *
+ */
+package org.eclipse.linuxtools.internal.lttng.stubs;
+
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+
+/**
+ * @author francois
+ *
+ */
+@SuppressWarnings("nls")
+public class LTTngTimestampStub extends TmfTimestamp {
+
+ /**
+ *
+ */
+ @SuppressWarnings("unused")
+ private static final long serialVersionUID = 216576768443708259L;
+
+ /**
+ * @param value
+ * @param scale
+ * @param precision
+ */
+ public LTTngTimestampStub(long value) {
+ super(value, (byte) -3, 0); // millisecs
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp#toString()
+ */
+ @Override
+ public String toString() {
+
+ // If we are dealing with units of seconds (or higher),
+ // use the plain formatter
+ if (fScale >= 0) {
+ Double value = fValue * Math.pow(10, fScale);
+ return value.toString();
+ }
+
+ // Define a format string
+ String format = String.format("%%1d.%%0%dd", -fScale);
+
+ // And format the timestamp value
+ double scale = Math.pow(10, fScale);
+ long seconds = (long) (fValue * scale);
+ long fracts = fValue - (long) ((double) seconds / scale);
+ String result = String.format(format, seconds, fracts);
+
+ return result;
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng.stubs;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+
+/**
+ * <b><u>LTTngTraceStub</u></b>
+ * <p>
+ * Dummy test trace. Use in conjunction with LTTngEventParserStub.
+ */
+@SuppressWarnings("nls")
+public class LTTngTraceStub extends TmfTrace<LttngEvent> {
+
+ // ========================================================================
+ // Attributes
+ // ========================================================================
+
+ // The actual stream
+ private final RandomAccessFile fTrace;
+
+ // The associated event parser
+ private final ITmfEventParser<LttngEvent> fParser;
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ /**
+ * @param filename
+ * @param parser
+ * @throws FileNotFoundException
+ */
+ public LTTngTraceStub(String filename) throws FileNotFoundException {
+ this(filename, DEFAULT_INDEX_PAGE_SIZE);
+ }
+
+ /**
+ * @param filename
+ * @param parser
+ * @param cacheSize
+ * @throws FileNotFoundException
+ */
+ public LTTngTraceStub(String filename, int cacheSize) throws FileNotFoundException {
+ super(filename, LttngEvent.class, filename, cacheSize);
+ fTrace = new RandomAccessFile(filename, "r");
+ fParser = new LTTngEventParserStub();
+// indexTrace(true);
+ }
+
+ @Override
+ public ITmfTrace<LttngEvent> copy() {
+ ITmfTrace<LttngEvent> returnedValue = null;
+ try {
+ returnedValue = new LTTngTraceStub(this.getName());
+ }
+ catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ return returnedValue;
+ }
+
+ // ========================================================================
+ // Accessors
+ // ========================================================================
+
+ public RandomAccessFile getStream() {
+ return fTrace;
+ }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public TmfContext seekLocation(ITmfLocation<?> location) {
+ TmfContext context = null;
+ try {
+ synchronized(fTrace) {
+ fTrace.seek((location != null) ? ((TmfLocation<Long>) location).getLocation() : 0);
+ context = new TmfContext(getCurrentLocation(), 0);
+// TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
+// TmfEvent event = parseEvent(context2);
+// context.setTimestamp(event.getTimestamp());
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return context;
+ }
+
+ @Override
+ public TmfContext seekLocation(double ratio) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public double getLocationRatio(ITmfLocation<?> location) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
+ */
+ @Override
+ public ITmfLocation<?> getCurrentLocation() {
+ try {
+ return new TmfLocation<Long>(fTrace.getFilePointer());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
+ */
+ @Override
+ public ITmfEvent parseEvent(ITmfContext context) {
+ try {
+ // paserNextEvent updates the context
+ LttngEvent event = (LttngEvent) fParser.parseNextEvent(this, context);
+// if (event != null) {
+// context.setTimestamp(event.getTimestamp());
+// }
+ return event;
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "[LTTngTraceStub]";
+ }
+
+// // ========================================================================
+// // Helper functions
+// // ========================================================================
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
+// */
+// public Map<String, Object> getAttributes() {
+// // TODO Auto-generated method stub
+// return null;
+// }
+
+}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.stubs;
-
-import java.io.IOException;
-
-import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-
-/**
- * <b><u>TmfEventParserStub</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngEventParserStub implements ITmfEventParser<LttngEvent> {
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext)
- */
- @Override
- public ITmfEvent parseNextEvent(ITmfTrace<LttngEvent> stream, ITmfContext context)
- throws IOException {
- // TODO Auto-generated method stub
- return null;
- }
-
-// // ========================================================================
-// // Attributes
-// // ========================================================================
-//
-// private final int NB_FORMATS = 10;
-// private final TmfEventFormat[] fFormats;
-//
-// // ========================================================================
-// // Constructors
-// // ========================================================================
-//
-// public LTTngEventParserStub() {
-// fFormats = new TmfEventFormat[NB_FORMATS];
-// for (int i = 0; i < NB_FORMATS; i++) {
-// Vector<String> format = new Vector<String>();
-// for (int j = 1; j <= i; j++) {
-// format.add(new String("Fmt-" + i + "-Fld-" + j));
-// }
-// String[] fields = new String[i];
-// fFormats[i] = new TmfEventFormat(format.toArray(fields));
-// }
-// }
-//
-// // ========================================================================
-// // Accessors
-// // ========================================================================
-//
-// // ========================================================================
-// // Operators
-// // ========================================================================
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
-// */
-// static final String typePrefix = "Type-";
-// public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
-//
-// if (! (eventStream instanceof LTTngTraceStub)) {
-// return null;
-// }
-//
-// // Highly inefficient...
-// RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
-// String name = eventStream.getName();
-// name = name.substring(name.lastIndexOf('/') + 1);
-//
-// synchronized(stream) {
-// long location = 0;
-// if (context != null)
-// location = (Long) (context.getLocation());
-// stream.seek(location);
-//
-// try {
-// // Read the individual fields
-// long ts = stream.readLong();
-// String source = stream.readUTF();
-// String type = stream.readUTF();
-// @SuppressWarnings("unused")
-// int reference = stream.readInt();
-//
-// // Read the event parts
-// int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
-// String[] fields = new String[typeIndex];
-// for (int i = 0; i < typeIndex; i++) {
-// fields[i] = stream.readUTF();
-// }
-//
-// // Format the content from the individual fields
-// String content = "[";
-// if (typeIndex > 0) {
-// content += fields[0];
-// }
-// for (int i = 1; i < typeIndex; i++) {
-// content += ", " + fields[i];
-// }
-// content += "]";
-//
-// // Update the context
-// context.setLocation(stream.getFilePointer());
-// context.incrIndex();
-// try {
-// long ts2 = stream.readLong();
-// context.setTimestamp(new LTTngTimestampStub(ts2));
-// } catch (EOFException e) {
-// context.setTimestamp(null);
-// }
-//
-// // Create the event
-// TmfEvent event = new TmfEvent(
-// new LTTngTimestampStub(ts),
-// new TmfEventSource(source),
-// new TmfEventType(type, fFormats[typeIndex]),
-// new TmfEventContent(content, fFormats[typeIndex]),
-// new TmfEventReference(name));
-//
-// return event;
-//
-// } catch (EOFException e) {
-// context.setTimestamp(null);
-// }
-// }
-// return null;
-// }
-
-}
\ No newline at end of file
+++ /dev/null
-/**
- *
- */
-package org.eclipse.linuxtools.lttng.stubs;
-
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-
-/**
- * @author francois
- *
- */
-@SuppressWarnings("nls")
-public class LTTngTimestampStub extends TmfTimestamp {
-
- /**
- *
- */
- @SuppressWarnings("unused")
- private static final long serialVersionUID = 216576768443708259L;
-
- /**
- * @param value
- * @param scale
- * @param precision
- */
- public LTTngTimestampStub(long value) {
- super(value, (byte) -3, 0); // millisecs
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp#toString()
- */
- @Override
- public String toString() {
-
- // If we are dealing with units of seconds (or higher),
- // use the plain formatter
- if (fScale >= 0) {
- Double value = fValue * Math.pow(10, fScale);
- return value.toString();
- }
-
- // Define a format string
- String format = String.format("%%1d.%%0%dd", -fScale);
-
- // And format the timestamp value
- double scale = Math.pow(10, fScale);
- long seconds = (long) (fValue * scale);
- long fracts = fValue - (long) ((double) seconds / scale);
- String result = String.format(format, seconds, fracts);
-
- return result;
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.stubs;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
-
-/**
- * <b><u>LTTngTraceStub</u></b>
- * <p>
- * Dummy test trace. Use in conjunction with LTTngEventParserStub.
- */
-@SuppressWarnings("nls")
-public class LTTngTraceStub extends TmfTrace<LttngEvent> {
-
- // ========================================================================
- // Attributes
- // ========================================================================
-
- // The actual stream
- private final RandomAccessFile fTrace;
-
- // The associated event parser
- private final ITmfEventParser<LttngEvent> fParser;
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- /**
- * @param filename
- * @param parser
- * @throws FileNotFoundException
- */
- public LTTngTraceStub(String filename) throws FileNotFoundException {
- this(filename, DEFAULT_INDEX_PAGE_SIZE);
- }
-
- /**
- * @param filename
- * @param parser
- * @param cacheSize
- * @throws FileNotFoundException
- */
- public LTTngTraceStub(String filename, int cacheSize) throws FileNotFoundException {
- super(filename, LttngEvent.class, filename, cacheSize);
- fTrace = new RandomAccessFile(filename, "r");
- fParser = new LTTngEventParserStub();
-// indexTrace(true);
- }
-
- @Override
- public ITmfTrace<LttngEvent> copy() {
- ITmfTrace<LttngEvent> returnedValue = null;
- try {
- returnedValue = new LTTngTraceStub(this.getName());
- }
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- return returnedValue;
- }
-
- // ========================================================================
- // Accessors
- // ========================================================================
-
- public RandomAccessFile getStream() {
- return fTrace;
- }
-
- // ========================================================================
- // Operators
- // ========================================================================
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
- */
- @Override
- @SuppressWarnings("unchecked")
- public TmfContext seekLocation(ITmfLocation<?> location) {
- TmfContext context = null;
- try {
- synchronized(fTrace) {
- fTrace.seek((location != null) ? ((TmfLocation<Long>) location).getLocation() : 0);
- context = new TmfContext(getCurrentLocation(), 0);
-// TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), 0);
-// TmfEvent event = parseEvent(context2);
-// context.setTimestamp(event.getTimestamp());
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return context;
- }
-
- @Override
- public TmfContext seekLocation(double ratio) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public double getLocationRatio(ITmfLocation<?> location) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
- */
- @Override
- public ITmfLocation<?> getCurrentLocation() {
- try {
- return new TmfLocation<Long>(fTrace.getFilePointer());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
- */
- @Override
- public ITmfEvent parseEvent(ITmfContext context) {
- try {
- // paserNextEvent updates the context
- LttngEvent event = (LttngEvent) fParser.parseNextEvent(this, context);
-// if (event != null) {
-// context.setTimestamp(event.getTimestamp());
-// }
- return event;
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "[LTTngTraceStub]";
- }
-
-// // ========================================================================
-// // Helper functions
-// // ========================================================================
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
-// */
-// public Map<String, Object> getAttributes() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-
-}
\ No newline at end of file