Interface Repository

  • All Known Implementing Classes:
    DBRepository, FileRepository

    public interface Repository
    This interface defines a repository for serializable objects and bytes array. Note: Be careful the constructor must be public to allow newInstance from another package.
    See Also:
    NTransaction
    • Method Detail

      • init

        void init​(Transaction transaction,
                  File dir)
           throws IOException
        Initializes the repository.
        Parameters:
        transaction - the transaction object.
        dir - the directory.
        Throws:
        IOException - an error occurs.
      • list

        String[] list​(String prefix)
               throws IOException
        Gets a list of persistent objects that name corresponds to prefix.
        Parameters:
        prefix - the prefix.
        Returns:
        The list of corresponding names.
        Throws:
        IOException - an error occurs.
      • save

        void save​(String dirName,
                  String name,
                  byte[] content)
           throws IOException
        Save the corresponding bytes array.
        Parameters:
        dirName - the directory.
        name - the object name.
        content - the serialized object view.
        Throws:
        IOException - an error occurs.
      • load

        byte[] load​(String dirName,
                    String name)
             throws IOException
        Loads the byte array.
        Parameters:
        dirName - the directory.
        name - the object name.
        Returns:
        the serialized object view.
        Throws:
        IOException - an error occurs.
      • delete

        void delete​(String dirName,
                    String name)
             throws IOException
        Deletes the corresponding objects in repository.
        Parameters:
        dirName - the directory.
        name - the object name.
        Throws:
        IOException - an error occurs.
      • commit

        void commit()
             throws IOException
        Commits all changes to the repository.
        Throws:
        IOException - an error occurs.
      • backup

        void backup​(BackupFile backup)
             throws IOException
        Backups the repository (may be unimplemented).
        Parameters:
        backup - The backup file.
        Throws:
        IOException
      • getNbSavedObjects

        int getNbSavedObjects()
        Returns the number of save operation to repository.
        Returns:
        The number of save operation to repository.
      • getNbDeletedObjects

        int getNbDeletedObjects()
        Returns the number of delete operation on repository.
        Returns:
        The number of delete operation on repository.
      • getNbBadDeletedObjects

        int getNbBadDeletedObjects()
        Returns the number of useless delete operation on repository.
        Returns:
        The number of useless delete operation on repository.
      • getNbLoadedObjects

        int getNbLoadedObjects()
        Returns the number of load operation from repository.
        Returns:
        The number of load operation from repository.