Class Databases

java.lang.Object
org.basex.core.Databases

public final class Databases extends Object
Provides central access to all databases and backups.
Author:
BaseX Team 2005-21, BSD License, Jens Erat
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Allowed characters for database names (additional to letters and digits).
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the names of all backups.
    Returns the name of a specific backup, or all backups found for a specific database, in a descending order.
    static String
    date(String backup)
    Extracts the date of a database from the name of a backup.
    Lists all available databases and backups.
    static String
    name(String backup)
    Extracts the name of a database from the name of a backup.
    static Pattern
    regex(String pattern)
    Returns a regular expression for the specified name pattern.
    static boolean
    validChar(int ch, boolean firstLast)
    Checks if the specified character is a valid character for a database name.
    static boolean
    Checks if the specified string is a valid database name.
    static boolean
    Checks if the specified string is a valid database pattern.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DBCHARS

      public static final String DBCHARS
      Allowed characters for database names (additional to letters and digits). The following characters are invalid:
      • ,?*" are used by the glob syntax
      • ; is reserved for separating commands.
      • :*?\"<>\/|" are used for filenames and paths
      See Also:
  • Method Details

    • list

      public StringList list()
      Lists all available databases and backups.
      Returns:
      database and backup list
    • regex

      public static Pattern regex(String pattern)
      Returns a regular expression for the specified name pattern.
      Parameters:
      pattern - pattern
      Returns:
      regular expression
    • backups

      public StringList backups()
      Returns the names of all backups.
      Returns:
      backups
    • backups

      public StringList backups(String db)
      Returns the name of a specific backup, or all backups found for a specific database, in a descending order.
      Parameters:
      db - database
      Returns:
      names of specified backups
    • name

      public static String name(String backup)
      Extracts the name of a database from the name of a backup.
      Parameters:
      backup - Name of the backup file. Valid formats: [dbname]-yyyy-mm-dd-hh-mm-ss, [dbname]
      Returns:
      name of the database ([dbname])
    • date

      public static String date(String backup)
      Extracts the date of a database from the name of a backup.
      Parameters:
      backup - name of the backup file, including the date
      Returns:
      date string
    • validChar

      public static boolean validChar(int ch, boolean firstLast)
      Checks if the specified character is a valid character for a database name.
      Parameters:
      ch - the character to be checked
      firstLast - character is first or last
      Returns:
      result of check
    • validName

      public static boolean validName(String name)
      Checks if the specified string is a valid database name.
      Parameters:
      name - name to be checked (can be null)
      Returns:
      result of check
    • validPattern

      public static boolean validPattern(String pattern)
      Checks if the specified string is a valid database pattern.
      Parameters:
      pattern - pattern to be checked (can be null)
      Returns:
      result of check