Class ResourcesDownloader
Object
InstallationResources
OptionalInstallations
ResourcesDownloader
- All Implemented Interfaces:
Localized
A provider for data licensed under different terms of use than the Apache license.
This class is in charge of downloading the data if necessary and asking user's agreement
before to install them. Authorities managed by the current implementation are:
"EPSG"for the EPSG geodetic dataset.
OptionalInstallations in which user's permission
is asked on the Console. By comparison, the org.apache.sis.gui module
(for example) contains a similar implementation but asking for permission in a JavaFX dialog.- Since:
- 0.7
-
Field Summary
Fields inherited from class OptionalInstallations
destinationDirectoryModifier and TypeFieldDescriptionprotected final PathThe target directory where to install the resources, ornullif none. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaskUserAgreement(String authority, String license) Asks to the user if (s)he agree to download and install the resource for the given authority.Returns the name of the authority who provides data under non-Apache terms of use.Returns the locale to use for messages shown to the user.Methods inherited from class OptionalInstallations
getLicense, getResource, getResourceNames, getSpaceRequirement, openScriptModifier and TypeMethodDescriptiongetLicense(String authority, Locale locale, String mimeType) Returns the terms of use of the dataset provided by the given authority, ornullif none.getResource(String authority, int index) Returns an installation resource for the given authority.String[]getResourceNames(String authority) Returns the names of installation scripts provided by the given authority.intgetSpaceRequirement(String authority) Returns an estimation of the space required on the host computer after download and installation.openScript(String authority, int resource) Returns a reader for the installation script at the given index.Methods inherited from class InstallationResources
getInstructionURL, loadModifier and TypeMethodDescriptionReturns a URL where users can get more information about the installation process.static ServiceLoader<InstallationResources> load()Returns all installation resources found on the module path, regardless if supported or not.
-
Constructor Details
-
ResourcesDownloader
public ResourcesDownloader()Creates a new installation scripts provider.
-
-
Method Details
-
getLocale
Returns the locale to use for messages shown to the user.- Specified by:
getLocalein interfaceLocalized- Overrides:
getLocalein classOptionalInstallations- Returns:
- the locale of messages shown to the user.
-
getAuthorities
Returns the name of the authority who provides data under non-Apache terms of use. If thisResourcesDownloadercannot ask user's agreement because there is noConsoleattached to the current Java virtual machine or the console is not a terminal, then this method returns an empty set.- Overrides:
getAuthoritiesin classOptionalInstallations- Returns:
"EPSG"or an empty set in this class cannot ask user's agreement.
-
askUserAgreement
Asks to the user if (s)he agree to download and install the resource for the given authority. This method may be invoked twice for the sameauthorityargument: first with a nulllicenseargument for asking if the user agrees to download the data, then with a non-nulllicenseargument for asking if the user agrees with the license terms.- Specified by:
askUserAgreementin classOptionalInstallations- Parameters:
authority- "EPSG".license- the license, ornullfor asking if the user wants to download the data.- Returns:
- whether user accepted.
-