Returns the SelectorList. @param selectors the selectors @param webClient the WebClient @return the SelectorList @throws IOException if an error occurs
(final String selectors, final WebClient webClient)
| 2074 | * @throws IOException if an error occurs |
| 2075 | */ |
| 2076 | protected SelectorList getSelectorList(final String selectors, final WebClient webClient) |
| 2077 | throws IOException { |
| 2078 | |
| 2079 | // get us a CSS3Parser from the pool so the chance of reusing it are high |
| 2080 | try (PooledCSS3Parser pooledParser = webClient.getCSS3Parser()) { |
| 2081 | final CSSOMParser parser = new CSSOMParser(pooledParser); |
| 2082 | final CheckErrorHandler errorHandler = new CheckErrorHandler(); |
| 2083 | parser.setErrorHandler(errorHandler); |
| 2084 | |
| 2085 | final SelectorList selectorList = parser.parseSelectors(selectors); |
| 2086 | // in case of error parseSelectors returns null |
| 2087 | if (errorHandler.error() != null) { |
| 2088 | throw new CSSException("Invalid selectors: '" + selectors + "'", errorHandler.error()); |
| 2089 | } |
| 2090 | |
| 2091 | if (selectorList != null) { |
| 2092 | CssStyleSheet.validateSelectors(selectorList, this); |
| 2093 | |
| 2094 | } |
| 2095 | return selectorList; |
| 2096 | } |
| 2097 | } |
| 2098 | |
| 2099 | /** |
| 2100 | * Returns the first element within the document that matches the specified group of selectors. |
no test coverage detected