Class XMLCacheResolverExtension
java.lang.Object
org.eclipse.lemminx.extensions.contentmodel.uriresolver.XMLCacheResolverExtension
- All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLEntityResolver,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 -
Method Summary
Modifier and TypeMethodDescriptionbooleancanUseCache(String url) Returnstrueif cache is enabled and url comes from "http(s)" or "ftp" andfalseotherwise.voidRemove the cache directory (.lemminx/cache) if it exists.voidForce the givenurlto download.getCachedResource(String url) Returns the cached resource path from the given url and null otherwise.booleanReturns true if the external resources can be downloaded and false otherwise.booleanReturnstrueif cache must be used,falseotherwise.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, waitMethods inherited from interface org.eclipse.lemminx.uriresolver.URIResolverExtension
getName
-
Constructor Details
-
XMLCacheResolverExtension
public XMLCacheResolverExtension()
-
-
Method Details
-
resolve
- 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
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
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
Remove the cache directory (.lemminx/cache) if it exists.- Throws:
IOException- if the delete of directory (.lemminx/cache) cannot be done.
-
forceDownloadExternalResource
Force the givenurlto download.- Parameters:
url- the url to download.
-