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
\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
}\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
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
}\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