Enum DataDirectory

java.lang.Object
java.lang.Enum<DataDirectory>
org.apache.sis.internal.system.DataDirectory
All Implemented Interfaces:
Serializable, Comparable<DataDirectory>, java.lang.constant.Constable

public enum DataDirectory extends Enum<DataDirectory>
Sub-directories of SIS_DATA where SIS looks for EPSG database, datum shift grids and other resources.
Since:
0.7
Version:
1.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The "Databases" directory.
    The "DatumChanges" directory.
    The "DomainsOfValidity" directory.
    The "Schemas" directory.
    The "Tests" directory.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Path
    The directory, or null if none or not yet determined.
    static final String
    The name of the environment variable.
    private static short
    Key of the last message logged at Level.WARNING, or null if none.
    private static Path
    The root directory fetched from the SIS_DATA environment variable when first needed, or null if none or not yet determined.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the sub-directory identified by this enum, or null if the parent $SIS_DATA directory was not specified.
    static String
    Returns the value of "SIS_DATA" environment variable, or null if none.
    static Path
    Returns the root directory fetched from the SIS_DATA environment variable.
    static boolean
    Returns true if the "SIS_DATA" environment variable is undefined.
    private static void
    log(Level level, Exception e, short key, Object... parameters)
    Logs a message to the "org.apache.sis.system" logger.
    static void
    Prevents the log message about SIS_DATA environment variable not set.
    resolve(Path file)
    If the given path is relative, returns the path as a child of the directory represented by this enum.
    Returns the enum constant of this type with the specified name.
    static DataDirectory[]
    Returns an array containing the constants of this enum type, in the order they are declared.
    private static void
    warning(Exception e, short key, Object... parameters)
    Logs a message to the "org.apache.sis.system" logger only if different than the last warning.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • DATABASES

      public static final DataDirectory DATABASES
      The "Databases" directory. This directory is used for storing EPSG database and other metadata.
    • DATUM_CHANGES

      public static final DataDirectory DATUM_CHANGES
      The "DatumChanges" directory. This directory is used for storing datum shift grids.
    • DOMAINS_OF_VALIDITY

      public static final DataDirectory DOMAINS_OF_VALIDITY
      The "DomainsOfValidity" directory. This directory is used for storing shapefiles for the CRS domains of validity.
    • SCHEMAS

      public static final DataDirectory SCHEMAS
      The "Schemas" directory. This directory contains XML schemas published by ISO. If this directory is present, it should contain a "iso/19115/-3" sub-directory among others.
      See Also:
    • TESTS

      public static final DataDirectory TESTS
      The "Tests" directory. This directory is used for optional test files that are too large for inclusion in source code repository. This is used at build time of Apache SIS project, but not used during normal execution.
  • Field Details

    • ENV

      public static final String ENV
      The name of the environment variable.
      See Also:
    • lastWarning

      private static short lastWarning
      Key of the last message logged at Level.WARNING, or null if none.
      See Also:
    • rootDirectory

      private static Path rootDirectory
      The root directory fetched from the SIS_DATA environment variable when first needed, or null if none or not yet determined.
      See Also:
    • directory

      private Path directory
      The directory, or null if none or not yet determined.
      See Also:
  • Constructor Details

    • DataDirectory

      private DataDirectory()
  • Method Details

    • values

      public static DataDirectory[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static DataDirectory valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • quiet

      public static void quiet()
      Prevents the log message about SIS_DATA environment variable not set. This is used for the "About" command line action only.
    • warning

      private static void warning(Exception e, short key, Object... parameters)
      Logs a message to the "org.apache.sis.system" logger only if different than the last warning.
    • log

      private static void log(Level level, Exception e, short key, Object... parameters)
      Logs a message to the "org.apache.sis.system" logger.
    • getenv

      public static String getenv() throws SecurityException
      Returns the value of "SIS_DATA" environment variable, or null if none. This method does not perform any logging and does not verify if the directory exists. If the intent is to perform I/O operations, use getRootDirectory() instead.
      Returns:
      the "SIS_DATA" environment variable, or null if none.
      Throws:
      SecurityException - if this method is not allowed to query the environment variable.
      Since:
      0.8
      See Also:
    • isUndefined

      public static boolean isUndefined()
      Returns true if the "SIS_DATA" environment variable is undefined. In case of doubt, this method returns false. This method is used for avoiding or at least delaying the log messages emitted by getRootDirectory() when a fallback exists in absence of any user attempt to configure the system.
      Returns:
      true if the "SIS_DATA" environment variable is unset.
      Since:
      0.8
    • getRootDirectory

      public static Path getRootDirectory()
      Returns the root directory fetched from the SIS_DATA environment variable. If the environment variable is not set or the directory does not exist, then this method returns null.
      Returns:
      the root SIS data directory, or null if none.
    • getDirectory

      public Path getDirectory()
      Returns the sub-directory identified by this enum, or null if the parent $SIS_DATA directory was not specified. If the $SIS_DATA directory exists but not the sub-directory, then this method creates the sub-directory.
      Returns:
      the sub-directory, or null if unspecified.
    • resolve

      public Path resolve(Path file)
      If the given path is relative, returns the path as a child of the directory represented by this enum. If no valid directory is configured by the SIS_DATA environment variable, then the relative path is returned as-is.

      This method is invoked for files that may be user-specified, for example datum shift file specified in ParameterValue.

      Parameters:
      file - the path to resolve, or null.
      Returns:
      the path to use, or null if the given path was null.