From f396007e8ec322ef99329c7b9b37922a927e9897 Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Mon, 12 Aug 2024 15:34:50 +1000 Subject: [PATCH] Nullable annotation for #attribute(key) And some trivial other cleanups --- src/main/java/org/jsoup/nodes/Element.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jsoup/nodes/Element.java b/src/main/java/org/jsoup/nodes/Element.java index d923bb1c08..b065248ec5 100644 --- a/src/main/java/org/jsoup/nodes/Element.java +++ b/src/main/java/org/jsoup/nodes/Element.java @@ -107,7 +107,7 @@ protected boolean hasChildNodes() { return childNodes != EmptyNodes; } - protected List ensureChildNodes() { + @Override protected List ensureChildNodes() { if (childNodes == EmptyNodes) { childNodes = new NodeList(this, 4); } @@ -261,7 +261,7 @@ public Element id(String id) { * * @return this element */ - public Element attr(String attributeKey, String attributeValue) { + @Override public Element attr(String attributeKey, String attributeValue) { super.attr(attributeKey, attributeValue); return this; } @@ -288,7 +288,7 @@ public Element attr(String attributeKey, boolean attributeValue) { @return the Attribute for this key, or null if not present. @since 1.17.2 */ - public Attribute attribute(String key) { + @Nullable Attribute attribute(String key) { return hasAttributes() ? attributes().attribute(key) : null; } @@ -1245,7 +1245,7 @@ public Elements getElementsByAttributeValueMatching(String key, Pattern pattern) /** * Find elements that have attributes whose values match the supplied regular expression. * @param key name of the attribute - * @param regex regular expression to match against attribute values. You can use embedded flags (such as (?i) and (?m) to control regex options. + * @param regex regular expression to match against attribute values. You can use embedded flags (such as {@code (?i)} and {@code (?m)}) to control regex options. * @return elements that have attributes matching this regular expression */ public Elements getElementsByAttributeValueMatching(String key, String regex) { @@ -1319,7 +1319,7 @@ public Elements getElementsMatchingText(Pattern pattern) { /** * Find elements whose text matches the supplied regular expression. - * @param regex regular expression to match text against. You can use embedded flags (such as (?i) and (?m) to control regex options. + * @param regex regular expression to match text against. You can use embedded flags (such as {@code (?i)} and {@code (?m)}) to control regex options. * @return elements matching the supplied regular expression. * @see Element#text() */ @@ -1345,7 +1345,7 @@ public Elements getElementsMatchingOwnText(Pattern pattern) { /** * Find elements whose own text matches the supplied regular expression. - * @param regex regular expression to match text against. You can use embedded flags (such as (?i) and (?m) to control regex options. + * @param regex regular expression to match text against. You can use embedded flags (such as {@code (?i)} and {@code (?m)}) to control regex options. * @return elements matching the supplied regular expression. * @see Element#ownText() */ @@ -1397,7 +1397,7 @@ public TextAccumulator(StringBuilder accum) { this.accum = accum; } - public void head(Node node, int depth) { + @Override public void head(Node node, int depth) { if (node instanceof TextNode) { TextNode textNode = (TextNode) node; appendNormalisedText(accum, textNode); @@ -1410,7 +1410,7 @@ public void head(Node node, int depth) { } } - public void tail(Node node, int depth) { + @Override public void tail(Node node, int depth) { // make sure there is a space between block tags and immediately following text nodes or inline elements
One
Two should be "One Two". if (node instanceof Element) { Element element = (Element) node; @@ -1907,7 +1907,7 @@ private static final class NodeList extends ChangeNotifyingArrayList { this.owner = owner; } - public void onContentsChanged() { + @Override public void onContentsChanged() { owner.nodelistChanged(); } }