Class DBConfiguration

java.lang.Object
xal.tools.database.DBConfiguration

public class DBConfiguration extends Object
load a database configuration
  • Field Details

    • PREFERENCES_URL_KEY

      protected static final String PREFERENCES_URL_KEY
      key for getting the URL from the preferences
      See Also:
  • Method Details

    • getDefaultServerName

      public String getDefaultServerName()
      get the default server name
    • getDefaultAccountName

      public String getDefaultAccountName()
      get the default account name
    • hasAccount

      public boolean hasAccount(String accountName)
      determine whether this configuration has the named account
    • hasServer

      public boolean hasServer(String serverName)
      determine whether this configuration has the named server
    • getAccountNames

      public List<String> getAccountNames()
      get an alpha-numerically ordered list of account names
    • getServerNames

      public List<String> getServerNames()
      get an alpha-numerically ordered list of server names
    • newConnectionDictionary

      public ConnectionDictionary newConnectionDictionary(String accountName, String serverName)
      Generate a new connection dictionary for the specified account name and server configuration name
      Parameters:
      accountName - name of the account for which to initialize the connection dictionary (or null to use the default account if any)
      serverName - name of the database server for which to initialize the connection dictionary (or null to use the default server if any)
      Returns:
      a new connection dictionary from the database configuration
    • newConnectionDictionary

      public ConnectionDictionary newConnectionDictionary(String accountName)
      generate a new connection dictionary for the specified account name and the default database server
    • availableConnectionDictionary

      public ConnectionDictionary availableConnectionDictionary(boolean useDefaultIfNeeded, String... accounts)
      Get the available connection dictionary which is the most preferred
      Parameters:
      useDefaultIfNeeded - use the default account if none of the listed accounts is available
      accounts - ordered (most preferred is first) accounts to search among
    • availableConnectionDictionary

      public ConnectionDictionary availableConnectionDictionary(String... accounts)
      Get the available connection dictionary which is the most preferred and use the default one if there are no matches
      Parameters:
      accounts - ordered (most preferred is first) accounts to search among
    • defaultConnectionDictionary

      public ConnectionDictionary defaultConnectionDictionary()
      generate a new connection dictionary from the default database server configuration and default account
    • getInstance

      public static DBConfiguration getInstance()
      load the configuration from the default configuration URL
    • getInstance

      public static DBConfiguration getInstance(URL configURL)
      load a configuration from the specified URL
    • getInstance

      public static DBConfiguration getInstance(DataAdaptor documentAdaptor, URL baseURL)
      load a configuration from the specified configuration document adaptor
    • hasDefaultConfiguration

      public static boolean hasDefaultConfiguration()
      determine whether a default configuration has been specified
    • getDefaults

      protected static Preferences getDefaults()
      Get the user preferences for this class
      Returns:
      the user preferences for this class
    • getDefaultURLSpec

      public static String getDefaultURLSpec()
      Get the URL Spec of the default connection dictionary's properties file
      Returns:
      the URL Spec of the configuration
    • setDefaultURLSpec

      public static void setDefaultURLSpec(String urlSpec) throws BackingStoreException
      Set the URL spec of the default configuration.
      Parameters:
      urlSpec - URL spec of the configuration
      Throws:
      BackingStoreException - if the url spec failed to be saved as a default
    • getDefaultURL

      public static URL getDefaultURL() throws MalformedURLException
      Get the URL of the default configuration
      Returns:
      the URL of the default configuration
      Throws:
      MalformedURLException - if the default URL spec cannot form a valid URL
    • setDefaultURL

      public static void setDefaultURL(URL url) throws BackingStoreException
      Set the URL of the default configuration.
      Parameters:
      url - URL of the configuration.
      Throws:
      BackingStoreException - if the url failed to be saved as a default
    • getDefaultDatabaseAdaptor

      public DatabaseAdaptor getDefaultDatabaseAdaptor()
      Get the default database adaptor
      Returns:
      the database adaptor
    • getSchemaURL

      public URL getSchemaURL(String name)
      Returns url location of a file with database schema description
      Parameters:
      name - schema
      Returns:
      url pointing to a file