public interface DownloadContext
Provides all information available during a “fetch resources” operation to a DownloadHandler callback, and allows the user to skip the download of certain file types.
| Modifier and Type | Method and Description |
|---|---|
String |
baseUri()
The current base URI associated with the document whose resources are being fetched.
|
boolean |
downloadSkipped()
Returns a flag indicating that this download has been skipped .
|
boolean |
downloadsStopped()
Returns a flag indicating that all downloads have been stopped
|
URL |
downloadUrl()
Returns the fully assembled URL pointing to a remote resource, which will be used to perform the download into the
targetFile(). |
String |
originalDownloadLink()
Returns the original link extracted from the HTML or CSS file.
|
File |
parentCssFile()
Returns the CSS file that is going to be updated after the fetch resources operation is complete.
|
File |
parentDir()
The directory where the
parentHtmlFile() is located. |
File |
parentHtmlFile()
Returns the HTML file that is going to be updated/generated after the fetch resources operation is complete.
|
com.univocity.api.io.RateLimiter |
rateLimiter()
Returns the
RateLimiter being used during the fetch resources operation to slow down the rate of downloads being performed. |
void |
setBaseUri(String baseUri)
Modifies the current base URI associated with the document whose resources are being fetched.
|
void |
setTargetFile(File newFile)
Changes the download destination to a new location.
|
void |
skipDownload()
Skips this download and moves on to the next.
|
HtmlElement |
sourceElement()
Returns the specific
HtmlElement of the HTML that has a reference to the resource being downloaded. |
void |
stopAllDownloads()
Skips this download and stops any active downloads, finalizing the fetch operation
|
File |
targetFile()
Returns the local target
File where the downloaded contents will be saved. |
String |
targetFileExtension()
Returns the extension of the
targetFile(). |
String |
targetRelativePath()
Returns the relative path of the file being downloaded.
|
String baseUri()
The current base URI associated with the document whose resources are being fetched. Used to “build” the full URL used to download a given resource. For example, if a link such as <a href="/Images/Icons/garage.svg"></a> is being processed, and the base URI is set to http://www.univocity.com, the download URL will be http://www.univocity.com/Images/Icons/garage.svg
Stringvoid setBaseUri(String baseUri)
Modifies the current base URI associated with the document whose resources are being fetched. Used to “build” the full URL used to download a given resource. For example, if a link such as <a href="/Images/Icons/garage.svg"></a> is being processed, and the base URI is set to http://www.univocity.com, the download URL will be http://www.univocity.com/Images/Icons/garage.svg
baseUri - the base URI to use for generating absolute download URL paths.com.univocity.api.io.RateLimiter rateLimiter()
Returns the RateLimiter being used during the fetch resources operation to slow down the rate of downloads being performed. This rate limiter is configured via FetchOptions.getRemoteInterval() and is not associated with the setting in RemoteParserSettings.getRemoteInterval().
HtmlElement sourceElement()
Returns the specific HtmlElement of the HTML that has a reference to the resource being downloaded. Any attribute of this element that points to a remote resource will be updated to point to the file downloaded locally. Will only return a non-null element when parentHtmlFile() returns a valid File.
This method will return null when a CSS file is being updated to point to local resources, i.e. parentHtmlFile() returns null and parentCssFile() returns a valid File.
null if the file to download originates from a CSS file.File parentHtmlFile()
Returns the HTML file that is going to be updated/generated after the fetch resources operation is complete. All HTML nodes that have attributes pointing to a remote resource that could be downloaded will be modified to point to the locally downloaded files.
The resulting HTML file will not have a <base> tag.
File parentCssFile()
Returns the CSS file that is going to be updated after the fetch resources operation is complete. All URLs pointing to a remote resource that could be downloaded will be modified to point to the locally downloaded files. Paths to these files will be relative to the CSS file location.
File parentDir()
The directory where the parentHtmlFile() is located.
File targetFile()
Returns the local target File where the downloaded contents will be saved. The file may exist already and will be overwritten if FetchOptions.isOverwriteSharedResources() evaluates to true.
void setTargetFile(File newFile)
Changes the download destination to a new location.
newFile - the download destination of the targetFile()String targetFileExtension()
Returns the extension of the targetFile(). Will never be null.
String targetRelativePath()
Returns the relative path of the file being downloaded. The path will be relative to the location of the HTML file if parentHtmlFile() is not null, or relative to the CSS file if null`.parentCssFile() is not
String originalDownloadLink()
Returns the original link extracted from the HTML or CSS file. For example, when fetching the resources of <a href="/Images/Icons/garage.svg"></a>, this method will return /Images/Icons/garage.svg.
URL downloadUrl()
Returns the fully assembled URL pointing to a remote resource, which will be used to perform the download into the targetFile().
void skipDownload()
Skips this download and moves on to the next.
boolean downloadSkipped()
Returns a flag indicating that this download has been skipped .
void stopAllDownloads()
Skips this download and stops any active downloads, finalizing the fetch operation
boolean downloadsStopped()
Returns a flag indicating that all downloads have been stopped
Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.