import javax.xml.parsers.DocumentBuilderFactory;\r
import javax.xml.parsers.ParserConfigurationException;\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.CustomXmlTraceDefinition.InputAttribute;\r
import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;\r
import org.w3c.dom.Document;\r
private CustomXmlEventType fEventType;\r
private InputElement fRecordInputElement;\r
\r
+ public CustomXmlTrace(CustomXmlTraceDefinition definition) {\r
+ fDefinition = definition;\r
+ fEventType = new CustomXmlEventType(fDefinition);\r
+ fRecordInputElement = getRecordInputElement(fDefinition.rootInputElement);\r
+ }\r
+\r
public CustomXmlTrace(String name, CustomXmlTraceDefinition definition, String path, int cacheSize) throws FileNotFoundException {\r
super(name, CustomXmlEvent.class, path, cacheSize);\r
fDefinition = definition;\r
@Override\r
public TmfContext seekLocation(double ratio) {\r
try {\r
- RandomAccessFile raFile = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
- ITmfLocation<?> location = new TmfLocation<Long>(new Long((long) (ratio * raFile.length())));\r
+ BufferedRandomAccessFile raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\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
@Override\r
- public ITmfTrace createTraceCopy() {\r
+ @SuppressWarnings({ "rawtypes", "unchecked" })\r
+ public ITmfTrace copy() {\r
// TODO Auto-generated method stub\r
return null;\r
}\r
\r
@Override\r
public ITmfLocation<?> getCurrentLocation() {\r
- return new TmfLocation<Object>(null);\r
+ // TODO Auto-generated method stub\r
+ return null;\r
}\r
\r
@Override\r
}\r
\r
public CustomXmlEvent extractEvent(Element element, InputElement inputElement) {\r
- CustomXmlEvent event = new CustomXmlEvent(fDefinition, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$\r
+ CustomXmlEvent event = new CustomXmlEvent(fDefinition, this, TmfTimestamp.Zero, new TmfEventSource(""), fEventType, new TmfEventReference("")); //$NON-NLS-1$ //$NON-NLS-2$\r
event.setContent(new CustomEventContent(event, new StringBuffer()));\r
parseElement(element, event, inputElement);\r
return event;\r