tmf: Eliminate lesser constructors in TmfTrace
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Sat, 13 Apr 2013 00:01:40 +0000 (20:01 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 22 Apr 2013 19:26:12 +0000 (15:26 -0400)
It's becoming very hard to figure out which exact constructor
is being called, and the resulting program flow. Remove the
intermediate constructors in TmfTrace and redirect implementations
to the full one.

Improved the Javadoc at the same time, to mention which default
values can be used.

Change-Id: Id0d03a976ce6d84e680021bf1634fa15d03942f3
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/11913
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/trace/TmfTraceStub.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java

index 7677ec7884ac848ee1484eb91d857b2e7d43adb3..c2acb599e9c454082577c94dd03793a93a41a760 100644 (file)
@@ -88,7 +88,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
      * @throws FileNotFoundException
      */
     public TmfTraceStub(final String path, final int cacheSize, final long interval) throws TmfTraceException {
-        super(null, ITmfEvent.class, path, cacheSize, interval);
+        super(null, ITmfEvent.class, path, cacheSize, interval, null, null);
         try {
             fTrace = new RandomAccessFile(path, "r");
         } catch (FileNotFoundException e) {
@@ -122,7 +122,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
      * @throws FileNotFoundException
      */
     public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException {
-        super(null, ITmfEvent.class, path, cacheSize);
+        super(null, ITmfEvent.class, path, cacheSize, 0, null, null);
         try {
             fTrace = new RandomAccessFile(path, "r");
         } catch (FileNotFoundException e) {
@@ -141,7 +141,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
      * @throws FileNotFoundException
      */
     public TmfTraceStub(final IResource resource,  final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException {
-        super(resource, ITmfEvent.class, path, cacheSize);
+        super(resource, ITmfEvent.class, path, cacheSize, 0, null, null);
         try {
             fTrace = new RandomAccessFile(path, "r");
         } catch (FileNotFoundException e) {
@@ -159,7 +159,7 @@ public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
      */
     public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion,
             final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws TmfTraceException {
-        super(null, ITmfEvent.class, path, cacheSize, 0, indexer);
+        super(null, ITmfEvent.class, path, cacheSize, 0, indexer, null);
         try {
             fTrace = new RandomAccessFile(path, "r");
         } catch (FileNotFoundException e) {
index 6e5108b91841b9a0ba0eb2ca6ff0175358e053b5..df0f01c1d9115a22ae38b06d7a77d44f938dc5b0 100644 (file)
@@ -128,65 +128,37 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
     }
 
     /**
-     * The standard constructor (non-live trace). Applicable when the trace
-     * implements its own parser and if at checkpoint-based index is OK.
+     * Full constructor.
      *
-     * @param resource the resource associated to the trace
-     * @param type the trace event type
-     * @param path the trace path
-     * @param cacheSize the trace cache size
-     * @throws TmfTraceException If something failed during the opening
-     */
-    protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize) throws TmfTraceException {
-        this(resource, type, path, cacheSize, 0);
-    }
-
-    /**
-     * The standard constructor (live trace). Applicable when the trace
-     * implements its own parser and if at checkpoint-based index is OK.
-     *
-     * @param resource the resource associated to the trace
-     * @param type the trace event type
-     * @param path the trace path
-     * @param cacheSize the trace cache size
-     * @param interval the trace streaming interval
-     * @throws TmfTraceException If something failed during the opening
-     */
-    protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize, final long interval) throws TmfTraceException {
-        this(resource, type, path, cacheSize, interval, null);
-    }
-
-    /**
-     * The 'non-default indexer' constructor. Allows to provide a trace
-     * specific indexer.
-     *
-     * @param resource the resource associated to the trace
-     * @param type the trace event type
-     * @param path the trace path
-     * @param cacheSize the trace cache size
-     * @param interval the trace streaming interval
-     * @param indexer the trace indexer
-     * @throws TmfTraceException If something failed during the opening
-     */
-    protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize,
-            final long interval, final ITmfTraceIndexer indexer) throws TmfTraceException {
-        this(resource, type, path, cacheSize, interval, indexer, null);
-    }
-
-    /**
-     * The full constructor where trace specific indexer/parser are provided.
-     *
-     * @param resource the resource associated to the trace
-     * @param type the trace event type
-     * @param path the trace path
-     * @param cacheSize the trace cache size
-     * @param interval the trace streaming interval
-     * @param indexer the trace indexer
-     * @param parser the trace event parser
-     * @throws TmfTraceException If something failed during the opening
-     */
-    protected TmfTrace(final IResource resource, final Class<? extends ITmfEvent> type, final String path, final int cacheSize,
-            final long interval, final ITmfTraceIndexer indexer, final ITmfEventParser parser) throws TmfTraceException {
+     * @param resource
+     *            The resource associated to the trace
+     * @param type
+     *            The type of events that will be read from this trace
+     * @param path
+     *            The path to the trace on the filesystem
+     * @param cacheSize
+     *            The trace cache size. Pass '-1' to use the default specified
+     *            in {@link ITmfTrace#DEFAULT_TRACE_CACHE_SIZE}
+     * @param interval
+     *            The trace streaming interval. You can use '0' for post-mortem
+     *            traces.
+     * @param indexer
+     *            The trace indexer. You can pass 'null' to use a default
+     *            checkpoint indexer.
+     * @param parser
+     *            The trace event parser. Use 'null' if (and only if) the trace
+     *            object itself is also the ITmfEventParser to be used.
+     * @throws TmfTraceException
+     *             If something failed during the opening
+     */
+    protected TmfTrace(final IResource resource,
+            final Class<? extends ITmfEvent> type,
+            final String path,
+            final int cacheSize,
+            final long interval,
+            final ITmfTraceIndexer indexer,
+            final ITmfEventParser parser)
+                    throws TmfTraceException {
         super();
         fCacheSize = (cacheSize > 0) ? cacheSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE;
         fStreamingInterval = interval;
This page took 0.028009 seconds and 5 git commands to generate.