public abstract class AbstractRepository extends java.lang.Object implements Repository
AbstractRepository is the shared base for implementers of the Repository
interface.RepositoryGSON| Constructor and Description |
|---|
AbstractRepository() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
download(java.nio.file.Path tmp,
java.net.URI baseUri,
Artifact.Item item,
ai.djl.util.Progress progress) |
java.nio.file.Path |
getCacheDirectory()
Returns the cache directory for the repository.
|
java.nio.file.Path |
getFile(Artifact.Item item,
java.lang.String path)
Returns the path to a file for the item.
|
java.util.List<MRL> |
getResources()
Returns a list of
MRLs in the repository. |
java.lang.String[] |
listDirectory(Artifact.Item item,
java.lang.String path)
Returns the list of files directly within a specified directory in a zipped directory item.
|
protected static java.lang.String |
md5hash(java.lang.String input) |
java.io.InputStream |
openStream(Artifact.Item item,
java.lang.String path)
Returns an
InputStream for an item in a repository. |
void |
prepare(Artifact artifact,
ai.djl.util.Progress progress)
Prepares the artifact for use with progress tracking.
|
protected java.net.URI |
resolvePath(Artifact.Item item,
java.lang.String path) |
protected void |
save(java.io.InputStream is,
java.nio.file.Path tmp,
java.net.URI baseUri,
Artifact.Item item,
ai.djl.util.Progress progress) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBaseUri, getName, getResourceDirectory, isRemote, locate, newInstance, newInstance, prepare, registerRepositoryFactory, resolvepublic java.io.InputStream openStream(Artifact.Item item, java.lang.String path) throws java.io.IOException
InputStream for an item in a repository.openStream in interface Repositoryitem - the item to openpath - the path to a file if the item is a zipped directory. Otherwise, pass nulljava.io.IOException - if it failed to open the streampublic java.lang.String[] listDirectory(Artifact.Item item, java.lang.String path) throws java.io.IOException
listDirectory in interface Repositoryitem - the zipped directory itempath - the path within the zip directoryjava.io.IOException - if it failed to list the directorypublic java.nio.file.Path getFile(Artifact.Item item, java.lang.String path) throws java.io.IOException
getFile in interface Repositoryitem - the item to find the path forpath - the path to a file if the item is a zipped directory. Otherwise, pass nulljava.io.IOException - if it failed to find the pathprotected java.net.URI resolvePath(Artifact.Item item, java.lang.String path) throws java.io.IOException
java.io.IOExceptionpublic void prepare(Artifact artifact, ai.djl.util.Progress progress) throws java.io.IOException
prepare in interface Repositoryartifact - the artifact to prepareprogress - the progress trackerjava.io.IOException - if it failed to preparepublic java.nio.file.Path getCacheDirectory()
throws java.io.IOException
getCacheDirectory in interface Repositoryjava.io.IOException - if it failed to ensure the creation of the cache directorypublic java.util.List<MRL> getResources()
MRLs in the repository.
An empty list will be returned if underlying Repository implementation does not
support this feature.
getResources in interface RepositoryMRLs in the repositoryprotected void download(java.nio.file.Path tmp,
java.net.URI baseUri,
Artifact.Item item,
ai.djl.util.Progress progress)
throws java.io.IOException
java.io.IOExceptionprotected void save(java.io.InputStream is,
java.nio.file.Path tmp,
java.net.URI baseUri,
Artifact.Item item,
ai.djl.util.Progress progress)
throws java.io.IOException
java.io.IOExceptionprotected static java.lang.String md5hash(java.lang.String input)