@Test public void readXML() throws Exception { SourceMatcher sm = new SourceMatcher(fileName); String xml = writeXMLAndGetStringOutput(sm, false); xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n<FindBugsFilter>" + "\n<Match>" + "\n" + xml + "\n</Match>" + "\n</FindBugsFilter>\n"; Filter filter = new Filter(new StringInputStream(xml)); assertFalse(filter.match(bug)); bug.addClass("bla", fileName); assertTrue(filter.match(bug)); }
@Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } SourceMatcher(String fileName); }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } SourceMatcher(String fileName); @Override String toString(); @Override boolean match(BugInstance bugInstance); @Override void writeXML(XMLOutput xmlOutput, boolean disabled); }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } SourceMatcher(String fileName); @Override String toString(); @Override boolean match(BugInstance bugInstance); @Override void writeXML(XMLOutput xmlOutput, boolean disabled);  }