Package org.jxmapviewer.cache
Class FileBasedLocalCache
java.lang.Object
org.jxmapviewer.cache.FileBasedLocalCache
- All Implemented Interfaces:
LocalCache
public class FileBasedLocalCache extends java.lang.Object implements LocalCache
A file/folder-based cache
-
Constructor Summary
Constructors Constructor Description FileBasedLocalCache(java.io.File cacheDir, boolean checkForUpdates) -
Method Summary
Modifier and Type Method Description java.io.InputStreamget(java.net.URL url)java.io.FilegetLocalFile(java.net.URL remoteUri)Returns the local File corresponding to the given remote URI.voidput(java.net.URL url, java.io.InputStream data)
-
Constructor Details
-
FileBasedLocalCache
public FileBasedLocalCache(java.io.File cacheDir, boolean checkForUpdates)- Parameters:
cacheDir- the root cache foldercheckForUpdates- true, if the remote URL should be checked for updates first
-
-
Method Details
-
get
public java.io.InputStream get(java.net.URL url)- Specified by:
getin interfaceLocalCache- Parameters:
url- the URL request to cache- Returns:
- a (local) stream to use instead or
null.
-
put
public void put(java.net.URL url, java.io.InputStream data) throws java.io.IOException- Specified by:
putin interfaceLocalCache- Parameters:
url- the URL request that should be cacheddata- the input stream that provides the data- Throws:
java.io.IOException- if the data cannot be written
-
getLocalFile
public java.io.File getLocalFile(java.net.URL remoteUri)Returns the local File corresponding to the given remote URI.- Parameters:
remoteUri- the remote URI- Returns:
- the corresponding local file
-