Class 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)
    • Constructor Detail

      • XMLCacheResolverExtension

        public XMLCacheResolverExtension()
    • Method Detail

      • resolve

        public String resolve​(String baseLocation,
                              String publicId,
                              String systemId)
        Specified by:
        resolve in interface URIResolverExtension
        Parameters:
        baseLocation - - the location of the resource that contains the uri
        publicId - - an optional public identifier (i.e. namespace name), or null if none
        systemId - - 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:
        resolveEntity in interface URIResolverExtension
        Specified by:
        resolveEntity in interface org.apache.xerces.xni.parser.XMLEntityResolver
        Throws:
        org.apache.xerces.xni.XNIException
        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.
      • forceDownloadExternalResource

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