Class FileSystemRepository
java.lang.Object
i5.las2peer.classLoaders.libraries.FileSystemRepository
- All Implemented Interfaces:
Repository
public class FileSystemRepository extends java.lang.Object implements Repository
implements a repository which loads all libraries from a given directory or from severeal ones. The search for
library files (jars) may be recursive.
-
Constructor Summary
Constructors Constructor Description FileSystemRepository(java.lang.Iterable<java.lang.String> directories, boolean recursive)
create a repository for the given directoriesFileSystemRepository(java.lang.String directory)
create a repository for the given directory, non-recursiveFileSystemRepository(java.lang.String[] directories)
create a repository for the given directories, non-recursiveFileSystemRepository(java.lang.String[] directories, boolean recursive)
create a repository for the given directoriesFileSystemRepository(java.lang.String directory, boolean recursive)
create a repository for the given directory -
Method Summary
Modifier and Type Method Description LoadedLibrary
findLibrary(LibraryIdentifier lib)
get a library matching name and version of the given identifierLoadedLibrary
findLibrary(java.lang.String name)
get the newest library for the given namejava.lang.String[]
getAllLibraries()
get an array with found jar files within this repositoryjava.lang.String[]
getAvailableVersions(java.lang.String libraryName)
get an array with all versions found for the given library namejava.util.Collection<LibraryVersion>
getAvailableVersionSet(java.lang.String libraryName)
get a collection with all versions found for the given library namestatic long
getLastModified(java.io.File dir, boolean recursive)
helper method to get the last modification date of a directoryjava.util.Collection<java.lang.String>
getLibraryCollection()
get a collection with all found jar files within this repositoryjava.lang.String
toString()
-
Constructor Details
-
FileSystemRepository
public FileSystemRepository(java.lang.String directory)create a repository for the given directory, non-recursive- Parameters:
directory
- A directory path name to use as repository
-
FileSystemRepository
public FileSystemRepository(java.lang.String directory, boolean recursive)create a repository for the given directory- Parameters:
directory
- A directory path name to use as repositoryrecursive
- If true, recursion is used for sub-directories.
-
FileSystemRepository
public FileSystemRepository(java.lang.String[] directories)create a repository for the given directories, non-recursive- Parameters:
directories
- An array of directory path names to use as repository
-
FileSystemRepository
public FileSystemRepository(java.lang.String[] directories, boolean recursive)create a repository for the given directories- Parameters:
directories
- An array of directory path names to use as repositoryrecursive
- If true, recursion is used for sub-directories.
-
FileSystemRepository
public FileSystemRepository(java.lang.Iterable<java.lang.String> directories, boolean recursive)create a repository for the given directories- Parameters:
directories
- A bunch of directory path names to use as repositoryrecursive
- If true, recursion is used for sub-directories.
-
-
Method Details
-
findLibrary
get the newest library for the given name- Specified by:
findLibrary
in interfaceRepository
- Parameters:
name
- A library name to search for- Returns:
- Returns a LoadedLibrary for the requested library name
- Throws:
LibraryNotFoundException
- If the library could not be found in this repository
-
findLibrary
get a library matching name and version of the given identifier- Specified by:
findLibrary
in interfaceRepository
- Parameters:
lib
- A library identifier- Returns:
- Returns a LoadedLibrary for the requested library identifier
- Throws:
LibraryNotFoundException
- If the library could not be found in this repository
-
getAvailableVersions
public java.lang.String[] getAvailableVersions(java.lang.String libraryName)get an array with all versions found for the given library name- Parameters:
libraryName
- A canonical library name- Returns:
- array with all available versions of the given library
-
getAvailableVersionSet
get a collection with all versions found for the given library name- Parameters:
libraryName
- A canonical library name- Returns:
- a collections with all versions of the given library
-
getAllLibraries
public java.lang.String[] getAllLibraries()get an array with found jar files within this repository- Returns:
- an array with all libraries in this repository
-
getLibraryCollection
public java.util.Collection<java.lang.String> getLibraryCollection()get a collection with all found jar files within this repository- Returns:
- a collection with all libraries in this repository
-
getLastModified
public static long getLastModified(java.io.File dir, boolean recursive)helper method to get the last modification date of a directory- Parameters:
dir
- A directoryrecursive
- If true also files inside the directory are considered- Returns:
- Returns the last modified date in epoch format
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
- Returns:
- a simple string representation of this object
-