Package org.eclipse.lemminx.uriresolver
Class CacheResourcesManager
- java.lang.Object
-
- org.eclipse.lemminx.uriresolver.CacheResourcesManager
-
public class CacheResourcesManager extends Object
Cache resources manager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCacheResourcesManager.ResourceToDeployClasspath resource to deploy into the lemminx cache
-
Constructor Summary
Constructors Constructor Description CacheResourcesManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProtocolForCache(String protocol)Add protocol for using cache when url will start with the given protocol.booleancanUseCache(String url)Returnstrueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.voidevictCache()Remove the cache directory (.lemminx/cache) if it exists.voidforceDownloadExternalResource(String url)Force the givenurlto download.PathgetResource(String resourceURI)static PathgetResourceCachePath(String resourceURI)static PathgetResourceCachePath(URI uri)static PathgetResourceCachePath(CacheResourcesManager.ResourceToDeploy resource)Try to get the cachedCacheResourcesManager.ResourceToDeploy.resourceCachePathin cache file system and if it is not found, create the file with the given content ofCacheResourcesManager.ResourceToDeploy.resourceFromClasspathstored in classpath.booleanisDownloadExternalResources()Returns true if the external resources can be downloaded and false otherwise.booleanisUseCache()Returnstrueif cache must be used,falseotherwise.voidremoveProtocolForCache(String protocol)Remove protocol to avoid using cache when url will start with the given protocol.voidsetDownloadExternalResources(boolean downloadExternalResources)Set true if the external resources can be downloaded and false otherwise.voidsetUseCache(boolean useCache)Settrueif cache must be used,falseotherwise.
-
-
-
Method Detail
-
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 cachedCacheResourcesManager.ResourceToDeploy.resourceCachePathin cache file system and if it is not found, create the file with the given content ofCacheResourcesManager.ResourceToDeploy.resourceFromClasspathstored in classpath.- Parameters:
resource- the resource to deploy if needed.- Returns:
- the cached
CacheResourcesManager.ResourceToDeploy.resourceCachePathin cache file system. - Throws:
IOException
-
canUseCache
public boolean canUseCache(String url)
Returnstrueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.- Parameters:
url-- Returns:
trueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.
-
setUseCache
public void setUseCache(boolean useCache)
Settrueif cache must be used,falseotherwise.- Parameters:
useCache-trueif cache must be used,falseotherwise.
-
isUseCache
public boolean isUseCache()
Returnstrueif cache must be used,falseotherwise.- Returns:
trueif cache must be used,falseotherwise.
-
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 IOExceptionRemove 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 givenurlto download.- Parameters:
url- the url to download.
-
-