Class PrivateDatabase


  • public class PrivateDatabase
    extends Database
    PrivateDatabase corresponds to a non-versioned database.
    • Constructor Detail

      • PrivateDatabase

        public PrivateDatabase​(java.io.File dbDir)
                        throws java.io.IOException
        Constructor for an existing "Non-Versioned" Database.
        Parameters:
        dbDir - database directory
        Throws:
        java.io.IOException
      • PrivateDatabase

        public PrivateDatabase​(java.io.File dbDir,
                               BufferFile srcFile,
                               boolean resetDatabaseId,
                               TaskMonitor monitor)
                        throws java.io.IOException,
                               CancelledException
        Construct a new Database from an existing srcFile.
        Parameters:
        dbDir -
        srcFile -
        resetDatabaseId - if true database ID will be reset for new Database
        monitor -
        Throws:
        java.io.IOException
        CancelledException
      • PrivateDatabase

        public PrivateDatabase​(java.io.File dbDir,
                               java.io.File packedFile,
                               TaskMonitor monitor)
                        throws java.io.IOException,
                               CancelledException
        Constructs a new Database from an existing packed database file.
        Parameters:
        dbDir - private database directory
        packedFile - packed database storage file
        monitor -
        Throws:
        java.io.IOException
        CancelledException
    • Method Detail

      • createDatabase

        public static LocalManagedBufferFile createDatabase​(java.io.File dbDir,
                                                            DBFileListener dbFileListener,
                                                            int bufferSize)
                                                     throws java.io.IOException
        Create a new database and provide the initial buffer file for writing.
        Parameters:
        dbDir -
        bufferSize -
        Returns:
        initial buffer file
        Throws:
        java.io.IOException
      • setIsCheckoutCopy

        public void setIsCheckoutCopy​(boolean state)
        If this is a checked-out copy and a cumulative change file should be maintained, this method must be invoked following construction.
      • openBufferFile

        public LocalManagedBufferFile openBufferFile()
                                              throws java.io.IOException
        Open the current version of this database for non-update use.
        Returns:
        buffer file for non-update use
        Throws:
        java.io.IOException
      • openBufferFileForUpdate

        public LocalManagedBufferFile openBufferFileForUpdate()
                                                       throws java.io.IOException
        Open the current version of this database for update use.
        Returns:
        updateable buffer file
        Throws:
        java.io.IOException - if updating this database file is not allowed
      • canRecover

        public boolean canRecover()
        Returns true if recovery data exists which may enable recovery of unsaved changes resulting from a previous crash.
      • dbMoved

        public void dbMoved​(java.io.File dir)
                     throws java.io.FileNotFoundException
        Following a move of the database directory, this method should be invoked if this instance will continue to be used.
        Parameters:
        dir - new database directory
        Throws:
        java.io.FileNotFoundException - if the database directory cannot be found
      • updateCheckoutCopy

        public void updateCheckoutCopy​(ManagedBufferFile srcFile,
                                       int oldVersion,
                                       TaskMonitor monitor)
                                throws CancelledException,
                                       java.io.IOException
        If this is a checked-out copy, replace the buffer file content with that provided by the specified srcFile. This Database must be a checkout copy. If a cumulative change files exists, it will be deleted following the update.
        Parameters:
        srcFile - open source data buffer file or null if current version is already up-to-date.
        oldVersion - older version of srcFile from which this database originated.
        Throws:
        java.io.IOException
        CancelledException
      • updateCheckoutCopy

        public void updateCheckoutCopy()
                                throws java.io.IOException
        If a cumulative change files exists, it will be deleted.
        Throws:
        java.io.IOException
      • updateCheckoutFrom

        public void updateCheckoutFrom​(PrivateDatabase otherDb)
                                throws java.io.IOException
        Move the content of the otherDb into this database. The otherDb will no longer exist if this method is successful. If already open for update, a save should not be done or the database may become corrupted. All existing handles should be closed and reopened when this method is complete.
        Parameters:
        otherDb - the other database.
        Throws:
        java.io.IOException - if an IO error occurs. An attempt will be made to restore this database to its original state, however the otherDb will not be repaired and may become unusable.
      • output

        public void output​(java.io.File outputFile,
                           java.lang.String name,
                           int filetype,
                           java.lang.String contentType,
                           TaskMonitor monitor)
                    throws java.io.IOException,
                           CancelledException
        Output the current version of this database to a packed storage file.
        Parameters:
        outputFile - packed storage file to be written
        name - database name
        filetype - application file type
        contentType - user content type
        monitor -
        Throws:
        java.io.IOException
        CancelledException