IStatus status = trace.validate(null, validTracePath);
assertTrue(status.isOK());
assertTrue(status instanceof TraceValidationStatus);
- assertEquals(100, ((TraceValidationStatus) status).getConfidence());
+ assertEquals(180, ((TraceValidationStatus) status).getConfidence());
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(OTHER_PATH), null);
URI uri = FileLocator.toFileURL(location).toURI();
int confidence = 0;
try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(path, "r")) { //$NON-NLS-1$
int lineCount = 0;
- int matches = 0;
+ double matches = 0.0;
String line = rafile.getNextLine();
while ((line != null) && (lineCount++ < MAX_LINES)) {
for (InputLine inputLine : fDefinition.inputs) {
Matcher matcher = inputLine.getPattern().matcher(line);
if (matcher.matches()) {
- matches++;
+ int groupCount = matcher.groupCount();
+ matches += (1.0 + groupCount / ((double) groupCount + 1));
break;
}
}
- confidence = MAX_CONFIDENCE * matches / lineCount;
+ confidence = (int) (MAX_CONFIDENCE * matches / lineCount);
line = rafile.getNextLine();
}
} catch (IOException e) {
int confidence = 0;
try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(path, "r")) { //$NON-NLS-1$
int lineCount = 0;
- int matches = 0;
+ double matches = 0.0;
String line = rafile.getNextLine();
while ((line != null) && (lineCount++ < MAX_LINES)) {
Matcher matcher = getFirstLinePattern().matcher(line);
if (matcher.matches()) {
- matches++;
+ int groupCount = matcher.groupCount();
+ matches += (1.0 + groupCount / ((double) groupCount + 1));
}
- confidence = MAX_CONFIDENCE * matches / lineCount;
+ confidence = (int) (MAX_CONFIDENCE * matches / lineCount);
line = rafile.getNextLine();
}
} catch (IOException e) {
return new TraceValidationStatus(confidence, Activator.PLUGIN_ID);
}
-
@Override
public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException {
super.initTrace(resource, path, type);