PubChemCompoundXMLFormat extends AbstractResourceFormat implements IChemFormatMatcher { @Override public MatchResult matches(List<String> lines) { MatchResult result = NO_MATCH; for (int i = 0; i < lines.size(); i++) { String line = lines.get(i); if (line.contains("<PC-Compound") && result == NO_MATCH) result = new MatchResult(true, this, i); if (line.contains("<PC-Compounds")) return NO_MATCH; } return result; } PubChemCompoundXMLFormat(); static IResourceFormat getInstance(); @Override String getFormatName(); @Override String getMIMEType(); @Override String getPreferredNameExtension(); @Override String[] getNameExtensions(); @Override String getReaderClassName(); @Override String getWriterClassName(); @Override boolean isXMLBased(); @Override int getSupportedDataFeatures(); @Override int getRequiredDataFeatures(); @Override MatchResult matches(List<String> lines);  }
@Test @Override public void testMatches() throws Exception { String header = "<?xml version=\"\"?><PC-Compound/>"; Assert.assertTrue(matches(header)); }
@Test public void testFalsePositive() throws Exception { String header = "<?xml version=\"\"?><PC-Compounds><PC-Compound/></PC-Compounds>"; Assert.assertFalse(matches(header)); }
@Test public void testFalsePositiveWithNewlines() throws Exception { String header = "<PC-Compounds>\n<PC-Compound/>\n</PC-Compounds>"; Assert.assertFalse(matches(header)); }