/*******************************************************************************\r
* Copyright (c) 2010 Ericsson\r
- * \r
+ *\r
* All rights reserved. This program and the accompanying materials are\r
* made available under the terms of the Eclipse Public License v1.0 which\r
* accompanies this distribution, and is available at\r
* http://www.eclipse.org/legal/epl-v10.html\r
- * \r
+ *\r
* Contributors:\r
* Patrick Tasse - Initial API and implementation\r
*******************************************************************************/\r
import org.eclipse.core.resources.IResource;\r
import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;\r
import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\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.TmfLongLocation;\r
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
\r
-public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> implements ITmfEventParser<CustomTxtEvent> {\r
+public class CustomTxtTrace extends TmfTrace implements ITmfEventParser {\r
\r
- private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
+ private static final TmfLongLocation NULL_LOCATION = new TmfLongLocation((Long) null);\r
private static final int DEFAULT_CACHE_SIZE = 100;\r
\r
private final CustomTxtTraceDefinition fDefinition;\r
public CustomTxtTrace(final CustomTxtTraceDefinition definition) {\r
fDefinition = definition;\r
fEventType = new CustomTxtEventType(fDefinition);\r
+ setCacheSize(DEFAULT_CACHE_SIZE);\r
}\r
\r
- public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int pageSize) throws TmfTraceException {\r
- super(resource, CustomTxtEvent.class, path, (pageSize > 0) ? pageSize : DEFAULT_CACHE_SIZE);\r
- fDefinition = definition;\r
- fEventType = new CustomTxtEventType(fDefinition);\r
- indexTrace(false);\r
+ public CustomTxtTrace(final IResource resource, final CustomTxtTraceDefinition definition, final String path, final int cacheSize) throws TmfTraceException {\r
+ this(definition);\r
+ setCacheSize((cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE);\r
+ initTrace(resource, path, CustomTxtEvent.class);\r
}\r
\r
@Override\r
- public void initTrace(final IResource resource, final String path, final Class<CustomTxtEvent> eventType) throws TmfTraceException {\r
+ public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> eventType) throws TmfTraceException {\r
super.initTrace(resource, path, eventType);\r
try {\r
fFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
}\r
\r
@Override\r
- public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {\r
+ public synchronized TmfContext seekEvent(final ITmfLocation location) {\r
final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);\r
if (NULL_LOCATION.equals(location) || fFile == null) {\r
return context;\r
try {\r
if (location == null) {\r
fFile.seek(0);\r
- } else if (location.getLocation() instanceof Long) {\r
- fFile.seek((Long) location.getLocation());\r
+ } else if (location.getLocationData() instanceof Long) {\r
+ fFile.seek((Long) location.getLocationData());\r
}\r
String line;\r
long rawPos = fFile.getFilePointer();\r
for (final InputLine input : getFirstLines()) {\r
final Matcher matcher = input.getPattern().matcher(line);\r
if (matcher.find()) {\r
- context.setLocation(new TmfLocation<Long>(rawPos));\r
+ context.setLocation(new TmfLongLocation(rawPos));\r
context.firstLineMatcher = matcher;\r
context.firstLine = line;\r
context.nextLineLocation = fFile.getFilePointer();\r
}\r
pos--;\r
}\r
- final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
+ final ITmfLocation location = new TmfLongLocation(pos);\r
final TmfContext context = seekEvent(location);\r
context.setRank(ITmfContext.UNKNOWN_RANK);\r
return context;\r
}\r
\r
@Override\r
- public synchronized double getLocationRatio(final ITmfLocation<?> location) {\r
+ public synchronized double getLocationRatio(final ITmfLocation location) {\r
if (fFile == null) {\r
return 0;\r
}\r
try {\r
- if (location.getLocation() instanceof Long) {\r
- return (double) ((Long) location.getLocation()) / fFile.length();\r
+ if (location.getLocationData() instanceof Long) {\r
+ return (double) ((Long) location.getLocationData()) / fFile.length();\r
}\r
} catch (final IOException e) {\r
Activator.getDefault().logError("Error seeking event. File: " + getPath(), e); //$NON-NLS-1$\r
}\r
\r
@Override\r
- public ITmfLocation<?> getCurrentLocation() {\r
+ public ITmfLocation getCurrentLocation() {\r
// TODO Auto-generated method stub\r
return null;\r
}\r
}\r
\r
final CustomTxtTraceContext context = (CustomTxtTraceContext) tmfContext;\r
- if (!(context.getLocation().getLocation() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
+ if (!(context.getLocation().getLocationData() instanceof Long) || NULL_LOCATION.equals(context.getLocation())) {\r
return null;\r
}\r
\r
for (final InputLine input : getFirstLines()) {\r
final Matcher matcher = input.getPattern().matcher(line);\r
if (matcher.find()) {\r
- context.setLocation(new TmfLocation<Long>(rawPos));\r
+ context.setLocation(new TmfLongLocation(rawPos));\r
context.firstLineMatcher = matcher;\r
context.firstLine = line;\r
context.nextLineLocation = fFile.getFilePointer();\r
for (final InputLine input : getFirstLines()) {\r
final Matcher matcher = input.getPattern().matcher(line);\r
if (matcher.find()) {\r
- context.setLocation(new TmfLocation<Long>(rawPos));\r
+ context.setLocation(new TmfLongLocation(rawPos));\r
context.firstLineMatcher = matcher;\r
context.firstLine = line;\r
context.nextLineLocation = fFile.getFilePointer();\r