Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / parsers / custom / CustomTxtTrace.java
index dc4cdd706cfbf5cfc4da23ebbeee8245e2b02e46..e4bd564c76402c8d5b40253b35ed420c2010c6bd 100644 (file)
@@ -21,17 +21,17 @@ import java.util.List;
 import java.util.Map.Entry;\r
 import java.util.regex.Matcher;\r
 \r
-import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.event.TmfEventReference;\r
-import org.eclipse.linuxtools.tmf.event.TmfEventSource;\r
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.io.BufferedRandomAccessFile;\r
-import org.eclipse.linuxtools.tmf.trace.ITmfContext;\r
-import org.eclipse.linuxtools.tmf.trace.ITmfLocation;\r
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.trace.TmfContext;\r
-import org.eclipse.linuxtools.tmf.trace.TmfLocation;\r
-import org.eclipse.linuxtools.tmf.trace.TmfTrace;\r
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
+import org.eclipse.linuxtools.tmf.core.event.TmfEventReference;\r
+import org.eclipse.linuxtools.tmf.core.event.TmfEventSource;\r
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
+import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
+import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
 import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
 \r
 public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {\r
@@ -40,7 +40,12 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     \r
     private CustomTxtTraceDefinition fDefinition;\r
     private CustomTxtEventType fEventType;\r
-    \r
+\r
+    public CustomTxtTrace(CustomTxtTraceDefinition definition) {\r
+        fDefinition = definition;\r
+        fEventType = new CustomTxtEventType(fDefinition);\r
+    }\r
+\r
     public CustomTxtTrace(String name, CustomTxtTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException {\r
         super(name, CustomTxtEvent.class, path, cacheSize);\r
         fDefinition = definition;\r
@@ -48,7 +53,8 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     }\r
 \r
        @Override\r
-    public ITmfTrace createTraceCopy() {\r
+       @SuppressWarnings({ "unchecked", "rawtypes" })\r
+       public ITmfTrace copy() {\r
         // TODO Auto-generated method stub\r
         return null;\r
     }\r
@@ -98,7 +104,13 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     public TmfContext seekLocation(double ratio) {\r
         try {\r
             BufferedRandomAccessFile raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
-            ITmfLocation<?> location = new TmfLocation<Long>(new Long((long) (ratio * raFile.length())));\r
+            long pos = (long) (ratio * raFile.length());\r
+            while (pos > 0) {\r
+                raFile.seek(pos - 1);\r
+                if (raFile.read() == '\n') break;\r
+                pos--;\r
+            }\r
+            ITmfLocation<?> location = new TmfLocation<Long>(new Long(pos));\r
             TmfContext context = seekLocation(location);\r
             context.setRank(ITmfContext.UNKNOWN_RANK);\r
             return context;\r
@@ -296,7 +308,7 @@ public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {
     }\r
     \r
     public CustomTxtEvent parseFirstLine(CustomTxtTraceContext context) {\r
-        CustomTxtEvent event = new CustomTxtEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$\r
+        CustomTxtEvent event = new CustomTxtEvent(fDefinition, this, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$\r
         event.processGroups(context.inputLine, context.firstLineMatcher);\r
         event.setContent(new CustomEventContent(event, new StringBuffer(context.firstLine)));\r
         return event;\r
This page took 0.024764 seconds and 5 git commands to generate.