target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Ignore @Test public void testOverflowClone() { StringBuilder builder = new StringBuilder(); for (int i = 0; i < 100000; i++) { builder.insert(0, "<i>"); builder.append("</i>"); } Document doc = Jsoup.parse(builder.toString()); doc.clone(); }
@Override public Document clone() { Document clone = (Document) super.clone(); clone.outputSettings = this.outputSettings.clone(); return clone; }
Document extends Element { @Override public Document clone() { Document clone = (Document) super.clone(); clone.outputSettings = this.outputSettings.clone(); return clone; } }
Document extends Element { @Override public Document clone() { Document clone = (Document) super.clone(); clone.outputSettings = this.outputSettings.clone(); return clone; } Document(String baseUri); }
Document extends Element { @Override public Document clone() { Document clone = (Document) super.clone(); clone.outputSettings = this.outputSettings.clone(); return clone; } Document(String baseUri); static Document createShell(String baseUri); String location(); Element head(); Element body(); String title(); void tit...
Document extends Element { @Override public Document clone() { Document clone = (Document) super.clone(); clone.outputSettings = this.outputSettings.clone(); return clone; } Document(String baseUri); static Document createShell(String baseUri); String location(); Element head(); Element body(); String title(); void tit...
@Test public void testMetaCharsetUpdateDisabled() { final Document docDisabled = Document.createShell(""); final String htmlNoCharset = "<html>\n" + " <head></head>\n" + " <body></body>\n" + "</html>"; assertEquals(htmlNoCharset, docDisabled.toString()); assertNull(docDisabled.select("meta[charset]").first()); }
public static Document createShell(String baseUri) { Validate.notNull(baseUri); Document doc = new Document(baseUri); Element html = doc.appendElement("html"); html.appendElement("head"); html.appendElement("body"); return doc; }
Document extends Element { public static Document createShell(String baseUri) { Validate.notNull(baseUri); Document doc = new Document(baseUri); Element html = doc.appendElement("html"); html.appendElement("head"); html.appendElement("body"); return doc; } }
Document extends Element { public static Document createShell(String baseUri) { Validate.notNull(baseUri); Document doc = new Document(baseUri); Element html = doc.appendElement("html"); html.appendElement("head"); html.appendElement("body"); return doc; } Document(String baseUri); }
Document extends Element { public static Document createShell(String baseUri) { Validate.notNull(baseUri); Document doc = new Document(baseUri); Element html = doc.appendElement("html"); html.appendElement("head"); html.appendElement("body"); return doc; } Document(String baseUri); static Document createShell(String ba...
Document extends Element { public static Document createShell(String baseUri) { Validate.notNull(baseUri); Document doc = new Document(baseUri); Element html = doc.appendElement("html"); html.appendElement("head"); html.appendElement("body"); return doc; } Document(String baseUri); static Document createShell(String ba...
@Test public void testMetaCharsetUpdateEnabledAfterCharsetChange() { final Document doc = createHtmlDocument("dontTouch"); doc.charset(Charset.forName(charsetUtf8)); Element selectedElement = doc.select("meta[charset]").first(); assertEquals(charsetUtf8, selectedElement.attr("charset")); assertTrue(doc.select("meta[nam...
public void charset(Charset charset) { updateMetaCharsetElement(true); outputSettings.charset(charset); ensureMetaCharsetElement(); }
Document extends Element { public void charset(Charset charset) { updateMetaCharsetElement(true); outputSettings.charset(charset); ensureMetaCharsetElement(); } }
Document extends Element { public void charset(Charset charset) { updateMetaCharsetElement(true); outputSettings.charset(charset); ensureMetaCharsetElement(); } Document(String baseUri); }
Document extends Element { public void charset(Charset charset) { updateMetaCharsetElement(true); outputSettings.charset(charset); ensureMetaCharsetElement(); } Document(String baseUri); static Document createShell(String baseUri); String location(); Element head(); Element body(); String title(); void title(String tit...
Document extends Element { public void charset(Charset charset) { updateMetaCharsetElement(true); outputSettings.charset(charset); ensureMetaCharsetElement(); } Document(String baseUri); static Document createShell(String baseUri); String location(); Element head(); Element body(); String title(); void title(String tit...
@Test public void testMetaCharsetUpdatedDisabledPerDefault() { final Document doc = createHtmlDocument("none"); assertFalse(doc.updateMetaCharsetElement()); }
public void updateMetaCharsetElement(boolean update) { this.updateMetaCharset = update; }
Document extends Element { public void updateMetaCharsetElement(boolean update) { this.updateMetaCharset = update; } }
Document extends Element { public void updateMetaCharsetElement(boolean update) { this.updateMetaCharset = update; } Document(String baseUri); }
Document extends Element { public void updateMetaCharsetElement(boolean update) { this.updateMetaCharset = update; } Document(String baseUri); static Document createShell(String baseUri); String location(); Element head(); Element body(); String title(); void title(String title); Element createElement(String tagName); ...
Document extends Element { public void updateMetaCharsetElement(boolean update) { this.updateMetaCharset = update; } Document(String baseUri); static Document createShell(String baseUri); String location(); Element head(); Element body(); String title(); void title(String title); Element createElement(String tagName); ...
@Test public void hasAssociatedControls() { String html = "<form id=1><button id=1><fieldset id=2 /><input id=3><keygen id=4><object id=5><output id=6>" + "<select id=7><option></select><textarea id=8><p id=9>"; Document doc = Jsoup.parse(html); FormElement form = (FormElement) doc.select("form").first(); assertEquals(...
public Elements elements() { return elements; }
FormElement extends Element { public Elements elements() { return elements; } }
FormElement extends Element { public Elements elements() { return elements; } FormElement(Tag tag, String baseUri, Attributes attributes); }
FormElement extends Element { public Elements elements() { return elements; } FormElement(Tag tag, String baseUri, Attributes attributes); Elements elements(); FormElement addElement(Element element); Connection submit(); List<Connection.KeyVal> formData(); }
FormElement extends Element { public Elements elements() { return elements; } FormElement(Tag tag, String baseUri, Attributes attributes); Elements elements(); FormElement addElement(Element element); Connection submit(); List<Connection.KeyVal> formData(); }
@Test public void createsFormData() { String html = "<form><input name='one' value='two'><select name='three'><option value='not'>" + "<option value='four' selected><option value='five' selected><textarea name=six>seven</textarea>" + "<input name='seven' type='radio' value='on' checked><input name='seven' type='radio' ...
public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = el.attr("type"); if ("select"....
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
@Test public void createsSubmitableConnection() { String html = "<form action='/search'><input name='q'></form>"; Document doc = Jsoup.parse(html, "http: doc.select("[name=q]").attr("value", "jsoup"); FormElement form = ((FormElement) doc.select("form").first()); Connection con = form.submit(); assertEquals(Connection....
public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Connection.Method.POST : Connect...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
@Test public void actionWithNoValue() { String html = "<form><input name='q'></form>"; Document doc = Jsoup.parse(html, "http: FormElement form = ((FormElement) doc.select("form").first()); Connection con = form.submit(); assertEquals("http: }
public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Connection.Method.POST : Connect...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
@Test public void testApply() throws Exception { A a = new A(); List<Integer> list = Lists.newArrayList(1, 2, 3); a.setList(list); Method m = A.class.getDeclaredMethod("getList"); GetterInvoker invoker = FunctionalGetterInvoker.create("list", m); String r = (String) invoker.invoke(a); assertThat(r, is(new Gson().toJson...
@Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); } }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); } }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); } @Nullable @Override String apply(@Nullable Object input); }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); } @Nullable @Override String apply(@Nullable Object input); }
@Test public void actionWithNoBaseUri() { String html = "<form><input name='q'></form>"; Document doc = Jsoup.parse(html); FormElement form = ((FormElement) doc.select("form").first()); boolean threw = false; try { Connection con = form.submit(); } catch (IllegalArgumentException e) { threw = true; assertEquals("Could ...
public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Connection.Method.POST : Connect...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
FormElement extends Element { public Connection submit() { String action = hasAttr("action") ? absUrl("action") : baseUri(); Validate.notEmpty(action, "Could not determine a form action URL for submit. Ensure you set a base URI when parsing."); Connection.Method method = attr("method").toUpperCase().equals("POST") ? Co...
@Test public void formsAddedAfterParseAreFormElements() { Document doc = Jsoup.parse("<body />"); doc.body().html("<form action='http: Element formEl = doc.select("form").first(); assertTrue(formEl instanceof FormElement); FormElement form = (FormElement) formEl; assertEquals(1, form.elements().size()); }
public Elements elements() { return elements; }
FormElement extends Element { public Elements elements() { return elements; } }
FormElement extends Element { public Elements elements() { return elements; } FormElement(Tag tag, String baseUri, Attributes attributes); }
FormElement extends Element { public Elements elements() { return elements; } FormElement(Tag tag, String baseUri, Attributes attributes); Elements elements(); FormElement addElement(Element element); Connection submit(); List<Connection.KeyVal> formData(); }
FormElement extends Element { public Elements elements() { return elements; } FormElement(Tag tag, String baseUri, Attributes attributes); Elements elements(); FormElement addElement(Element element); Connection submit(); List<Connection.KeyVal> formData(); }
@Test public void usesOnForCheckboxValueIfNoValueSet() { Document doc = Jsoup.parse("<form><input type=checkbox checked name=foo></form>"); FormElement form = (FormElement) doc.select("form").first(); List<Connection.KeyVal> data = form.formData(); assertEquals("on", data.get(0).value()); assertEquals("foo", data.get(0...
public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = el.attr("type"); if ("select"....
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
@Test public void adoptedFormsRetainInputs() { String html = "<html>\n" + "<body> \n" + " <table>\n" + " <form action=\"/hello.php\" method=\"post\">\n" + " <tr><td>User:</td><td> <input type=\"text\" name=\"user\" /></td></tr>\n" + " <tr><td>Password:</td><td> <input type=\"password\" name=\"pass\" /></td></tr>\n" + "...
public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = el.attr("type"); if ("select"....
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
FormElement extends Element { public List<Connection.KeyVal> formData() { ArrayList<Connection.KeyVal> data = new ArrayList<>(); for (Element el: elements) { if (!el.tag().isFormSubmittable()) continue; if (el.hasAttr("disabled")) continue; String name = el.attr("name"); if (name.length() == 0) continue; String type = ...
@Test public void html() { Attribute attr = new Attribute("key", "value &"); assertEquals("key=\"value &amp;\"", attr.html()); assertEquals(attr.html(), attr.toString()); }
public String html() { StringBuilder accum = new StringBuilder(); try { html(accum, (new Document("")).outputSettings()); } catch(IOException exception) { throw new SerializationException(exception); } return accum.toString(); }
Attribute implements Map.Entry<String, String>, Cloneable { public String html() { StringBuilder accum = new StringBuilder(); try { html(accum, (new Document("")).outputSettings()); } catch(IOException exception) { throw new SerializationException(exception); } return accum.toString(); } }
Attribute implements Map.Entry<String, String>, Cloneable { public String html() { StringBuilder accum = new StringBuilder(); try { html(accum, (new Document("")).outputSettings()); } catch(IOException exception) { throw new SerializationException(exception); } return accum.toString(); } Attribute(String key, String va...
Attribute implements Map.Entry<String, String>, Cloneable { public String html() { StringBuilder accum = new StringBuilder(); try { html(accum, (new Document("")).outputSettings()); } catch(IOException exception) { throw new SerializationException(exception); } return accum.toString(); } Attribute(String key, String va...
Attribute implements Map.Entry<String, String>, Cloneable { public String html() { StringBuilder accum = new StringBuilder(); try { html(accum, (new Document("")).outputSettings()); } catch(IOException exception) { throw new SerializationException(exception); } return accum.toString(); } Attribute(String key, String va...
@Test public void testBlank() { TextNode one = new TextNode(""); TextNode two = new TextNode(" "); TextNode three = new TextNode(" \n\n "); TextNode four = new TextNode("Hello"); TextNode five = new TextNode(" \nHello "); assertTrue(one.isBlank()); assertTrue(two.isBlank()); assertTrue(three.isBlank()); assertFalse(fou...
public boolean isBlank() { return StringUtil.isBlank(coreValue()); }
TextNode extends LeafNode { public boolean isBlank() { return StringUtil.isBlank(coreValue()); } }
TextNode extends LeafNode { public boolean isBlank() { return StringUtil.isBlank(coreValue()); } TextNode(String text); TextNode(String text, String baseUri); }
TextNode extends LeafNode { public boolean isBlank() { return StringUtil.isBlank(coreValue()); } TextNode(String text); TextNode(String text, String baseUri); String nodeName(); String text(); TextNode text(String text); String getWholeText(); boolean isBlank(); TextNode splitText(int offset); @Override String toStrin...
TextNode extends LeafNode { public boolean isBlank() { return StringUtil.isBlank(coreValue()); } TextNode(String text); TextNode(String text, String baseUri); String nodeName(); String text(); TextNode text(String text); String getWholeText(); boolean isBlank(); TextNode splitText(int offset); @Override String toStrin...
@Test public void testSplitText() { Document doc = Jsoup.parse("<div>Hello there</div>"); Element div = doc.select("div").first(); TextNode tn = (TextNode) div.childNode(0); TextNode tail = tn.splitText(6); assertEquals("Hello ", tn.getWholeText()); assertEquals("there", tail.getWholeText()); tail.text("there!"); asser...
public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String tail = text.substring(offse...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
@Test public void testSplitAnEmbolden() { Document doc = Jsoup.parse("<div>Hello there</div>"); Element div = doc.select("div").first(); TextNode tn = (TextNode) div.childNode(0); TextNode tail = tn.splitText(6); tail.wrap("<b></b>"); assertEquals("Hello <b>there</b>", TextUtil.stripNewlines(div.html())); }
public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String tail = text.substring(offse...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
TextNode extends LeafNode { public TextNode splitText(int offset) { final String text = coreValue(); Validate.isTrue(offset >= 0, "Split offset must be not be negative"); Validate.isTrue(offset < text.length(), "Split offset must not be greater than current text length"); String head = text.substring(0, offset); String...
@Test public void testGetElementById() { Document doc = Jsoup.parse(reference); Element div = doc.getElementById("div1"); assertEquals("div1", div.id()); assertNull(doc.getElementById("none")); Document doc2 = Jsoup.parse("<div id=1><div id=2><p>Hello <span id=2>world!</span></p></div></div>"); Element div2 = doc2.getE...
public Element getElementById(String id) { Validate.notEmpty(id); Elements elements = Collector.collect(new Evaluator.Id(id), this); if (elements.size() > 0) return elements.get(0); else return null; }
Element extends Node { public Element getElementById(String id) { Validate.notEmpty(id); Elements elements = Collector.collect(new Evaluator.Id(id), this); if (elements.size() > 0) return elements.get(0); else return null; } }
Element extends Node { public Element getElementById(String id) { Validate.notEmpty(id); Elements elements = Collector.collect(new Evaluator.Id(id), this); if (elements.size() > 0) return elements.get(0); else return null; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag...
Element extends Node { public Element getElementById(String id) { Validate.notEmpty(id); Elements elements = Collector.collect(new Evaluator.Id(id), this); if (elements.size() > 0) return elements.get(0); else return null; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag...
Element extends Node { public Element getElementById(String id) { Validate.notEmpty(id); Elements elements = Collector.collect(new Evaluator.Id(id), this); if (elements.size() > 0) return elements.get(0); else return null; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag...
@Test public void testNormalisesText() { String h = "<p>Hello<p>There.</p> \n <p>Here <b>is</b> \n s<b>om</b>e text."; Document doc = Jsoup.parse(h); String text = doc.text(); assertEquals("Hello There. Here is some text.", text); }
public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Element) { Element element ...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
@Test public void testApply() throws Exception { A a = new A(); List<Integer> list = Lists.newArrayList(1, 2, 3); a.setList(list); Method m = A.class.getDeclaredMethod("getList"); GetterInvoker invoker = FunctionalGetterInvoker.create("list", m); String r = (String) invoker.invoke(a); assertThat(r, is(JSON.toJSONString...
@Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : JSON.toJSONString(input); }
ObjectToFastjsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : JSON.toJSONString(input); } }
ObjectToFastjsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : JSON.toJSONString(input); } }
ObjectToFastjsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : JSON.toJSONString(input); } @Nullable @Override String apply(@Nullable Object input); }
ObjectToFastjsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : JSON.toJSONString(input); } @Nullable @Override String apply(@Nullable Object input); }
@Test public void testKeepsPreText() { String h = "<p>Hello \n \n there.</p> <div><pre> What's \n\n that?</pre>"; Document doc = Jsoup.parse(h); assertEquals("Hello there. What's \n\n that?", doc.text()); }
public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Element) { Element element ...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
Element extends Node { public String text() { final StringBuilder accum = StringUtil.stringBuilder(); new NodeTraversor(new NodeVisitor() { public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); } else if (node instanceof Elem...
@Test public void testElementSiblingIndex() { Document doc = Jsoup.parse("<div><p>One</p>...<p>Two</p>...<p>Three</p>"); Elements ps = doc.select("p"); assertTrue(0 == ps.get(0).elementSiblingIndex()); assertTrue(1 == ps.get(1).elementSiblingIndex()); assertTrue(2 == ps.get(2).elementSiblingIndex()); }
public int elementSiblingIndex() { if (parent() == null) return 0; return indexInList(this, parent().childElementsList()); }
Element extends Node { public int elementSiblingIndex() { if (parent() == null) return 0; return indexInList(this, parent().childElementsList()); } }
Element extends Node { public int elementSiblingIndex() { if (parent() == null) return 0; return indexInList(this, parent().childElementsList()); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public int elementSiblingIndex() { if (parent() == null) return 0; return indexInList(this, parent().childElementsList()); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUr...
Element extends Node { public int elementSiblingIndex() { if (parent() == null) return 0; return indexInList(this, parent().childElementsList()); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUr...
@Test public void testHasClassDomMethods() { Tag tag = Tag.valueOf("a"); Attributes attribs = new Attributes(); Element el = new Element(tag, "", attribs); attribs.put("class", "toto"); boolean hasClass = el.hasClass("toto"); assertTrue(hasClass); attribs.put("class", " toto"); hasClass = el.hasClass("toto"); assertTru...
public boolean hasClass(String className) { final String classAttr = attributes().getIgnoreCase("class"); final int len = classAttr.length(); final int wantLen = className.length(); if (len == 0 || len < wantLen) { return false; } if (len == wantLen) { return className.equalsIgnoreCase(classAttr); } boolean inClass = f...
Element extends Node { public boolean hasClass(String className) { final String classAttr = attributes().getIgnoreCase("class"); final int len = classAttr.length(); final int wantLen = className.length(); if (len == 0 || len < wantLen) { return false; } if (len == wantLen) { return className.equalsIgnoreCase(classAttr)...
Element extends Node { public boolean hasClass(String className) { final String classAttr = attributes().getIgnoreCase("class"); final int len = classAttr.length(); final int wantLen = className.length(); if (len == 0 || len < wantLen) { return false; } if (len == wantLen) { return className.equalsIgnoreCase(classAttr)...
Element extends Node { public boolean hasClass(String className) { final String classAttr = attributes().getIgnoreCase("class"); final int len = classAttr.length(); final int wantLen = className.length(); if (len == 0 || len < wantLen) { return false; } if (len == wantLen) { return className.equalsIgnoreCase(classAttr)...
Element extends Node { public boolean hasClass(String className) { final String classAttr = attributes().getIgnoreCase("class"); final int len = classAttr.length(); final int wantLen = className.length(); if (len == 0 || len < wantLen) { return false; } if (len == wantLen) { return className.equalsIgnoreCase(classAttr)...
@Test public void testFormatHtml() { Document doc = Jsoup.parse("<title>Format test</title><div><p>Hello <span>jsoup <span>users</span></span></p><p>Good.</p></div>"); assertEquals("<html>\n <head>\n <title>Format test</title>\n </head>\n <body>\n <div>\n <p>Hello <span>jsoup <span>users</span></span></p>\n <p>Good.</p...
public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
@Test public void testFormatOutline() { Document doc = Jsoup.parse("<title>Format test</title><div><p>Hello <span>jsoup <span>users</span></span></p><p>Good.</p></div>"); doc.outputSettings().outline(true); assertEquals("<html>\n <head>\n <title>Format test</title>\n </head>\n <body>\n <div>\n <p>\n Hello \n <span>\n j...
public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
@Test public void testSetIndent() { Document doc = Jsoup.parse("<div><p>Hello\nthere</p></div>"); doc.outputSettings().indentAmount(0); assertEquals("<html>\n<head></head>\n<body>\n<div>\n<p>Hello there</p>\n</div>\n</body>\n</html>", doc.html()); }
public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
@Test public void testEmptyElementFormatHtml() { Document doc = Jsoup.parse("<section><div></div></section>"); assertEquals("<section>\n <div></div>\n</section>", doc.select("section").first().outerHtml()); }
public Elements select(String cssQuery) { return Selector.select(cssQuery, this); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
@Test public void testNoIndentOnScriptAndStyle() { Document doc = Jsoup.parse("<script>one\ntwo</script>\n<style>three\nfour</style>"); assertEquals("<script>one\ntwo</script> \n<style>three\nfour</style>", doc.head().html()); }
public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
Element extends Node { public String html() { StringBuilder accum = StringUtil.stringBuilder(); html(accum); return getOutputSettings().prettyPrint() ? accum.toString().trim() : accum.toString(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Overrid...
@Test public void testPrependElement() { Document doc = Jsoup.parse("<div id=1><p>Hello</p></div>"); Element div = doc.getElementById("1"); div.prependElement("p").text("Before"); assertEquals("Before", div.child(0).text()); assertEquals("Hello", div.child(1).text()); }
public Element prependElement(String tagName) { Element child = new Element(Tag.valueOf(tagName), baseUri()); prependChild(child); return child; }
Element extends Node { public Element prependElement(String tagName) { Element child = new Element(Tag.valueOf(tagName), baseUri()); prependChild(child); return child; } }
Element extends Node { public Element prependElement(String tagName) { Element child = new Element(Tag.valueOf(tagName), baseUri()); prependChild(child); return child; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Element prependElement(String tagName) { Element child = new Element(Tag.valueOf(tagName), baseUri()); prependChild(child); return child; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @...
Element extends Node { public Element prependElement(String tagName) { Element child = new Element(Tag.valueOf(tagName), baseUri()); prependChild(child); return child; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @...
@Test public void testPrependText() { Document doc = Jsoup.parse("<div id=1><p>Hello</p></div>"); Element div = doc.getElementById("1"); div.prependText("there & now > "); assertEquals("there & now > Hello", div.text()); assertEquals("there &amp; now &gt; <p>Hello</p>", TextUtil.stripNewlines(div.html())); }
public Element prependText(String text) { Validate.notNull(text); TextNode node = new TextNode(text); prependChild(node); return this; }
Element extends Node { public Element prependText(String text) { Validate.notNull(text); TextNode node = new TextNode(text); prependChild(node); return this; } }
Element extends Node { public Element prependText(String text) { Validate.notNull(text); TextNode node = new TextNode(text); prependChild(node); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Element prependText(String text) { Validate.notNull(text); TextNode node = new TextNode(text); prependChild(node); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override S...
Element extends Node { public Element prependText(String text) { Validate.notNull(text); TextNode node = new TextNode(text); prependChild(node); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override S...
@Test public void testApply() throws Exception { A a = new A(); List<Integer> list = Lists.newArrayList(1, 2, 3); String json = JSON.toJSONString(list); Method m = A.class.getDeclaredMethod("setList", List.class); SetterInvoker invoker = FunctionalSetterInvoker.create("list", m); invoker.invoke(a, json); assertThat(a.g...
@Nullable @Override public Object apply(@Nullable String input, Type runtimeOutputType) { return input == null ? null : JSON.parseObject(input, runtimeOutputType); }
FastjsonToObjectFunction implements RuntimeSetterFunction<String, Object> { @Nullable @Override public Object apply(@Nullable String input, Type runtimeOutputType) { return input == null ? null : JSON.parseObject(input, runtimeOutputType); } }
FastjsonToObjectFunction implements RuntimeSetterFunction<String, Object> { @Nullable @Override public Object apply(@Nullable String input, Type runtimeOutputType) { return input == null ? null : JSON.parseObject(input, runtimeOutputType); } }
FastjsonToObjectFunction implements RuntimeSetterFunction<String, Object> { @Nullable @Override public Object apply(@Nullable String input, Type runtimeOutputType) { return input == null ? null : JSON.parseObject(input, runtimeOutputType); } @Nullable @Override Object apply(@Nullable String input, Type runtimeOutputTy...
FastjsonToObjectFunction implements RuntimeSetterFunction<String, Object> { @Nullable @Override public Object apply(@Nullable String input, Type runtimeOutputType) { return input == null ? null : JSON.parseObject(input, runtimeOutputType); } @Nullable @Override Object apply(@Nullable String input, Type runtimeOutputTy...
@Test public void testWrap() { Document doc = Jsoup.parse("<div><p>Hello</p><p>There</p></div>"); Element p = doc.select("p").first(); p.wrap("<div class='head'></div>"); assertEquals("<div><div class=\"head\"><p>Hello</p></div><p>There</p></div>", TextUtil.stripNewlines(doc.body().html())); Element ret = p.wrap("<div>...
@Override public Element wrap(String html) { return (Element) super.wrap(html); }
Element extends Node { @Override public Element wrap(String html) { return (Element) super.wrap(html); } }
Element extends Node { @Override public Element wrap(String html) { return (Element) super.wrap(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { @Override public Element wrap(String html) { return (Element) super.wrap(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Overri...
Element extends Node { @Override public Element wrap(String html) { return (Element) super.wrap(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Overri...
@Test public void before() { Document doc = Jsoup.parse("<div><p>Hello</p><p>There</p></div>"); Element p1 = doc.select("p").first(); p1.before("<div>one</div><div>two</div>"); assertEquals("<div><div>one</div><div>two</div><p>Hello</p><p>There</p></div>", TextUtil.stripNewlines(doc.body().html())); doc.select("p").las...
@Override public Element before(String html) { return (Element) super.before(html); }
Element extends Node { @Override public Element before(String html) { return (Element) super.before(html); } }
Element extends Node { @Override public Element before(String html) { return (Element) super.before(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { @Override public Element before(String html) { return (Element) super.before(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Ov...
Element extends Node { @Override public Element before(String html) { return (Element) super.before(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Ov...
@Test public void after() { Document doc = Jsoup.parse("<div><p>Hello</p><p>There</p></div>"); Element p1 = doc.select("p").first(); p1.after("<div>one</div><div>two</div>"); assertEquals("<div><p>Hello</p><div>one</div><div>two</div><p>There</p></div>", TextUtil.stripNewlines(doc.body().html())); doc.select("p").last(...
@Override public Element after(String html) { return (Element) super.after(html); }
Element extends Node { @Override public Element after(String html) { return (Element) super.after(html); } }
Element extends Node { @Override public Element after(String html) { return (Element) super.after(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { @Override public Element after(String html) { return (Element) super.after(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
Element extends Node { @Override public Element after(String html) { return (Element) super.after(html); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
@Test public void testHasText() { Document doc = Jsoup.parse("<div><p>Hello</p><p></p></div>"); Element div = doc.select("div").first(); Elements ps = doc.select("p"); assertTrue(div.hasText()); assertTrue(ps.first().hasText()); assertFalse(ps.last().hasText()); }
public boolean hasText() { for (Node child: childNodes) { if (child instanceof TextNode) { TextNode textNode = (TextNode) child; if (!textNode.isBlank()) return true; } else if (child instanceof Element) { Element el = (Element) child; if (el.hasText()) return true; } } return false; }
Element extends Node { public boolean hasText() { for (Node child: childNodes) { if (child instanceof TextNode) { TextNode textNode = (TextNode) child; if (!textNode.isBlank()) return true; } else if (child instanceof Element) { Element el = (Element) child; if (el.hasText()) return true; } } return false; } }
Element extends Node { public boolean hasText() { for (Node child: childNodes) { if (child instanceof TextNode) { TextNode textNode = (TextNode) child; if (!textNode.isBlank()) return true; } else if (child instanceof Element) { Element el = (Element) child; if (el.hasText()) return true; } } return false; } Element(St...
Element extends Node { public boolean hasText() { for (Node child: childNodes) { if (child instanceof TextNode) { TextNode textNode = (TextNode) child; if (!textNode.isBlank()) return true; } else if (child instanceof Element) { Element el = (Element) child; if (el.hasText()) return true; } } return false; } Element(St...
Element extends Node { public boolean hasText() { for (Node child: childNodes) { if (child instanceof TextNode) { TextNode textNode = (TextNode) child; if (!textNode.isBlank()) return true; } else if (child instanceof Element) { Element el = (Element) child; if (el.hasText()) return true; } } return false; } Element(St...
@Test public void dataset() { Document doc = Jsoup.parse("<div id=1 data-name=jsoup class=new data-package=jar>Hello</div><p id=2>Hello</p>"); Element div = doc.select("div").first(); Map<String, String> dataset = div.dataset(); Attributes attributes = div.attributes(); assertEquals(2, dataset.size()); assertEquals("js...
public Map<String, String> dataset() { return attributes().dataset(); }
Element extends Node { public Map<String, String> dataset() { return attributes().dataset(); } }
Element extends Node { public Map<String, String> dataset() { return attributes().dataset(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Map<String, String> dataset() { return attributes().dataset(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override String ...
Element extends Node { public Map<String, String> dataset() { return attributes().dataset(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override String ...
@Test public void testClone() { Document doc = Jsoup.parse("<div><p>One<p><span>Two</div>"); Element p = doc.select("p").get(1); Element clone = p.clone(); assertNull(clone.parent()); assertEquals(0, clone.siblingIndex); assertEquals(1, p.siblingIndex); assertNotNull(p.parent()); clone.append("<span>Three"); assertEqua...
@Override public Element clone() { return (Element) super.clone(); }
Element extends Node { @Override public Element clone() { return (Element) super.clone(); } }
Element extends Node { @Override public Element clone() { return (Element) super.clone(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { @Override public Element clone() { return (Element) super.clone(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override String nod...
Element extends Node { @Override public Element clone() { return (Element) super.clone(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override String nod...
@Test public void testClassNames() { Document doc = Jsoup.parse("<div class=\"c1 c2\">C</div>"); Element div = doc.select("div").get(0); assertEquals("c1 c2", div.className()); final Set<String> set1 = div.classNames(); final Object[] arr1 = set1.toArray(); assertTrue(arr1.length==2); assertEquals("c1", arr1[0]); asser...
public Set<String> classNames() { String[] names = classSplit.split(className()); Set<String> classNames = new LinkedHashSet<>(Arrays.asList(names)); classNames.remove(""); return classNames; }
Element extends Node { public Set<String> classNames() { String[] names = classSplit.split(className()); Set<String> classNames = new LinkedHashSet<>(Arrays.asList(names)); classNames.remove(""); return classNames; } }
Element extends Node { public Set<String> classNames() { String[] names = classSplit.split(className()); Set<String> classNames = new LinkedHashSet<>(Arrays.asList(names)); classNames.remove(""); return classNames; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String...
Element extends Node { public Set<String> classNames() { String[] names = classSplit.split(className()); Set<String> classNames = new LinkedHashSet<>(Arrays.asList(names)); classNames.remove(""); return classNames; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String...
Element extends Node { public Set<String> classNames() { String[] names = classSplit.split(className()); Set<String> classNames = new LinkedHashSet<>(Arrays.asList(names)); classNames.remove(""); return classNames; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String...
@Test public void testHashAndEqualsAndValue() { String doc1 = "<div id=1><p class=one>One</p><p class=one>One</p><p class=one>Two</p><p class=two>One</p></div>" + "<div id=2><p class=one>One</p><p class=one>One</p><p class=one>Two</p><p class=two>One</p></div>"; Document doc = Jsoup.parse(doc1); Elements els = doc.sele...
public Elements select(String cssQuery) { return Selector.select(cssQuery, this); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
@Test public void testRelativeUrls() { String html = "<body><a href='./one.html'>One</a> <a href='two.html'>two</a> <a href='../three.html'>Three</a> <a href=' Document doc = Jsoup.parse(html, "http: Elements els = doc.select("a"); assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEq...
public Elements select(String cssQuery) { return Selector.select(cssQuery, this); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
@Test public void testHashcodeIsStableWithContentChanges() { Element root = new Element(Tag.valueOf("root"), ""); HashSet<Element> set = new HashSet<Element>(); set.add(root); root.appendChild(new Element(Tag.valueOf("a"), "")); assertTrue(set.contains(root)); }
public Element appendChild(Node child) { Validate.notNull(child); reparentChild(child); ensureChildNodes(); childNodes.add(child); child.setSiblingIndex(childNodes.size() - 1); return this; }
Element extends Node { public Element appendChild(Node child) { Validate.notNull(child); reparentChild(child); ensureChildNodes(); childNodes.add(child); child.setSiblingIndex(childNodes.size() - 1); return this; } }
Element extends Node { public Element appendChild(Node child) { Validate.notNull(child); reparentChild(child); ensureChildNodes(); childNodes.add(child); child.setSiblingIndex(childNodes.size() - 1); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String b...
Element extends Node { public Element appendChild(Node child) { Validate.notNull(child); reparentChild(child); ensureChildNodes(); childNodes.add(child); child.setSiblingIndex(childNodes.size() - 1); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String b...
Element extends Node { public Element appendChild(Node child) { Validate.notNull(child); reparentChild(child); ensureChildNodes(); childNodes.add(child); child.setSiblingIndex(childNodes.size() - 1); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String b...
@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("setX", long[].class); SetterInvoker invoker = FunctionalSetterInvoker.create("x", m); invoker.invoke(a, "1000000000000000000,2,3"); assertThat(Arrays.toString(a.getX()), is(Arrays.toString(new long[]{100000000000000000...
@Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length; i++) { r[i] = Long.parseLong(ss[i]); } return r; }
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length...
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length...
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length...
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length...
@Test public void testChainedRemoveAttributes() { String html = "<a one two three four>Text</a>"; Document doc = Jsoup.parse(html); Element a = doc.select("a").first(); a .removeAttr("zero") .removeAttr("one") .removeAttr("two") .removeAttr("three") .removeAttr("four") .removeAttr("five"); assertEquals("<a>Text</a>", a...
public Elements select(String cssQuery) { return Selector.select(cssQuery, this); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
Element extends Node { public Elements select(String cssQuery) { return Selector.select(cssQuery, this); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Over...
@Test public void testIs() { String html = "<div><p>One <a class=big>Two</a> Three</p><p>Another</p>"; Document doc = Jsoup.parse(html); Element p = doc.select("p").first(); assertTrue(p.is("p")); assertFalse(p.is("div")); assertTrue(p.is("p:has(a)")); assertTrue(p.is("p:first-child")); assertFalse(p.is("p:last-child")...
public boolean is(String cssQuery) { return is(QueryParser.parse(cssQuery)); }
Element extends Node { public boolean is(String cssQuery) { return is(QueryParser.parse(cssQuery)); } }
Element extends Node { public boolean is(String cssQuery) { return is(QueryParser.parse(cssQuery)); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public boolean is(String cssQuery) { return is(QueryParser.parse(cssQuery)); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override ...
Element extends Node { public boolean is(String cssQuery) { return is(QueryParser.parse(cssQuery)); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override ...
@Test public void elementByTagName() { Element a = new Element("P"); assertTrue(a.tagName().equals("P")); }
public String tagName() { return tag.getName(); }
Element extends Node { public String tagName() { return tag.getName(); } }
Element extends Node { public String tagName() { return tag.getName(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public String tagName() { return tag.getName(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override String nodeName(); String tag...
Element extends Node { public String tagName() { return tag.getName(); } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override int childNodeSize(); @Override String nodeName(); String tag...
@Test public void testAppendTo() { String parentHtml = "<div class='a'></div>"; String childHtml = "<div class='b'></div><p>Two</p>"; Document parentDoc = Jsoup.parse(parentHtml); Element parent = parentDoc.body(); Document childDoc = Jsoup.parse(childHtml); Element div = childDoc.select("div").first(); Element p = chi...
public Element appendTo(Element parent) { Validate.notNull(parent); parent.appendChild(this); return this; }
Element extends Node { public Element appendTo(Element parent) { Validate.notNull(parent); parent.appendChild(this); return this; } }
Element extends Node { public Element appendTo(Element parent) { Validate.notNull(parent); parent.appendChild(this); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); }
Element extends Node { public Element appendTo(Element parent) { Validate.notNull(parent); parent.appendChild(this); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override i...
Element extends Node { public Element appendTo(Element parent) { Validate.notNull(parent); parent.appendChild(this); return this; } Element(String tag); Element(Tag tag, String baseUri, Attributes attributes); Element(Tag tag, String baseUri); @Override Attributes attributes(); @Override String baseUri(); @Override i...
@Test public void escape() { String text = "Hello &<> Å å π 新 there ¾ © »"; String escapedAscii = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(base)); String escapedAsciiFull = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(extended)); String escapedAsciiXhtml = Entitie...
static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
@Test public void escapedSupplemtary() { String text = "\uD835\uDD59"; String escapedAscii = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(base)); assertEquals("&#x1d559;", escapedAscii); String escapedAsciiFull = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(extended))...
static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
@Test public void getByName() { assertEquals("≫⃒", Entities.getByName("nGt")); assertEquals("fj", Entities.getByName("fjlig")); assertEquals("≫", Entities.getByName("gg")); assertEquals("©", Entities.getByName("copy")); }
public static String getByName(String name) { String val = multipoints.get(name); if (val != null) return val; int codepoint = extended.codepointForName(name); if (codepoint != empty) return new String(new int[]{codepoint}, 0, 1); return emptyName; }
Entities { public static String getByName(String name) { String val = multipoints.get(name); if (val != null) return val; int codepoint = extended.codepointForName(name); if (codepoint != empty) return new String(new int[]{codepoint}, 0, 1); return emptyName; } }
Entities { public static String getByName(String name) { String val = multipoints.get(name); if (val != null) return val; int codepoint = extended.codepointForName(name); if (codepoint != empty) return new String(new int[]{codepoint}, 0, 1); return emptyName; } private Entities(); }
Entities { public static String getByName(String name) { String val = multipoints.get(name); if (val != null) return val; int codepoint = extended.codepointForName(name); if (codepoint != empty) return new String(new int[]{codepoint}, 0, 1); return emptyName; } private Entities(); static boolean isNamedEntity(final St...
Entities { public static String getByName(String name) { String val = multipoints.get(name); if (val != null) return val; int codepoint = extended.codepointForName(name); if (codepoint != empty) return new String(new int[]{codepoint}, 0, 1); return emptyName; } private Entities(); static boolean isNamedEntity(final St...
@Test public void escapeSupplementaryCharacter() { String text = new String(Character.toChars(135361)); String escapedAscii = Entities.escape(text, new OutputSettings().charset("ascii").escapeMode(base)); assertEquals("&#x210c1;", escapedAscii); String escapedUtf = Entities.escape(text, new OutputSettings().charset("UT...
static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
@Test public void notMissingMultis() { String text = "&nparsl;"; String un = "\u2AFD\u20E5"; assertEquals(un, Entities.unescape(text)); }
static String unescape(String string) { return unescape(string, false); }
Entities { static String unescape(String string) { return unescape(string, false); } }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
@Test public void notMissingSupplementals() { String text = "&npolint; &qfr;"; String un = "⨔ \uD835\uDD2E"; assertEquals(un, Entities.unescape(text)); }
static String unescape(String string) { return unescape(string, false); }
Entities { static String unescape(String string) { return unescape(string, false); } }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("getX"); GetterInvoker invoker = FunctionalGetterInvoker.create("x", m); a.setX(new String[]{"1", "2", "3"}); assertThat((String) invoker.invoke(a), is("1,2,3")); a.setX(null); assertThat(invoker.invoke(a), nullValue())...
@Nullable @Override public String apply(@Nullable String[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length; i++) { builder.append(SEPARATOR).append(input[i]); } return builder.toStr...
StringArrayToStringFunction implements GetterFunction<String[], String> { @Nullable @Override public String apply(@Nullable String[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length;...
StringArrayToStringFunction implements GetterFunction<String[], String> { @Nullable @Override public String apply(@Nullable String[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length;...
StringArrayToStringFunction implements GetterFunction<String[], String> { @Nullable @Override public String apply(@Nullable String[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length;...
StringArrayToStringFunction implements GetterFunction<String[], String> { @Nullable @Override public String apply(@Nullable String[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length;...
@Test public void unescape() { String text = "Hello &AElig; &amp;&LT&gt; &reg &angst; &angst &#960; &#960 &#x65B0; there &! &frac34; &copy; &COPY;"; assertEquals("Hello Æ &<> ® Å &angst π π 新 there &! ¾ © ©", Entities.unescape(text)); assertEquals("&0987654321; &unknown", Entities.unescape("&0987654321; &unknown")); }
static String unescape(String string) { return unescape(string, false); }
Entities { static String unescape(String string) { return unescape(string, false); } }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
@Test public void strictUnescape() { String text = "Hello &amp= &amp;"; assertEquals("Hello &amp= &", Entities.unescape(text, true)); assertEquals("Hello &= &", Entities.unescape(text)); assertEquals("Hello &= &", Entities.unescape(text, false)); }
static String unescape(String string) { return unescape(string, false); }
Entities { static String unescape(String string) { return unescape(string, false); } }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
@Test public void caseSensitive() { String unescaped = "Ü ü & &"; assertEquals("&Uuml; &uuml; &amp; &amp;", Entities.escape(unescaped, new OutputSettings().charset("ascii").escapeMode(extended))); String escaped = "&Uuml; &uuml; &amp; &AMP"; assertEquals("Ü ü & &", Entities.unescape(escaped)); }
static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); }
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
Entities { static String escape(String string, Document.OutputSettings out) { StringBuilder accum = new StringBuilder(string.length() * 2); try { escape(accum, string, out, false, false, false); } catch (IOException e) { throw new SerializationException(e); } return accum.toString(); } private Entities(); static boole...
@Test public void quoteReplacements() { String escaped = "&#92; &#36;"; String unescaped = "\\ $"; assertEquals(unescaped, Entities.unescape(escaped)); }
static String unescape(String string) { return unescape(string, false); }
Entities { static String unescape(String string) { return unescape(string, false); } }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
@Test public void noSpuriousDecodes() { String string = "http: assertEquals(string, Entities.unescape(string)); }
static String unescape(String string) { return unescape(string, false); }
Entities { static String unescape(String string) { return unescape(string, false); } }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); }
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
Entities { static String unescape(String string) { return unescape(string, false); } private Entities(); static boolean isNamedEntity(final String name); static boolean isBaseNamedEntity(final String name); static Character getCharacterByName(String name); static String getByName(String name); static int codepointsFor...
@Test public void simpleBehaviourTest() { String h = "<div><p class=foo><a href='http: String cleanHtml = Jsoup.clean(h, Whitelist.simpleText()); assertEquals("Hello <b>there</b>!", TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void simpleBehaviourTest2() { String h = "Hello <b>there</b>!"; String cleanHtml = Jsoup.clean(h, Whitelist.simpleText()); assertEquals("Hello <b>there</b>!", TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void basicBehaviourTest() { String h = "<div><p><a href='javascript:sendAllMoney()'>Dodgy</a> <A HREF='HTTP: String cleanHtml = Jsoup.clean(h, Whitelist.basic()); assertEquals("<p><a rel=\"nofollow\">Dodgy</a> <a href=\"http: TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void basicWithImagesTest() { String h = "<div><p><img src='http: String cleanHtml = Jsoup.clean(h, Whitelist.basicWithImages()); assertEquals("<p><img src=\"http: }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testRelaxed() { String h = "<h1>Head</h1><table><tr><td>One<td>Two</td></tr></table>"; String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("<h1>Head</h1><table><tbody><tr><td>One</td><td>Two</td></tr></tbody></table>", TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("setX", String[].class); SetterInvoker invoker = FunctionalSetterInvoker.create("x", m); invoker.invoke(a, "1,2,3"); assertThat(Arrays.toString(a.getX()), is(Arrays.toString(new String[]{"1", "2", "3"}))); invoker.invok...
@Nullable @Override public String[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new String[0]; } return input.split(SEPARATOR); }
StringToStringArrayFunction implements SetterFunction<String, String[]> { @Nullable @Override public String[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new String[0]; } return input.split(SEPARATOR); } }
StringToStringArrayFunction implements SetterFunction<String, String[]> { @Nullable @Override public String[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new String[0]; } return input.split(SEPARATOR); } }
StringToStringArrayFunction implements SetterFunction<String, String[]> { @Nullable @Override public String[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new String[0]; } return input.split(SEPARATOR); } @Nullable @Override String[] apply(@Nullable String input...
StringToStringArrayFunction implements SetterFunction<String, String[]> { @Nullable @Override public String[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new String[0]; } return input.split(SEPARATOR); } @Nullable @Override String[] apply(@Nullable String input...
@Test public void testRemoveTags() { String h = "<div><p><A HREF='HTTP: String cleanHtml = Jsoup.clean(h, Whitelist.basic().removeTags("a")); assertEquals("<p>Nice</p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testRemoveAttributes() { String h = "<div><p>Nice</p><blockquote cite='http: String cleanHtml = Jsoup.clean(h, Whitelist.basic().removeAttributes("blockquote", "cite")); assertEquals("<p>Nice</p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testRemoveEnforcedAttributes() { String h = "<div><p><A HREF='HTTP: String cleanHtml = Jsoup.clean(h, Whitelist.basic().removeEnforcedAttribute("a", "rel")); assertEquals("<p><a href=\"http: TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testRemoveProtocols() { String h = "<p>Contact me <a href='mailto:[email protected]'>here</a></p>"; String cleanHtml = Jsoup.clean(h, Whitelist.basic().removeProtocols("a", "href", "ftp", "mailto")); assertEquals("<p>Contact me <a rel=\"nofollow\">here</a></p>", TextUtil.stripNewlines(cleanHtml)); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test @MultiLocaleTest public void whitelistedProtocolShouldBeRetained() { Whitelist whitelist = Whitelist.none() .addTags("a") .addAttributes("a", "href") .addProtocols("a", "href", "something"); String cleanHtml = Jsoup.clean("<a href=\"SOMETHING: assertEquals("<a href=\"SOMETHING: }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testDropComments() { String h = "<p>Hello<!-- no --></p>"; String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("<p>Hello</p>", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testDropXmlProc() { String h = "<?import namespace=\"xss\"><p>Hello</p>"; String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("<p>Hello</p>", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testDropScript() { String h = "<SCRIPT SRC= String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testDropImageScript() { String h = "<IMG SRC=\"javascript:alert('XSS')\">"; String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("<img>", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testCleanJavascriptHref() { String h = "<A HREF=\"javascript:document.location='http: String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("<a>XSS</a>", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("getX"); GetterInvoker invoker = FunctionalGetterInvoker.create("x", m); a.setX(new int[]{1, 2, 3}); assertThat((String) invoker.invoke(a), is("1,2,3")); a.setX(null); assertThat(invoker.invoke(a), nullValue()); a.setX(...
@Nullable @Override public String apply(@Nullable int[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length; i++) { builder.append(SEPARATOR).append(input[i]); } return builder.toString...
IntArrayToStringFunction implements GetterFunction<int[], String> { @Nullable @Override public String apply(@Nullable int[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length; i++) { b...
IntArrayToStringFunction implements GetterFunction<int[], String> { @Nullable @Override public String apply(@Nullable int[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length; i++) { b...
IntArrayToStringFunction implements GetterFunction<int[], String> { @Nullable @Override public String apply(@Nullable int[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length; i++) { b...
IntArrayToStringFunction implements GetterFunction<int[], String> { @Nullable @Override public String apply(@Nullable int[] input) { if (input == null) { return null; } if (input.length == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input[0]); for (int i = 1; i < input.length; i++) { b...
@Test public void testGetRawType() throws Exception { TypeToken<List<String>> token = new TypeToken<List<String>>() { }; assertThat(token.getRawType().equals(List.class), is(true)); TypeToken<String> token2 = new TypeToken<String>() { }; assertThat(token2.getRawType().equals(String.class), is(true)); }
public final Class<? super T> getRawType() { Class<?> rawType = getRawType(runtimeType); @SuppressWarnings("unchecked") Class<? super T> result = (Class<? super T>) rawType; return result; }
TypeToken extends TypeCapture<T> implements Serializable { public final Class<? super T> getRawType() { Class<?> rawType = getRawType(runtimeType); @SuppressWarnings("unchecked") Class<? super T> result = (Class<? super T>) rawType; return result; } }
TypeToken extends TypeCapture<T> implements Serializable { public final Class<? super T> getRawType() { Class<?> rawType = getRawType(runtimeType); @SuppressWarnings("unchecked") Class<? super T> result = (Class<? super T>) rawType; return result; } protected TypeToken(); private TypeToken(Type type); }
TypeToken extends TypeCapture<T> implements Serializable { public final Class<? super T> getRawType() { Class<?> rawType = getRawType(runtimeType); @SuppressWarnings("unchecked") Class<? super T> result = (Class<? super T>) rawType; return result; } protected TypeToken(); private TypeToken(Type type); static TypeToke...
TypeToken extends TypeCapture<T> implements Serializable { public final Class<? super T> getRawType() { Class<?> rawType = getRawType(runtimeType); @SuppressWarnings("unchecked") Class<? super T> result = (Class<? super T>) rawType; return result; } protected TypeToken(); private TypeToken(Type type); static TypeToke...
@Test public void testCleanAnchorProtocol() { String validAnchor = "<a href=\"#valid\">Valid anchor</a>"; String invalidAnchor = "<a href=\"#anchor with spaces\">Invalid anchor</a>"; String cleanHtml = Jsoup.clean(validAnchor, Whitelist.relaxed()); assertEquals("<a>Valid anchor</a>", cleanHtml); cleanHtml = Jsoup.clean...
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testDropsUnknownTags() { String h = "<p><custom foo=true>Test</custom></p>"; String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); assertEquals("<p>Test</p>", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testHandlesEmptyAttributes() { String h = "<img alt=\"\" src= unknown=''>"; String cleanHtml = Jsoup.clean(h, Whitelist.basicWithImages()); assertEquals("<img alt=\"\">", cleanHtml); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testIsValidBodyHtml() { String ok = "<p>Test <b><a href='http: String ok1 = "<p>Test <b><a href='http: String nok1 = "<p><script></script>Not <b>OK</b></p>"; String nok2 = "<p align=right>Test Not <b>OK</b></p>"; String nok3 = "<!-- comment --><p>Not OK</p>"; String nok4 = "<html><head>Foo</head><body...
public boolean isValidBodyHtml(String bodyHtml) { Document clean = Document.createShell(""); Document dirty = Document.createShell(""); ParseErrorList errorList = ParseErrorList.tracking(1); List<Node> nodes = Parser.parseFragment(bodyHtml, dirty.body(), "", errorList); dirty.body().insertChildren(0, nodes); int numDis...
Cleaner { public boolean isValidBodyHtml(String bodyHtml) { Document clean = Document.createShell(""); Document dirty = Document.createShell(""); ParseErrorList errorList = ParseErrorList.tracking(1); List<Node> nodes = Parser.parseFragment(bodyHtml, dirty.body(), "", errorList); dirty.body().insertChildren(0, nodes); ...
Cleaner { public boolean isValidBodyHtml(String bodyHtml) { Document clean = Document.createShell(""); Document dirty = Document.createShell(""); ParseErrorList errorList = ParseErrorList.tracking(1); List<Node> nodes = Parser.parseFragment(bodyHtml, dirty.body(), "", errorList); dirty.body().insertChildren(0, nodes); ...
Cleaner { public boolean isValidBodyHtml(String bodyHtml) { Document clean = Document.createShell(""); Document dirty = Document.createShell(""); ParseErrorList errorList = ParseErrorList.tracking(1); List<Node> nodes = Parser.parseFragment(bodyHtml, dirty.body(), "", errorList); dirty.body().insertChildren(0, nodes); ...
Cleaner { public boolean isValidBodyHtml(String bodyHtml) { Document clean = Document.createShell(""); Document dirty = Document.createShell(""); ParseErrorList errorList = ParseErrorList.tracking(1); List<Node> nodes = Parser.parseFragment(bodyHtml, dirty.body(), "", errorList); dirty.body().insertChildren(0, nodes); ...
@Test public void testIsValidDocument() { String ok = "<html><head></head><body><p>Hello</p></body><html>"; String nok = "<html><head><script>woops</script><title>Hello</title></head><body><p>Hello</p></body><html>"; Whitelist relaxed = Whitelist.relaxed(); Cleaner cleaner = new Cleaner(relaxed); Document okDoc = Jsoup...
public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; }
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } }
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } Cleaner(Whitelist...
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } Cleaner(Whitelist...
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } Cleaner(Whitelist...
@Test public void resolvesRelativeLinks() { String html = "<a href='/foo'>Link</a><img src='/bar'>"; String clean = Jsoup.clean(html, "http: assertEquals("<a href=\"http: }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void preservesRelativeLinksIfConfigured() { String html = "<a href='/foo'>Link</a><img src='/bar'> <img src='javascript:alert()'>"; String clean = Jsoup.clean(html, "http: assertEquals("<a href=\"/foo\" rel=\"nofollow\">Link</a>\n<img src=\"/bar\"> \n<img>", clean); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void dropsUnresolvableRelativeLinks() { String html = "<a href='/foo'>Link</a>"; String clean = Jsoup.clean(html, Whitelist.basic()); assertEquals("<a rel=\"nofollow\">Link</a>", clean); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void handlesCustomProtocols() { String html = "<img src='cid:12345' /> <img src='data:gzzt' />"; String dropped = Jsoup.clean(html, Whitelist.basicWithImages()); assertEquals("<img> \n<img>", dropped); String preserved = Jsoup.clean(html, Whitelist.basicWithImages().addProtocols("img", "src", "cid", "data"...
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void handlesAllPseudoTag() { String html = "<p class='foo' src='bar'><a class='qux'>link</a></p>"; Whitelist whitelist = new Whitelist() .addAttributes(":all", "class") .addAttributes("p", "style") .addTags("p", "a"); String clean = Jsoup.clean(html, whitelist); assertEquals("<p class=\"foo\"><a class=\"qu...
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("setX", List.class); SetterInvoker invoker = FunctionalSetterInvoker.create("x", m); invoker.invoke(a, "1,2,3"); List<Integer> list = Lists.newArrayList(1, 2, 3); assertThat(a.getX().toString(), is(list.toString())); in...
@Nullable @Override public List<Integer> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Integer>(); } String[] ss = input.split(SEPARATOR); List<Integer> r = new ArrayList<Integer>(); for (int i = 0; i < ss.length; i++) { r.add(Integer.parseInt(ss[i])...
StringToIntegerListFunction implements SetterFunction<String, List<Integer>> { @Nullable @Override public List<Integer> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Integer>(); } String[] ss = input.split(SEPARATOR); List<Integer> r = new ArrayList<...
StringToIntegerListFunction implements SetterFunction<String, List<Integer>> { @Nullable @Override public List<Integer> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Integer>(); } String[] ss = input.split(SEPARATOR); List<Integer> r = new ArrayList<...
StringToIntegerListFunction implements SetterFunction<String, List<Integer>> { @Nullable @Override public List<Integer> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Integer>(); } String[] ss = input.split(SEPARATOR); List<Integer> r = new ArrayList<...
StringToIntegerListFunction implements SetterFunction<String, List<Integer>> { @Nullable @Override public List<Integer> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Integer>(); } String[] ss = input.split(SEPARATOR); List<Integer> r = new ArrayList<...
@Test public void addsTagOnAttributesIfNotSet() { String html = "<p class='foo' src='bar'>One</p>"; Whitelist whitelist = new Whitelist() .addAttributes("p", "class"); String clean = Jsoup.clean(html, whitelist); assertEquals("<p class=\"foo\">One</p>", clean); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void supplyOutputSettings() { Document.OutputSettings os = new Document.OutputSettings(); os.prettyPrint(false); os.escapeMode(Entities.EscapeMode.extended); os.charset("ascii"); String html = "<div><p>&bernou;</p></div>"; String customOut = Jsoup.clean(html, "http: String defaultOut = Jsoup.clean(html, "h...
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void handlesFramesets() { String dirty = "<html><head><script></script><noscript></noscript></head><frameset><frame src=\"foo\" /><frame src=\"foo\" /></frameset></html>"; String clean = Jsoup.clean(dirty, Whitelist.basic()); assertEquals("", clean); Document dirtyDoc = Jsoup.parse(dirty); Document cleanDo...
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void testScriptTagInWhiteList() { Whitelist whitelist = Whitelist.relaxed(); whitelist.addTags( "script" ); assertTrue( Jsoup.isValid("Hello<script>alert('Doh')</script>World !", whitelist ) ); }
public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; }
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } }
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } Cleaner(Whitelist...
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } Cleaner(Whitelist...
Cleaner { public boolean isValid(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); int numDiscarded = copySafeNodes(dirtyDocument.body(), clean.body()); return numDiscarded == 0 && dirtyDocument.head().childNodes().size() == 0; } Cleaner(Whitelist...
@Test public void handlesControlCharactersAfterTagName() { String html = "<a/\06>"; String clean = Jsoup.clean(html, Whitelist.basic()); assertEquals("<a rel=\"nofollow\"></a>", clean); }
public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); }
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
Cleaner { public Document clean(Document dirtyDocument) { Validate.notNull(dirtyDocument); Document clean = Document.createShell(dirtyDocument.baseUri()); if (dirtyDocument.body() != null) copySafeNodes(dirtyDocument.body(), clean.body()); return clean; } Cleaner(Whitelist whitelist); Document clean(Document dirtyDocum...
@Test public void consume() { CharacterReader r = new CharacterReader("one"); assertEquals(0, r.pos()); assertEquals('o', r.current()); assertEquals('o', r.consume()); assertEquals(1, r.pos()); assertEquals('n', r.current()); assertEquals(1, r.pos()); assertEquals('n', r.consume()); assertEquals('e', r.consume()); asse...
char consume() { bufferUp(); char val = isEmpty() ? EOF : charBuf[bufPos]; bufPos++; return val; }
CharacterReader { char consume() { bufferUp(); char val = isEmpty() ? EOF : charBuf[bufPos]; bufPos++; return val; } }
CharacterReader { char consume() { bufferUp(); char val = isEmpty() ? EOF : charBuf[bufPos]; bufPos++; return val; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); }
CharacterReader { char consume() { bufferUp(); char val = isEmpty() ? EOF : charBuf[bufPos]; bufPos++; return val; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consu...
CharacterReader { char consume() { bufferUp(); char val = isEmpty() ? EOF : charBuf[bufPos]; bufPos++; return val; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consu...
@Test public void unconsume() { CharacterReader r = new CharacterReader("one"); assertEquals('o', r.consume()); assertEquals('n', r.current()); r.unconsume(); assertEquals('o', r.current()); assertEquals('o', r.consume()); assertEquals('n', r.consume()); assertEquals('e', r.consume()); assertTrue(r.isEmpty()); r.uncons...
void unconsume() { bufPos--; }
CharacterReader { void unconsume() { bufPos--; } }
CharacterReader { void unconsume() { bufPos--; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); }
CharacterReader { void unconsume() { bufPos--; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
CharacterReader { void unconsume() { bufPos--; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
@Test public void mark() { CharacterReader r = new CharacterReader("one"); r.consume(); r.mark(); assertEquals('n', r.consume()); assertEquals('e', r.consume()); assertTrue(r.isEmpty()); r.rewindToMark(); assertEquals('n', r.consume()); }
void mark() { bufMark = bufPos; }
CharacterReader { void mark() { bufMark = bufPos; } }
CharacterReader { void mark() { bufMark = bufPos; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); }
CharacterReader { void mark() { bufMark = bufPos; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
CharacterReader { void mark() { bufMark = bufPos; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
@Test public void consumeToEnd() { String in = "one two three"; CharacterReader r = new CharacterReader(in); String toEnd = r.consumeToEnd(); assertEquals(in, toEnd); assertTrue(r.isEmpty()); }
String consumeToEnd() { bufferUp(); String data = cacheString(charBuf, stringCache, bufPos, bufLength - bufPos); bufPos = bufLength; return data; }
CharacterReader { String consumeToEnd() { bufferUp(); String data = cacheString(charBuf, stringCache, bufPos, bufLength - bufPos); bufPos = bufLength; return data; } }
CharacterReader { String consumeToEnd() { bufferUp(); String data = cacheString(charBuf, stringCache, bufPos, bufLength - bufPos); bufPos = bufLength; return data; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); }
CharacterReader { String consumeToEnd() { bufferUp(); String data = cacheString(charBuf, stringCache, bufPos, bufLength - bufPos); bufPos = bufLength; return data; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void ...
CharacterReader { String consumeToEnd() { bufferUp(); String data = cacheString(charBuf, stringCache, bufPos, bufLength - bufPos); bufPos = bufLength; return data; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void ...
@Test public void nextIndexOfUnmatched() { CharacterReader r = new CharacterReader("<[[one]]"); assertEquals(-1, r.nextIndexOf("]]>")); }
int nextIndexOf(char c) { bufferUp(); for (int i = bufPos; i < bufLength; i++) { if (c == charBuf[i]) return i - bufPos; } return -1; }
CharacterReader { int nextIndexOf(char c) { bufferUp(); for (int i = bufPos; i < bufLength; i++) { if (c == charBuf[i]) return i - bufPos; } return -1; } }
CharacterReader { int nextIndexOf(char c) { bufferUp(); for (int i = bufPos; i < bufLength; i++) { if (c == charBuf[i]) return i - bufPos; } return -1; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); }
CharacterReader { int nextIndexOf(char c) { bufferUp(); for (int i = bufPos; i < bufLength; i++) { if (c == charBuf[i]) return i - bufPos; } return -1; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); S...
CharacterReader { int nextIndexOf(char c) { bufferUp(); for (int i = bufPos; i < bufLength; i++) { if (c == charBuf[i]) return i - bufPos; } return -1; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); S...
@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("setX", List.class); SetterInvoker invoker = FunctionalSetterInvoker.create("x", m); invoker.invoke(a, "100000000000000000,2,3"); List<Long> list = Lists.newArrayList(100000000000000000L, 2L, 3L); assertThat(a.getX().to...
@Nullable @Override public List<Long> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Long>(); } String[] ss = input.split(SEPARATOR); List<Long> r = new ArrayList<Long>(); for (int i = 0; i < ss.length; i++) { r.add(Long.parseLong(ss[i])); } return r;...
StringToLongListFunction implements SetterFunction<String, List<Long>> { @Nullable @Override public List<Long> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Long>(); } String[] ss = input.split(SEPARATOR); List<Long> r = new ArrayList<Long>(); for (i...
StringToLongListFunction implements SetterFunction<String, List<Long>> { @Nullable @Override public List<Long> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Long>(); } String[] ss = input.split(SEPARATOR); List<Long> r = new ArrayList<Long>(); for (i...
StringToLongListFunction implements SetterFunction<String, List<Long>> { @Nullable @Override public List<Long> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Long>(); } String[] ss = input.split(SEPARATOR); List<Long> r = new ArrayList<Long>(); for (i...
StringToLongListFunction implements SetterFunction<String, List<Long>> { @Nullable @Override public List<Long> apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new ArrayList<Long>(); } String[] ss = input.split(SEPARATOR); List<Long> r = new ArrayList<Long>(); for (i...
@Test public void advance() { CharacterReader r = new CharacterReader("One Two Three"); assertEquals('O', r.consume()); r.advance(); assertEquals('e', r.consume()); }
public void advance() { bufPos++; }
CharacterReader { public void advance() { bufPos++; } }
CharacterReader { public void advance() { bufPos++; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); }
CharacterReader { public void advance() { bufPos++; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
CharacterReader { public void advance() { bufPos++; } CharacterReader(Reader input, int sz); CharacterReader(Reader input); CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
@Test public void consumeToAny() { CharacterReader r = new CharacterReader("One &bar; qux"); assertEquals("One ", r.consumeToAny('&', ';')); assertTrue(r.matches('&')); assertTrue(r.matches("&bar;")); assertEquals('&', r.consume()); assertEquals("bar", r.consumeToAny('&', ';')); assertEquals(';', r.consume()); assertEq...
public String consumeToAny(final char... chars) { bufferUp(); final int start = bufPos; final int remaining = bufLength; final char[] val = charBuf; OUTER: while (bufPos < remaining) { for (char c : chars) { if (val[bufPos] == c) break OUTER; } bufPos++; } return bufPos > start ? cacheString(charBuf, stringCache, start...
CharacterReader { public String consumeToAny(final char... chars) { bufferUp(); final int start = bufPos; final int remaining = bufLength; final char[] val = charBuf; OUTER: while (bufPos < remaining) { for (char c : chars) { if (val[bufPos] == c) break OUTER; } bufPos++; } return bufPos > start ? cacheString(charBuf, ...
CharacterReader { public String consumeToAny(final char... chars) { bufferUp(); final int start = bufPos; final int remaining = bufLength; final char[] val = charBuf; OUTER: while (bufPos < remaining) { for (char c : chars) { if (val[bufPos] == c) break OUTER; } bufPos++; } return bufPos > start ? cacheString(charBuf, ...
CharacterReader { public String consumeToAny(final char... chars) { bufferUp(); final int start = bufPos; final int remaining = bufLength; final char[] val = charBuf; OUTER: while (bufPos < remaining) { for (char c : chars) { if (val[bufPos] == c) break OUTER; } bufPos++; } return bufPos > start ? cacheString(charBuf, ...
CharacterReader { public String consumeToAny(final char... chars) { bufferUp(); final int start = bufPos; final int remaining = bufLength; final char[] val = charBuf; OUTER: while (bufPos < remaining) { for (char c : chars) { if (val[bufPos] == c) break OUTER; } bufPos++; } return bufPos > start ? cacheString(charBuf, ...