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.InputStream get​(java.net.URL url)  
    java.io.File getLocalFile​(java.net.URL remoteUri)
    Returns the local File corresponding to the given remote URI.
    void put​(java.net.URL url, java.io.InputStream data)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FileBasedLocalCache

      public FileBasedLocalCache​(java.io.File cacheDir, boolean checkForUpdates)
      Parameters:
      cacheDir - the root cache folder
      checkForUpdates - 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:
      get in interface LocalCache
      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:
      put in interface LocalCache
      Parameters:
      url - the URL request that should be cached
      data - 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