Java Code Examples for org.jsoup.nodes.Element#is()

The following examples show how to use org.jsoup.nodes.Element#is() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Elements.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private Elements siblings(String query, boolean next, boolean all) {
    Elements els = new Elements();
    Evaluator eval = query != null? QueryParser.parse(query) : null;
    for (Element e : this) {
        do {
            Element sib = next ? e.nextElementSibling() : e.previousElementSibling();
            if (sib == null) break;
            if (eval == null)
                els.add(sib);
            else if (sib.is(eval))
                els.add(sib);
            e = sib;
        } while (all);
    }
    return els;
}
 
Example 2
Source File: Elements.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private Elements siblings(String query, boolean next, boolean all) {
    Elements els = new Elements();
    Evaluator eval = query != null? QueryParser.parse(query) : null;
    for (Element e : this) {
        do {
            Element sib = next ? e.nextElementSibling() : e.previousElementSibling();
            if (sib == null) break;
            if (eval == null)
                els.add(sib);
            else if (sib.is(eval))
                els.add(sib);
            e = sib;
        } while (all);
    }
    return els;
}
 
Example 3
Source File: AppShellRegistry.java    From flow with Apache License 2.0 5 votes vote down vote up
private void insertElement(Element elm, Consumer<Element> action) {
    action.accept(elm);
    for (String cssQuery : UNIQUE_ELEMENTS) {
        if (elm.is(cssQuery)) {
            Element first = elm.parent().selectFirst(cssQuery);
            if (first != elm && first != null) {
                first.replaceWith(elm);
            }
            break;
        }
    }
}
 
Example 4
Source File: Elements.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test if any of the matched elements match the supplied query.
 * @param query A selector
 * @return true if at least one element in the list matches the query.
 */
public boolean is(String query) {
    Evaluator eval = QueryParser.parse(query);
    for (Element e : this) {
        if (e.is(eval))
            return true;
    }
    return false;
}
 
Example 5
Source File: Elements.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test if any of the matched elements match the supplied query.
 * @param query A selector
 * @return true if at least one element in the list matches the query.
 */
public boolean is(String query) {
    Evaluator eval = QueryParser.parse(query);
    for (Element e : this) {
        if (e.is(eval))
            return true;
    }
    return false;
}