FilterRuleChainXmlParser { public FilterRuleChain<String> parseChain(InputStream inStream) throws IOException, SAXException { try { Document xmlDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inStream); return parseChain(xmlDoc.getDocumentElement()); } catch (ParserConfigurationException e) { throw new IllegalStateException("XML configuration error!", e); } finally { inStream.close(); } } FilterRuleChainXmlParser();  FilterRuleChainXmlParser(DomUtil domUtil); FilterRuleChain<String> parseChain(InputStream inStream); Map<String, FilterRuleChain<String>> parseChains(Element xmlElement); FilterRuleChain<String> parseChain(Element xmlElement); FilterRuleChain<String> parseChain(Element xmlElement, FilterRuleChain<String> parent); static final String XML_TAG_CHAIN; static final String XML_ATR_CHAIN_ID; static final String XML_ATR_CHAIN_PARENT; static final String XML_ATR_CHAIN_DEFAULT; static final String XML_TAG_RULE_INCLUDE; static final String XML_TAG_RULE_EXCLUDE; static final String XML_ATR_RULE_PATTERN; }
@Test public void test() throws Exception { FilterRuleChainXmlParser parser = new FilterRuleChainXmlParser(); try (InputStream inStream = new ClasspathResource(FilterRuleChainXmlParserTest.class, ".xml", true) .openStream()) { FilterRuleChain chain = parser.parseChain(inStream); assertTrue(chain.accept("/doc/manual.pdf")); assertFalse(chain.accept("/data/manual.pdf")); assertTrue(chain.accept("/data/config.xml")); assertTrue(chain.accept("/data/config.xsl")); assertFalse(chain.accept("/foo/config.xml")); assertFalse(chain.accept("/foo/config.XSL")); assertFalse(chain.accept("/foo/bar/file.pdf")); assertFalse(chain.accept("/foo/bar/file.xml")); assertFalse(chain.accept("/foo/bar/file.XsL")); assertTrue(chain.accept("/foo/bar/file.bar")); } }