Class CacheResourcesManager

java.lang.Object
org.eclipse.lemminx.uriresolver.CacheResourcesManager

public class CacheResourcesManager extends Object
Cache resources manager.
  • Constructor Details

  • Method Details

    • getResource

      public Path getResource(String resourceURI) throws IOException
      Throws:
      IOException
    • getResourceCachePath

      public static Path getResourceCachePath(String resourceURI) throws IOException
      Throws:
      IOException
    • getResourceCachePath

      public static Path getResourceCachePath(URI uri) throws IOException
      Throws:
      IOException
    • getResourceCachePath

      public static Path getResourceCachePath(CacheResourcesManager.ResourceToDeploy resource) throws IOException
      Try to get the cached CacheResourcesManager.ResourceToDeploy.resourceCachePath in cache file system and if it is not found, create the file with the given content of CacheResourcesManager.ResourceToDeploy.resourceFromClasspath stored in classpath.
      Parameters:
      resource - the resource to deploy if needed.
      Returns:
      the cached CacheResourcesManager.ResourceToDeploy.resourceCachePath in cache file system.
      Throws:
      IOException
    • canUseCache

      public boolean canUseCache(String url)
      Returns true if cache is enabled and url comes from "http(s)" or "ftp" and false otherwise.
      Parameters:
      url -
      Returns:
      true if cache is enabled and url comes from "http(s)" or "ftp" and false otherwise.
    • setUseCache

      public void setUseCache(boolean useCache)
      Set true if cache must be used, false otherwise.
      Parameters:
      useCache - true if cache must be used, false otherwise.
    • isUseCache

      public boolean isUseCache()
      Returns true if cache must be used, false otherwise.
      Returns:
      true if cache must be used, false otherwise.
    • isDownloadExternalResources

      public boolean isDownloadExternalResources()
      Returns true if the external resources can be downloaded and false otherwise.
      Returns:
      true if the external resources can be downloaded and false otherwise.
    • setDownloadExternalResources

      public void setDownloadExternalResources(boolean downloadExternalResources)
      Set true if the external resources can be downloaded and false otherwise.
      Parameters:
      downloadExternalResources - the external resources
    • evictCache

      public void evictCache() throws IOException
      Remove the cache directory (.lemminx/cache) if it exists.
      Throws:
      IOException - if the delete of directory (.lemminx/cache) cannot be done.
    • addProtocolForCache

      public void addProtocolForCache(String protocol)
      Add protocol for using cache when url will start with the given protocol.
      Parameters:
      protocol - the protocol to add.
    • removeProtocolForCache

      public void removeProtocolForCache(String protocol)
      Remove protocol to avoid using cache when url will start with the given protocol.
      Parameters:
      protocol - the protocol to remove.
    • forceDownloadExternalResource

      public void forceDownloadExternalResource(String url)
      Force the given url to download.
      Parameters:
      url - the url to download.