Package db

Class Database

  • Direct Known Subclasses:
    PackedDatabase, PrivateDatabase, VersionedDatabase

    public abstract class Database
    extends java.lang.Object
    Database facilitates the creation of a DBHandle for accessing a database.

    Public constructors are only provided for use with "Non-Versioned" databases. This class should be extended when additional management features are needed, such as for a "Versioned" database.

    This class assumes exclusive control of the associated files contained within the associated database directory and relies on the proper establishment of a syncObject to midigate potential concurrent modification issues.

    • Field Detail

      • DATABASE_FILE_PREFIX NEW

        protected static final java.lang.String DATABASE_FILE_PREFIX
        See Also:
        Constant Field Values
      • VERSION_FILE_PREFIX NEW

        protected static final java.lang.String VERSION_FILE_PREFIX
        See Also:
        Constant Field Values
      • CHANGE_FILE_PREFIX NEW

        protected static final java.lang.String CHANGE_FILE_PREFIX
        See Also:
        Constant Field Values
      • CUMULATIVE_CHANGE_FILENAME NEW

        protected static final java.lang.String CUMULATIVE_CHANGE_FILENAME
        See Also:
        Constant Field Values
      • CUMULATIVE_MODMAP_FILENAME NEW

        protected static final java.lang.String CUMULATIVE_MODMAP_FILENAME
        See Also:
        Constant Field Values
      • minVersion NEW

        protected int minVersion
      • currentVersion NEW

        protected int currentVersion
      • lastModified NEW

        protected long lastModified
      • isVersioned NEW

        protected boolean isVersioned
      • isCheckOutCopy NEW

        protected boolean isCheckOutCopy
      • updateAllowed NEW

        protected boolean updateAllowed
      • dbDir NEW

        protected java.io.File dbDir
      • dbDirCreated NEW

        protected boolean dbDirCreated
      • syncObject NEW

        protected java.lang.Object syncObject

Constructor Detail

  • Method Detail

    • setSynchronizationObject

      public void setSynchronizationObject​(java.lang.Object syncObject)
      Set the object to be used for synchronization.
      Parameters:
      syncObject -
    • lastModified

      public long lastModified()
      Returns the time at which this database was last saved.
    • deleteDir NEW

      protected static final boolean deleteDir​(java.io.File dir)
      Delete a directory and all of its contents.
      Parameters:
      dir -
      Returns:
      true if delete was successful. If false is returned, a partial delete may have occurred.
    • getCurrentVersion

      public int getCurrentVersion()
      Returns the version number associated with the latest buffer file version.
    • open

      public DBHandle open​(TaskMonitor monitor)
                    throws java.io.IOException,
                           CancelledException
      Open the stored database for non-update use. The returned handle does not support the Save operation.
      Parameters:
      monitor - task monitor (may be null)
      Returns:
      database handle
      Throws:
      FileInUseException - thrown if unable to obtain the required database lock(s).
      java.io.IOException - thrown if IO error occurs.
      CancelledException - if cancelled by monitor
    • openForUpdate

      public DBHandle openForUpdate​(TaskMonitor monitor)
                             throws java.io.IOException,
                                    CancelledException
      Open the stored database for update use.
      Parameters:
      monitor - task monitor (may be null)
      Returns:
      buffer file
      Throws:
      FileInUseException - thrown if unable to obtain the required database lock(s).
      java.io.IOException - thrown if IO error occurs.
      CancelledException - if cancelled by monitor
    • length

      public long length()
                  throws java.io.IOException
      Returns the length of this domain file. This size is the minimum disk space used for storing this file, but does not account for additional storage space used to tracks changes, etc.
      Returns:
      file length
      Throws:
      java.io.IOException - thrown if IO or access error occurs
    • refresh

      public void refresh()
                   throws java.io.FileNotFoundException
      Scan files and update state.
      Throws:
      java.io.FileNotFoundException
    • scanFiles NEW

      protected void scanFiles​(boolean repair)
                        throws java.io.FileNotFoundException
      Scan files and update state.
      Parameters:
      repair - if true files are repaired if needed.
      Throws:
      java.io.FileNotFoundException