Package org.scijava.download
Class DiskLocationCache
- java.lang.Object
-
- org.scijava.download.DiskLocationCache
-
- All Implemented Interfaces:
LocationCache
public class DiskLocationCache extends Object implements LocationCache
A file-based implementation ofLocationCache.- Author:
- Curtis Rueden
-
-
Constructor Summary
Constructors Constructor Description DiskLocationCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocationcachedLocation(Location source)Gets the cache location of a given data source.booleancanCache(Location source)Gets whether the given location can be cached by this cache.FilegetBaseDirectory()booleanisFileLocationCachingEnabled()StringloadChecksum(Location source)Loads the checksum value which corresponds to the cached location.voidsaveChecksum(Location source, String checksum)Associates the given checksum value with the specified source location.voidsetBaseDirectory(File baseDir)voidsetFileLocationCachingEnabled(boolean enabled)
-
-
-
Method Detail
-
getBaseDirectory
public File getBaseDirectory()
-
setBaseDirectory
public void setBaseDirectory(File baseDir)
-
isFileLocationCachingEnabled
public boolean isFileLocationCachingEnabled()
-
setFileLocationCachingEnabled
public void setFileLocationCachingEnabled(boolean enabled)
-
canCache
public boolean canCache(Location source)
Description copied from interface:LocationCacheGets whether the given location can be cached by this cache.- Specified by:
canCachein interfaceLocationCache
-
cachedLocation
public Location cachedLocation(Location source)
Description copied from interface:LocationCacheGets the cache location of a given data source.- Specified by:
cachedLocationin interfaceLocationCache- Returns:
- A
Locationwhere the source data is, or would be, cached.
-
loadChecksum
public String loadChecksum(Location source) throws IOException
Description copied from interface:LocationCacheLoads the checksum value which corresponds to the cached location.- Specified by:
loadChecksumin interfaceLocationCache- Parameters:
source- The source location for which the cached checksum is desired.- Returns:
- The loaded checksum, or null if one is not available.
- Throws:
IOException- If something goes wrong accessing the checksum.- See Also:
DataHandle.checksum()
-
saveChecksum
public void saveChecksum(Location source, String checksum) throws IOException
Description copied from interface:LocationCacheAssociates the given checksum value with the specified source location.- Specified by:
saveChecksumin interfaceLocationCache- Parameters:
source- The source location for which the checksum should be cached.checksum- The checksum value to cache.- Throws:
IOException- If something goes wrong caching the checksum.- See Also:
DataHandle.checksum()
-
-