Object Documents
-
- All Implemented Interfaces:
public class Documents
-
-
Method Summary
Modifier and Type Method Description final FeaturedDocumentparse(String html, String baseURI)Parse HTML into a FeaturedDocument. final FeaturedDocumentparse(String html, String baseURI, Parser parser)Parse HTML into a FeaturedDocument, using the provided Parser. final FeaturedDocumentparse(String html)Parse HTML into a FeaturedDocument. final FeaturedDocumentparse(File file, String charsetName, String baseURI)Parse the contents of a file as HTML. final FeaturedDocumentparse(Path path, String charsetName, String baseURI)final FeaturedDocumentparse(File file, String charsetName)Parse the contents of a file as HTML. final FeaturedDocumentparse(Path path, String charsetName)final FeaturedDocumentparse(InputStream istream, String charsetName, String baseURI)Read an input stream, and parse it to a FeaturedDocument. final FeaturedDocumentparse(InputStream istream, String charsetName, String baseURI, Parser parser)Read an input stream, and parse it to a FeaturedDocument. final FeaturedDocumentparse(URL url, Long timeoutMillis)Fetch a URL, and parse it as HTML. final FeaturedDocumentparse(URL url, Duration timeout)final FeaturedDocumentparseBodyFragment(String bodyHtml, String baseURI)Parse a fragment of HTML, with the assumption that it forms the bodyof the HTML.final FeaturedDocumentparseBodyFragment(String bodyHtml)Parse a fragment of HTML, with the assumption that it forms the bodyof the HTML.-
-
Method Detail
-
parse
final FeaturedDocument parse(String html, String baseURI)
Parse HTML into a FeaturedDocument. The parser will make a sensible, balanced document tree out of any HTML.
- Parameters:
html- HTML to parsebaseURI- The URL where the HTML was retrieved from.- Returns:
sane HTML
-
parse
final FeaturedDocument parse(String html, String baseURI, Parser parser)
Parse HTML into a FeaturedDocument, using the provided Parser. You can provide an alternate parser, such as a simple XML (non-HTML) parser.
- Parameters:
html- HTML to parsebaseURI- The URL where the HTML was retrieved from.parser- alternate parser to use.- Returns:
sane HTML
-
parse
final FeaturedDocument parse(String html)
Parse HTML into a FeaturedDocument. As no base PAGE is specified, absolute URL detection relies on the HTML including a
<base href>tag.- Parameters:
html- HTML to parse- Returns:
sane HTML
-
parse
final FeaturedDocument parse(File file, String charsetName, String baseURI)
Parse the contents of a file as HTML.
- Parameters:
file- file to load HTML fromcharsetName- (optional) character set of file contents.baseURI- The URL where the HTML was retrieved from, to resolve relative links against.- Returns:
sane HTML
-
parse
final FeaturedDocument parse(Path path, String charsetName, String baseURI)
-
parse
final FeaturedDocument parse(File file, String charsetName)
Parse the contents of a file as HTML. The location of the file is used as the base PAGE to qualify relative URLs.
- Parameters:
file- file to load HTML fromcharsetName- (optional) character set of file contents.- Returns:
sane HTML
-
parse
final FeaturedDocument parse(Path path, String charsetName)
-
parse
final FeaturedDocument parse(InputStream istream, String charsetName, String baseURI)
Read an input stream, and parse it to a FeaturedDocument.
- Parameters:
istream- input stream to read.charsetName- (optional) character set of file contents.baseURI- The URL where the HTML was retrieved from, to resolve relative links against.- Returns:
sane HTML
-
parse
final FeaturedDocument parse(InputStream istream, String charsetName, String baseURI, Parser parser)
Read an input stream, and parse it to a FeaturedDocument. You can provide an alternate parser, such as a simple XML (non-HTML) parser.
- Parameters:
istream- input stream to read.charsetName- (optional) character set of file contents.baseURI- The URL where the HTML was retrieved from, to resolve relative links against.parser- alternate parser to use.- Returns:
sane HTML
-
parse
final FeaturedDocument parse(URL url, Long timeoutMillis)
Fetch a URL, and parse it as HTML. Provided for compatibility; in most cases use .connect instead.
The encoding character set is determined by the content-type header or http-equiv meta tag, or falls back to
UTF-8.- Parameters:
url- URL to fetch (with a GET).timeoutMillis- Connection and read timeout, in milliseconds.- Returns:
The parsed HTML.
-
parse
final FeaturedDocument parse(URL url, Duration timeout)
-
parseBodyFragment
final FeaturedDocument parseBodyFragment(String bodyHtml, String baseURI)
Parse a fragment of HTML, with the assumption that it forms the
bodyof the HTML.- Parameters:
bodyHtml- body HTML fragmentbaseURI- URL to resolve relative URLs against.- Returns:
sane HTML document
-
parseBodyFragment
final FeaturedDocument parseBodyFragment(String bodyHtml)
Parse a fragment of HTML, with the assumption that it forms the
bodyof the HTML.- Parameters:
bodyHtml- body HTML fragment- Returns:
sane HTML document
-
-
-
-