Java 类org.jsoup.select.Selector.SelectorParseException 实例源码

项目:catpeds    文件:PawpedsDocumentParserTest.java   
/**
 * Test that {@link PawpedsDocumentParser#parseSearch(Document)} throws an
 * {@link IllegalArgumentException} if there is an jsoup parsing error.
 */
@Test(expected = IllegalArgumentException.class)
public void testJsoupSelectorUnexpectedError() throws Exception {
    // Given
    Document document = mock(Document.class);

    Elements noErrorElement = mock(Elements.class);
    when(noErrorElement.text()).thenReturn("");
    when(document.select("th.error")).thenReturn(noErrorElement);

    when(document.select("table.searchresult tr.searchresult:has(td.searchresult)")).thenThrow(SelectorParseException.class);

    // When
    pawpedsDocumentParser.parseSearch(document);

    // Then
    // the exception is expected
}
项目:marmotta    文件:CssSelectFunction.java   
private LinkedList<String> doFilter(Document jsoup, Set<String> jsoupSelectors) throws IOException {
    LinkedList<String> result = new LinkedList<String>();
    for (String jsoupSel : jsoupSelectors) {
        try {
            for (Element e : jsoup.select(jsoupSel)) {
                result.add(e.outerHtml());
            }
        } catch (SelectorParseException xpe) {
            throw new IllegalArgumentException("error while processing jsoup selector: '" + jsoupSel + "'", xpe);
        }
    }
    return result;
}
项目:marmotta    文件:JsoupFunction.java   
private LinkedList<String> doFilter(Document jsoup, Set<String> jsoupSelectors) throws IOException {
    LinkedList<String> result = new LinkedList<String>();
    for (String jsoupSel : jsoupSelectors) {
        try {
            for (Element e : jsoup.select(jsoupSel)) {
                result.add(e.outerHtml());
            }
        } catch (SelectorParseException xpe) {
            throw new IllegalArgumentException("error while processing jsoup selector: '" + jsoupSel + "'", xpe);
        }
    }
    return result;
}
项目:Tanaguru    文件:DOMHandlerImpl.java   
/**
 * http://www.ibm.com/developerworks/library/x-javaxpathapi.html
 *
 * @param expr
 * @return
 */
@Override
public DOMHandler cssLikeSelectNodeSet(String expr) {
    if (StringUtils.isNotBlank(expr)) {
        try {
        selectedElements = jsoupDocument.select(expr);
        } catch (SelectorParseException spe) {               
        } catch (IllegalArgumentException iae) {
        }
    }
    return this;
}