Class LocalFileAwareDownloader
- java.lang.Object
-
- com.android.repository.impl.downloader.LocalFileAwareDownloader
-
- All Implemented Interfaces:
Downloader
public class LocalFileAwareDownloader extends java.lang.Object implements Downloader
Decorator around anotherDownloaderthat handlesfile:///URLs. Such URLs can be used for testing.
-
-
Constructor Summary
Constructors Constructor Description LocalFileAwareDownloader(Downloader delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamdownloadAndStream(java.net.URL url, ProgressIndicator indicator)Gets a stream associated with the content at the given URL.java.nio.file.PathdownloadFully(java.net.URL url, ProgressIndicator indicator)Downloads the content at the given URL to a temporary file and returns a handle to that file.voiddownloadFully(java.net.URL url, java.nio.file.Path target, Checksum checksum, ProgressIndicator indicator)Downloads the content at the given URL to the given file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.android.repository.api.Downloader
downloadFullyWithCaching, setDownloadIntermediatesLocation
-
-
-
-
Constructor Detail
-
LocalFileAwareDownloader
public LocalFileAwareDownloader(@NonNull Downloader delegate)
-
-
Method Detail
-
downloadAndStream
@Nullable public java.io.InputStream downloadAndStream(@NonNull java.net.URL url, @NonNull ProgressIndicator indicator) throws java.io.IOExceptionDescription copied from interface:DownloaderGets a stream associated with the content at the given URL. This could be achieved by downloading the file completely, streaming it directly, or some combination.- Specified by:
downloadAndStreamin interfaceDownloader- Parameters:
url- The URL to fetch.indicator- Facility for showing download progress and logging.- Returns:
- An InputStream corresponding to the specified content, or
nullif the download is cancelled. - Throws:
java.io.IOException
-
downloadFully
@Nullable public java.nio.file.Path downloadFully(@NonNull java.net.URL url, @NonNull ProgressIndicator indicator) throws java.io.IOExceptionDescription copied from interface:DownloaderDownloads the content at the given URL to a temporary file and returns a handle to that file.- Specified by:
downloadFullyin interfaceDownloader- Parameters:
url- The URL to fetch.indicator- Facility for showing download progress and logging.- Returns:
- The temporary file, or
nullif the download is cancelled. - Throws:
java.io.IOException
-
downloadFully
public void downloadFully(@NonNull java.net.URL url, @NonNull java.nio.file.Path target, @Nullable Checksum checksum, @NonNull ProgressIndicator indicator) throws java.io.IOExceptionDescription copied from interface:DownloaderDownloads the content at the given URL to the given file. Calling this method instructs the downloader to fetch the content from the original server and bypass any caches.For example, in case of HTTP connections, calling this method may be equivalent to adding "Cache-Control: no-cache" and "Pragma: no-cache" headers to the request, thus instructing the network facilities that no caching is expected to take place (e.g., on proxy servers).
- Specified by:
downloadFullyin interfaceDownloader- Parameters:
url- The URL to fetch.target- The location to download to.checksum- If specified, first checktargetto see if the given checksum matches the existing file. If so, returns immediately.indicator- Facility for showing download progress and logging.- Throws:
java.io.IOException
-
-