-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeUtils.java
27 lines (24 loc) · 957 Bytes
/
NodeUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package org.jsoup.nodes;
import org.jsoup.parser.HtmlTreeBuilder;
import org.jsoup.parser.Parser;
/**
* Internal helpers for Nodes, to keep the actual node APIs relatively clean. A jsoup internal class, so don't use it as
* there is no contract API).
*/
final class NodeUtils {
/**
* Get the output setting for this node, or if this node has no document (or parent), retrieve the default output
* settings
*/
static Document.OutputSettings outputSettings(Node node) {
Document owner = node.ownerDocument();
return owner != null ? owner.outputSettings() : (new Document("")).outputSettings();
}
/**
* Get the parser that was used to make this node, or the default HTML parser if it has no parent.
*/
static Parser parser(Node node) {
Document doc = node.ownerDocument();
return doc != null && doc.parser() != null ? doc.parser() : new Parser(new HtmlTreeBuilder());
}
}