Class XMLCacheResolverExtension
- java.lang.Object
-
- org.eclipse.lemminx.extensions.contentmodel.uriresolver.XMLCacheResolverExtension
-
- All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLEntityResolver,URIResolverExtension
public class XMLCacheResolverExtension extends Object implements URIResolverExtension
URI resolver which, on the first access, downloads the XML Schema or DTD from "http(s)" or "ftp" URIs to the file system. On subsequent calls, the locally cached file is used instead of being remotely accessed. This cache drastically improves the resolution performance of some XML Schemas (ex: xml.xsd)
-
-
Field Summary
-
Fields inherited from interface org.eclipse.lemminx.uriresolver.URIResolverExtension
DEFAULT
-
-
Constructor Summary
Constructors Constructor Description XMLCacheResolverExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.PathgetCachedResource(String url)Returns the cached resource path from the given url and null otherwise.booleanisDownloadExternalResources()Returns true if the external resources can be downloaded and false otherwise.booleanisUseCache()Returnstrueif cache must be used,falseotherwise.Stringresolve(String baseLocation, String publicId, String systemId)org.apache.xerces.xni.parser.XMLInputSourceresolveEntity(org.apache.xerces.xni.XMLResourceIdentifier resourceIdentifier)voidsetDownloadExternalResources(boolean downloadExternalResources)Set true if the external resources can be downloaded and false otherwise.voidsetUseCache(boolean useCache)Settrueif cache must be used,falseotherwise.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.lemminx.uriresolver.URIResolverExtension
getName
-
-
-
-
Method Detail
-
resolve
public String resolve(String baseLocation, String publicId, String systemId)
- Specified by:
resolvein interfaceURIResolverExtension- Parameters:
baseLocation- - the location of the resource that contains the uripublicId- - an optional public identifier (i.e. namespace name), or null if nonesystemId- - an absolute or relative URI, or null if none- Returns:
- an absolute URI representation of the 'logical' location of the resource
-
resolveEntity
public org.apache.xerces.xni.parser.XMLInputSource resolveEntity(org.apache.xerces.xni.XMLResourceIdentifier resourceIdentifier) throws org.apache.xerces.xni.XNIException, IOException- Specified by:
resolveEntityin interfaceURIResolverExtension- Specified by:
resolveEntityin interfaceorg.apache.xerces.xni.parser.XMLEntityResolver- Throws:
org.apache.xerces.xni.XNIExceptionIOException
-
getCachedResource
public Path getCachedResource(String url) throws IOException, CacheResourceDownloadedException
Returns the cached resource path from the given url and null otherwise.- Parameters:
url- the url to download.- Returns:
- the cached resource path from the given url and null otherwise.
- Throws:
IOExceptionCacheResourceDownloadedException- throws when resource is downloading.
-
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.
-
forceDownloadExternalResource
public void forceDownloadExternalResource(String url)
Force the givenurlto download.- Parameters:
url- the url to download.
-
-