Class FileRepository

    • Field Detail

      • nbsaved

        private int nbsaved
        The number of save operation to repository.
      • nbdeleted

        private int nbdeleted
        The number of delete operation on repository.
      • baddeleted

        private int baddeleted
        The number of useless delete operation on repository.
      • nbloaded

        private int nbloaded
        The number of load operation from repository.
      • useFileOutputStream

        private boolean useFileOutputStream
        Boolean value to force the use of FileOutputStream rather than RandomAccessFile. By default this value is false, it can be set to true using the FileRepository.useRandomAccessFile java property.

        This property can be fixed only from java launching command, or through System.property method.

      • syncOnWrite

        private boolean syncOnWrite
    • Constructor Detail

      • FileRepository

        public FileRepository()
    • Method Detail

      • getNbSavedObjects

        public int getNbSavedObjects()
        Returns the number of save operation to repository.
        Specified by:
        getNbSavedObjects in interface Repository
        Returns:
        The number of save operation to repository.
      • getNbDeletedObjects

        public int getNbDeletedObjects()
        Returns the number of delete operation on repository.
        Specified by:
        getNbDeletedObjects in interface Repository
        Returns:
        The number of delete operation on repository.
      • getNbBadDeletedObjects

        public int getNbBadDeletedObjects()
        Returns the number of useless delete operation on repository.
        Specified by:
        getNbBadDeletedObjects in interface Repository
        Returns:
        The number of useless delete operation on repository.
      • getNbLoadedObjects

        public int getNbLoadedObjects()
        Returns the number of load operation from repository.
        Specified by:
        getNbLoadedObjects in interface Repository
        Returns:
        The number of load operation from repository.
      • init

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

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

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

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

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

        private final void deleteDir​(File dir)
        Delete the specified directory if it is empty. Also recursively delete the parent directories if they are empty.
        Parameters:
        dir - the directory to delete.