Package org.apache.sis.internal.util
Class MetadataServices
java.lang.Object
org.apache.sis.internal.system.SystemListener
org.apache.sis.internal.system.OptionalDependency
org.apache.sis.internal.util.MetadataServices
- All Implemented Interfaces:
EventListener
- Direct Known Subclasses:
ServicesForUtility
Provides access to services defined in the
"sis-metadata"
module.
This class searches for the ServicesForUtility
implementation using Java reflection.- Since:
- 0.6
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A pseudo-authority name used byInstallationResources
for identifying the embedded data resources.private static MetadataServices
The services, fetched when first needed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Invoked when the classpath changed.createCoordinateFormat
(Locale locale, TimeZone timezone) Creates a format forDirectPosition
instances.getCodeTitle
(org.opengis.util.CodeList<?> code, Locale locale) Returns the title of the given enumeration or code list value.Returns the data source for the SIS-wide "SpatialMetadata" database.getInformation
(String key, Locale locale) Returns information about the Apache SIS configuration to be reported inAbout
.static MetadataServices
Returns the singleton instance.getUnicodeIdentifier
(org.opengis.metadata.citation.Citation citation) Infers an identifier from the given citation, or returnsnull
if no identifier has been found.boolean
true
if this thread is in the process of reading a XML document with JAXB.void
Specifies the data source to use if there is no JNDI environment or if no data source is binded tojdbc/SpatialMetadata
.Methods inherited from class org.apache.sis.internal.system.OptionalDependency
getInstance, moduleNotFound
Methods inherited from class org.apache.sis.internal.system.SystemListener
add, databaseChanged, fireClasspathChanged, remove
-
Field Details
-
EMBEDDED
A pseudo-authority name used byInstallationResources
for identifying the embedded data resources. The actual data are provided by the metadata module.- See Also:
-
instance
The services, fetched when first needed.
-
-
Constructor Details
-
MetadataServices
protected MetadataServices()For subclass only. This constructor registers this instance as aSystemListener
in order to force a newMetadataServices
lookup if the classpath changes.
-
-
Method Details
-
classpathChanged
protected final void classpathChanged()Invoked when the classpath changed. Resets theinstance
tonull
in order to force the next call togetInstance()
to fetch a new one, which may be different.- Overrides:
classpathChanged
in classOptionalDependency
-
getInstance
Returns the singleton instance.- Returns:
- the singleton instance.
-
isUnmarshalling
public boolean isUnmarshalling()true
if this thread is in the process of reading a XML document with JAXB.- Returns:
- if XML unmarshalling is in progress in current thread.
-
getCodeTitle
Returns the title of the given enumeration or code list value.- Parameters:
code
- the code for which to get the title.locale
- desired locale for the title.- Returns:
- the title.
- See Also:
-
getUnicodeIdentifier
Infers an identifier from the given citation, or returnsnull
if no identifier has been found. This method returns a non-null value only if the identifier is a valid Unicode identifier.- Parameters:
citation
- the citation for which to get the identifier, ornull
.- Returns:
- a non-empty identifier without leading or trailing whitespaces, or
null
.
-
getInformation
Returns information about the Apache SIS configuration to be reported inAbout
. This method is invoked only for aspects that depends on other modules thansis-utility
.Current keys are:
"EPSG"
: version of EPSG database."DataSource"
: URL to the data source, or error message.
- Parameters:
key
- a key identifying the information to return.locale
- language to use if possible.- Returns:
- the information, or
null
if none. - See Also:
-
createCoordinateFormat
Creates a format forDirectPosition
instances.- Parameters:
locale
- the locale for the newFormat
, ornull
forLocale.ROOT
.timezone
- the timezone, ornull
for UTC.- Returns:
- a
CoordinateFormat
.
-
getDataSource
Returns the data source for the SIS-wide "SpatialMetadata" database.- Returns:
- the data source for the
$SIS_DATA/Databases/SpatialMetadata
or equivalent database, ornull
if none. - Throws:
SQLException
- if an error occurred while fetching the database source.
-
setDataSource
Specifies the data source to use if there is no JNDI environment or if no data source is binded tojdbc/SpatialMetadata
.- Parameters:
ds
- supplier of data source to set, ornull
for removing previous supplier. This supplier may returnnull
, in which case it will be ignored.- Throws:
IllegalStateException
- ifDataSource
has already be obtained before this method call.
-