Interface Repository

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      RepositoryConnection getConnection()
      Opens a connection to this repository that can be used for querying and updating the contents of the repository.
      File getDataDir()
      Get the directory where data and logging for this repository is stored.
      ValueFactory getValueFactory()
      Gets a ValueFactory for this Repository.
      void init()
      Initializes this repository.
      boolean isInitialized()
      Indicates if the Repository has been initialized.
      boolean isWritable()
      Checks whether this repository is writable, i.e.
      void setDataDir​(File dataDir)
      Set the directory where data and logging for this repository is stored.
      void shutDown()
      Shuts the repository down, releasing any resources that it keeps hold of.
    • Method Detail

      • setDataDir

        void setDataDir​(File dataDir)
        Set the directory where data and logging for this repository is stored.
        Parameters:
        dataDir - the directory where data for this repository is stored
      • getDataDir

        File getDataDir()
        Get the directory where data and logging for this repository is stored.
        Returns:
        the directory where data for this repository is stored.
      • init

        void init()
           throws RepositoryException
        Initializes this repository. A repository needs to be initialized before it can be used, however explicitly calling this method is not necessary: the repository will automatically initialize itself if an operation is executed on it that requires it to be initialized.
        Throws:
        RepositoryException - If the initialization failed.
        Since:
        2.5
      • isInitialized

        boolean isInitialized()
        Indicates if the Repository has been initialized. Note that the initialization status may change if the Repository is shut down.
        Returns:
        true iff the repository has been initialized.
      • shutDown

        void shutDown()
               throws RepositoryException
        Shuts the repository down, releasing any resources that it keeps hold of. Once shut down, the repository can no longer be used until it is re-initialized.
        Throws:
        RepositoryException
      • isWritable

        boolean isWritable()
                    throws RepositoryException
        Checks whether this repository is writable, i.e. if the data contained in this repository can be changed. The writability of the repository is determined by the writability of the Sail that this repository operates on.
        Throws:
        RepositoryException
      • getConnection

        RepositoryConnection getConnection()
                                    throws RepositoryException
        Opens a connection to this repository that can be used for querying and updating the contents of the repository. Created connections need to be closed to make sure that any resources they keep hold of are released. The best way to do this is to use a try-with-resources block, as follows:
         try (RepositoryConnection conn = repository.getConnection()) {
                // perform operations on the connection
         }
         

        Note that RepositoryConnection is not guaranteed to be thread-safe! The recommended pattern for repository access in a multi-threaded application is to share the Repository object between threads, but have each thread create and use its own RepositoryConnections.

        Returns:
        A connection that allows operations on this repository.
        Throws:
        RepositoryException - If something went wrong during the creation of the Connection.
      • getValueFactory

        ValueFactory getValueFactory()
        Gets a ValueFactory for this Repository.
        Returns:
        A repository-specific ValueFactory.