Java Code Examples for org.jsoup.helper.StringUtil#join()
The following examples show how to use
org.jsoup.helper.StringUtil#join() .
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: Element.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Get a CSS selector that will uniquely select this element. * <p> * If the element has an ID, returns #id; * otherwise returns the parent (if any) CSS selector, followed by {@literal '>'}, * followed by a unique selector for the element (tag.class.class:nth-child(n)). * </p> * * @return the CSS Path that can be used to retrieve the element in a selector. */ public String cssSelector() { if (id().length() > 0) return "#" + id(); // Translate HTML namespace ns:tag to CSS namespace syntax ns|tag String tagName = tagName().replace(':', '|'); StringBuilder selector = new StringBuilder(tagName); String classes = StringUtil.join(classNames(), "."); if (classes.length() > 0) selector.append('.').append(classes); if (parent() == null || parent() instanceof Document) // don't add Document to selector, as will always have a html node return selector.toString(); selector.insert(0, " > "); if (parent().select(selector.toString()).size() > 1) selector.append(String.format( ":nth-child(%d)", elementSiblingIndex() + 1)); return parent().cssSelector() + selector.toString(); }
Example 2
Source File: Element.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Get a CSS selector that will uniquely select this element. * <p> * If the element has an ID, returns #id; * otherwise returns the parent (if any) CSS selector, followed by {@literal '>'}, * followed by a unique selector for the element (tag.class.class:nth-child(n)). * </p> * * @return the CSS Path that can be used to retrieve the element in a selector. */ public String cssSelector() { if (id().length() > 0) return "#" + id(); // Translate HTML namespace ns:tag to CSS namespace syntax ns|tag String tagName = tagName().replace(':', '|'); StringBuilder selector = new StringBuilder(tagName); String classes = StringUtil.join(classNames(), "."); if (classes.length() > 0) selector.append('.').append(classes); if (parent() == null || parent() instanceof Document) // don't add Document to selector, as will always have a html node return selector.toString(); selector.insert(0, " > "); if (parent().select(selector.toString()).size() > 1) selector.append(String.format( ":nth-child(%d)", elementSiblingIndex() + 1)); return parent().cssSelector() + selector.toString(); }
Example 3
Source File: Element.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Get a CSS selector that will uniquely select this element. * <p> * If the element has an ID, returns #id; * otherwise returns the parent (if any) CSS selector, followed by {@literal '>'}, * followed by a unique selector for the element (tag.class.class:nth-child(n)). * </p> * * @return the CSS Path that can be used to retrieve the element in a selector. */ public String cssSelector() { if (id().length() > 0) return "#" + id(); // Translate HTML namespace ns:tag to CSS namespace syntax ns|tag String tagName = tagName().replace(':', '|'); StringBuilder selector = new StringBuilder(tagName); String classes = StringUtil.join(classNames(), "."); if (classes.length() > 0) selector.append('.').append(classes); if (parent() == null || parent() instanceof Document) // don't add Document to selector, as will always have a html node return selector.toString(); selector.insert(0, " > "); if (parent().select(selector.toString()).size() > 1) selector.append(String.format( ":nth-child(%d)", elementSiblingIndex() + 1)); return parent().cssSelector() + selector.toString(); }
Example 4
Source File: CombiningEvaluator.java From zongtui-webcrawler with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, " "); }
Example 5
Source File: CombiningEvaluator.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, " "); }
Example 6
Source File: CombiningEvaluator.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, " "); }
Example 7
Source File: CombiningEvaluator.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, ", "); }
Example 8
Source File: CombiningEvaluator.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, " "); }
Example 9
Source File: CombiningEvaluator.java From astor with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, ", "); }
Example 10
Source File: CombiningEvaluator.java From jsoup-learning with MIT License | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, " "); }
Example 11
Source File: CombiningEvaluator.java From xsoup with MIT License | 4 votes |
@Override public String toString() { return StringUtil.join(evaluators, " "); }