tmf: support preprocessing of lines in the TextTrace class (Bug 458578)
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Wed, 28 Jan 2015 15:14:45 +0000 (10:14 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Wed, 4 Feb 2015 20:40:55 +0000 (15:40 -0500)
Change-Id: I510a6a12bf9a9abd38985bdb2097480afb0c0ad1
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/40549
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Hudson CI
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTrace.java

index 674b3b6a39388f37d4b0d41b98cab577ba26108a..6fae095d127d87c2214c68e7c6ef11c5dc304689 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -25,6 +25,7 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
@@ -95,6 +96,7 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
             String line = rafile.getNextLine();
             List<Pattern> validationPatterns = getValidationPatterns();
             while ((line != null) && (lineCount++ < MAX_LINES)) {
+                line = preProcessLine(line);
                 for(Pattern pattern : validationPatterns) {
                     Matcher matcher = pattern.matcher(line);
                     if (matcher.matches()) {
@@ -151,6 +153,7 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
             long rawPos = fFile.getFilePointer();
             String line = fFile.getNextLine();
             while (line != null) {
+                line = preProcessLine(line);
                 Matcher matcher = getFirstLinePattern().matcher(line);
                 if (matcher.matches()) {
                     setupContext(context, rawPos, line, matcher);
@@ -266,6 +269,7 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
             long rawPos = fFile.getFilePointer();
             String line = fFile.getNextLine();
             while (line != null) {
+                line = preProcessLine(line);
                 Matcher matcher = getFirstLinePattern().matcher(line);
                 if (matcher.matches()) {
                     setupContext(context, rawPos, line, matcher);
@@ -283,6 +287,19 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
         return event;
     }
 
+    /**
+     * Pre-processes the input line. The default implementation returns the
+     * input line.
+     *
+     * @param line
+     *            non-null input string
+     * @return the pre-processed input line
+     */
+    @NonNull
+    protected String preProcessLine(@NonNull String line) {
+        return line;
+    }
+
     /**
      * Gets the first line pattern.
      *
This page took 0.026309 seconds and 5 git commands to generate.