Class MetadataServices

All Implemented Interfaces:
EventListener
Direct Known Subclasses:
ServicesForUtility

public class MetadataServices extends OptionalDependency
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 Details

    • EMBEDDED

      public static final String EMBEDDED
      A pseudo-authority name used by InstallationResources for identifying the embedded data resources. The actual data are provided by the metadata module.
      See Also:
    • instance

      private static volatile MetadataServices instance
      The services, fetched when first needed.
  • Constructor Details

    • MetadataServices

      protected MetadataServices()
      For subclass only. This constructor registers this instance as a SystemListener in order to force a new MetadataServices lookup if the classpath changes.
  • Method Details

    • classpathChanged

      protected final void classpathChanged()
      Invoked when the classpath changed. Resets the instance to null in order to force the next call to getInstance() to fetch a new one, which may be different.
      Overrides:
      classpathChanged in class OptionalDependency
    • getInstance

      public static MetadataServices 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

      public String getCodeTitle(org.opengis.util.CodeList<?> code, Locale locale)
      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

      public String getUnicodeIdentifier(org.opengis.metadata.citation.Citation citation)
      Infers an identifier from the given citation, or returns null 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, or null.
      Returns:
      a non-empty identifier without leading or trailing whitespaces, or null.
    • getInformation

      public String getInformation(String key, Locale locale)
      Returns information about the Apache SIS configuration to be reported in About. This method is invoked only for aspects that depends on other modules than sis-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

      public Format createCoordinateFormat(Locale locale, TimeZone timezone)
      Creates a format for DirectPosition instances.
      Parameters:
      locale - the locale for the new Format, or null for Locale.ROOT.
      timezone - the timezone, or null for UTC.
      Returns:
      a CoordinateFormat.
    • getDataSource

      public DataSource getDataSource() throws SQLException
      Returns the data source for the SIS-wide "SpatialMetadata" database.
      Returns:
      the data source for the $SIS_DATA/Databases/SpatialMetadata or equivalent database, or null if none.
      Throws:
      SQLException - if an error occurred while fetching the database source.
    • setDataSource

      public void setDataSource(Supplier<DataSource> ds)
      Specifies the data source to use if there is no JNDI environment or if no data source is binded to jdbc/SpatialMetadata.
      Parameters:
      ds - supplier of data source to set, or null for removing previous supplier. This supplier may return null, in which case it will be ignored.
      Throws:
      IllegalStateException - if DataSource has already be obtained before this method call.