public abstract class InstallationResources extends Object
InstallationResources
can be used for downloading large files that may not be of interest
to every users, or data that are subject to more restricting terms of use than the Apache license.
"EPSG:4326"
became a de-facto standard in various places like Web Map Services,
images encoded in GeoTIFF format, etc. But the EPSG terms of use
are more restrictive than the Apache license and require that we inform the users about those conditions."Embedded"
is a pseudo-authority for an embedded database containing EPSG and other data.
The embedded database is provided as a convenience for avoiding the need to define a SIS_DATA
directory
on the local machine.
Authority | Provided by Maven module | Used by class |
---|---|---|
"EPSG" | org.apache.sis.non-free:sis-epsg | EPSGFactory |
"Embedded" | org.apache.sis.non-free:sis-embedded-data | All the above |
InstallationResources
implementations shall be declared in the following file:
META-INF/services/org.apache.sis.setup.InstallationResourcesAbove registration is usually done automatically when extension modules are added on the classpath. For example adding the
org.apache.sis.non-free:sis-epsg
Maven dependency as documented on
the Apache SIS web site is the only step needed for
allowing Apache SIS to read the EPSG scripts (however SIS still needs an installation directory
for writing the database; see above-cited web page for more information).Defined in the sis-utility
module
Modifier | Constructor and Description |
---|---|
protected |
InstallationResources()
For subclass constructors.
|
Modifier and Type | Method and Description |
---|---|
abstract Set<String> |
getAuthorities()
Returns identifiers of the resources provided by this instance.
|
abstract String |
getLicense(String authority,
Locale locale,
String mimeType)
Returns the terms of use of the resources distributed by the specified authority, or
null if none. |
Object |
getResource(String authority,
int index)
Returns an installation resource for the given authority, or
null if not available. |
abstract String[] |
getResourceNames(String authority)
Returns the names of all resources of the specified authority that are distributed by this instance.
|
abstract BufferedReader |
openScript(String authority,
int resource)
Returns a reader for the resources at the given index.
|
protected InstallationResources()
public abstract Set<String> getAuthorities()
Authority | Resources |
---|---|
"EPSG" | SQL installation scripts for EPSG geodetic dataset. |
"Embedded" | Data source of embedded database containing EPSG and other resources. |
"Embedded"
is a pseudo-authority for an embedded database containing EPSG and other data.
This embedded database is provided by the org.apache.sis.non-free:sis-embedded-data
module
as a convenience for avoiding the need to define a SIS_DATA
directory on the local machine.
In this particular case, the resource is more for execution than for installation.
InstallationResources
instance did not find the
resources (for example because of files not found) or does not have the permission to distribute them.public abstract String getLicense(String authority, Locale locale, String mimeType) throws IOException
null
if none.
The terms of use can be returned in either plain text or HTML.
Authority | License |
---|---|
"EPSG" |
A copy of the http://www.epsg.org/TermsOfUse page. |
"Embedded" |
Above EPSG license. |
authority
- one of the values returned by getAuthorities()
.locale
- the preferred locale for the terms of use.mimeType
- either "text/plain"
or "text/html"
.null
if none.IllegalArgumentException
- if the given authority
argument is not one of the expected values.IOException
- if an error occurred while reading the license file.public abstract String[] getResourceNames(String authority) throws IOException
"EPSG"
authority:
the resource names are the filenames of all SQL scripts to execute. One of the first script creates tables,
followed by a script that populates tables with data, followed by a script that creates foreigner keys.
"Embedded"
pseudo-authority:
the database name, which is "SpatialMetadata"
.
When embedded, this database is read-only.
authority
- one of the values returned by getAuthorities()
.IllegalArgumentException
- if the given authority
argument is not one of the expected values.IOException
- if fetching the resource names required an I/O operation and that operation failed.public Object getResource(String authority, int index) throws IOException
null
if not available.
The return value may be an instance of any type, at implementation choice.
This may be for example a URL
referencing the actual resource.
The default implementation returns null
. A null value means that the resource is fetched by
openScript(String, int)
instead than this method. We do not return URL
to text
files in order to ensure that the file is opened with proper character encoding.
authority
- one of the values returned by getAuthorities()
.index
- index of the resource to get, from 0 inclusive to
getResourceNames(authority).length
exclusive.null
if not available.IllegalArgumentException
- if the given authority
argument is not one of the expected values.IndexOutOfBoundsException
- if the given resource
argument is out of bounds.IOException
- if an error occurred while fetching the resource.ClassLoader.getResource(String)
public abstract BufferedReader openScript(String authority, int resource) throws IOException
BufferedReader
instance shall be closed by the caller.authority
- one of the values returned by getAuthorities()
.resource
- index of the script to open, from 0 inclusive to
getResourceNames(authority).length
exclusive.IllegalArgumentException
- if the given authority
argument is not one of the expected values.IndexOutOfBoundsException
- if the given resource
argument is out of bounds.IOException
- if an error occurred while creating the reader.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.