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
`static class` `CacheResourcesManager.ResourceToDeploy` Classpath resource to deploy into the lemminx cache

### Constructor Summary

Constructors
`CacheResourcesManager()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addProtocolForCache​(String protocol)` Add protocol for using cache when url will start with the given protocol.
`boolean` `canUseCache​(String url)` Returns `true` if cache is enabled and url comes from "http(s)" or "ftp" and `false` otherwise.
`void` `evictCache()` Remove the cache directory (.lemminx/cache) if it exists.
`void` `forceDownloadExternalResource​(String url)` Force the given `url` to download.
`Path` `getResource​(String resourceURI)`
`static Path` `getResourceCachePath​(String resourceURI)`
`static Path` `getResourceCachePath​(URI uri)`
`static Path` `getResourceCachePath​(CacheResourcesManager.ResourceToDeploy resource)` 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.
`boolean` `isDownloadExternalResources()` Returns true if the external resources can be downloaded and false otherwise.
`boolean` `isUseCache()` Returns `true` if cache must be used, `false` otherwise.
`void` `removeProtocolForCache​(String protocol)` Remove protocol to avoid using cache when url will start with the given protocol.
`void` `setDownloadExternalResources​(boolean downloadExternalResources)` Set true if the external resources can be downloaded and false otherwise.
`void` `setUseCache​(boolean useCache)` Set `true` if cache must be used, `false` otherwise.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CacheResourcesManager

    public CacheResourcesManager()

### 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 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.