Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Dec 16, 2024
1 parent 442ec75 commit dd5eb3b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 21 deletions.
11 changes: 7 additions & 4 deletions src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -858,10 +858,12 @@ else if (methodHasBody)
try {
conn.connect();
if (conn.getDoOutput()) {
OutputStream out = conn.getOutputStream();
try { writePost(req, out, mimeBoundary); }
catch (IOException e) { conn.disconnect(); throw e; }
finally { out.close(); }
try (OutputStream out = conn.getOutputStream()) {
writePost(req, out, mimeBoundary);
} catch (IOException e) {
conn.disconnect();
throw e;
}
}

int status = conn.getResponseCode();
Expand Down Expand Up @@ -1389,6 +1391,7 @@ public String value() {
return value;
}

@Override
public KeyVal inputStream(InputStream inputStream) {
Validate.notNullParam(value, "inputStream");
this.stream = inputStream;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jsoup/helper/W3CDom.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ public W3CBuilder(Document doc) {
}
}

@Override
public void head(org.jsoup.nodes.Node source, int depth) {
namespacesStack.push(new HashMap<>(namespacesStack.peek())); // inherit from above on the stack
if (source instanceof org.jsoup.nodes.Element) {
Expand Down Expand Up @@ -416,6 +417,7 @@ private void append(Node append, org.jsoup.nodes.Node source) {
dest.appendChild(append);
}

@Override
public void tail(org.jsoup.nodes.Node source, int depth) {
if (source instanceof org.jsoup.nodes.Element && dest.getParentNode() instanceof Element) {
dest = dest.getParentNode(); // undescend
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jsoup/nodes/XmlDeclaration.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.jsoup.SerializationException;
import org.jsoup.internal.StringUtil;
import org.jsoup.helper.Validate;

import java.io.IOException;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jsoup/parser/HtmlTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.jspecify.annotations.Nullable;

import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/jsoup/parser/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
import org.jsoup.nodes.Range;
import org.jspecify.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;

import static org.jsoup.internal.SharedConstants.*;


/**
* Parse tokens for the Tokeniser.
*/
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/org/jsoup/parser/Tokeniser.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,6 @@ void error(String errorMsg, Object... args) {
errors.add(new ParseError(reader, errorMsg, args));
}

static boolean currentNodeInHtmlNS() {
// todo: implement namespaces correctly
return true;
// Element currentNode = currentNode();
// return currentNode != null && currentNode.namespace().equals("HTML");
}

/**
* Utility method to consume reader and unescape entities found within.
* @param inAttribute if the text to be unescaped is in an attribute
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jsoup/parser/XmlTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.jsoup.nodes.XmlDeclaration;
import org.jspecify.annotations.Nullable;

import java.io.Reader;
import java.io.StringReader;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jsoup/safety/Safelist.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> prot
return false;
}

private boolean isValidAnchor(String value) {
private static boolean isValidAnchor(String value) {
return value.startsWith("#") && !value.matches(".*\\s.*");
}

Expand Down

0 comments on commit dd5eb3b

Please sign in to comment.