Class AbstractRepository

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.String> arguments  
      protected java.lang.String name  
      protected java.net.URI uri  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRepository​(java.lang.String name, java.net.URI uri)  
    • Field Detail

      • name

        protected java.lang.String name
      • uri

        protected java.net.URI uri
      • arguments

        protected java.util.Map<java.lang.String,​java.lang.String> arguments
    • Constructor Detail

      • AbstractRepository

        protected AbstractRepository​(java.lang.String name,
                                     java.net.URI uri)
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the repository name.
        Specified by:
        getName in interface Repository
        Returns:
        the repository name
      • getBaseUri

        public java.net.URI getBaseUri()
        Returns the URI to the base of the repository.
        Specified by:
        getBaseUri in interface Repository
        Returns:
        the URI
      • openStream

        public java.io.InputStream openStream​(Artifact.Item item,
                                              java.lang.String path)
                                       throws java.io.IOException
        Returns an InputStream for an item in a repository.
        Specified by:
        openStream in interface Repository
        Parameters:
        item - the item to open
        path - the path to a file if the item is a zipped directory. Otherwise, pass null
        Returns:
        the file stream
        Throws:
        java.io.IOException - if it failed to open the stream
      • listDirectory

        public java.lang.String[] listDirectory​(Artifact.Item item,
                                                java.lang.String path)
                                         throws java.io.IOException
        Returns the list of files directly within a specified directory in a zipped directory item.
        Specified by:
        listDirectory in interface Repository
        Parameters:
        item - the zipped directory item
        path - the path within the zip directory
        Returns:
        the list of files/directories
        Throws:
        java.io.IOException - if it failed to list the directory
      • getFile

        public java.nio.file.Path getFile​(Artifact.Item item,
                                          java.lang.String path)
                                   throws java.io.IOException
        Returns the path to a file for the item.
        Specified by:
        getFile in interface Repository
        Parameters:
        item - the item to find the path for
        path - the path to a file if the item is a zipped directory. Otherwise, pass null
        Returns:
        the file path
        Throws:
        java.io.IOException - if it failed to find the path
      • resolvePath

        protected java.net.URI resolvePath​(Artifact.Item item,
                                           java.lang.String path)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • prepare

        public void prepare​(Artifact artifact,
                            ai.djl.util.Progress progress)
                     throws java.io.IOException
        Prepares the artifact for use with progress tracking.
        Specified by:
        prepare in interface Repository
        Parameters:
        artifact - the artifact to prepare
        progress - the progress tracker
        Throws:
        java.io.IOException - if it failed to prepare
      • getCacheDirectory

        public java.nio.file.Path getCacheDirectory()
                                             throws java.io.IOException
        Returns the cache directory for the repository.
        Specified by:
        getCacheDirectory in interface Repository
        Returns:
        the cache directory path
        Throws:
        java.io.IOException - if it failed to ensure the creation of the cache directory
      • addResource

        public void addResource​(MRL mrl)
        Adds resource to the repository.
        Specified by:
        addResource in interface Repository
        Parameters:
        mrl - the resource to add
      • download

        protected void download​(java.nio.file.Path tmp,
                                java.net.URI baseUri,
                                Artifact.Item item,
                                ai.djl.util.Progress progress)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • save

        protected void save​(java.io.InputStream is,
                            java.nio.file.Path tmp,
                            Artifact.Item item,
                            ai.djl.util.Progress progress)
                     throws java.io.IOException
        Throws:
        java.io.IOException