Class CacheUtil


  • public class CacheUtil
    extends java.lang.Object
    Provides static methods to interact with the cache, download indicator, and other utility methods.
    Version:
    $Revision: 1.17 $
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.File downloadAndGetCacheFile​(java.net.URL location, VersionString version)
      Caches a resource and returns a URL for it in the cache; blocks until resource is cached.
      private static DownloadServiceListener getDownloadServiceListener​(JNLPClassLoader jnlpClassLoader, java.lang.String title, java.net.URL[] undownloaded, DownloadIndicator indicator)  
      private static java.lang.String getProgressClass​(JNLPClassLoader jnlpClassLoader)  
      static java.lang.String hex​(java.lang.String origName, java.lang.String candidate)  
      static boolean isCacheable​(java.net.URL source)
      Returns whether the resource can be cached as a local file; if not, then URLConnection.openStream can be used to obtain the contents.
      static boolean isNonCacheable​(java.net.URL source)
      Returns whether the resource can be cached as a local file; if not, then URLConnection.openStream can be used to obtain the contents.
      static void logCacheIds​(java.lang.String filter)  
      static java.io.File urlToPath​(java.net.URL location, java.lang.String root)
      Converts a URL into a local path string within the given directory.
      static void waitForResources​(JNLPClassLoader jnlpClassLoader, ResourceTracker tracker, java.net.URL[] resources, java.lang.String title)
      Waits until the resources are downloaded, while showing a progress indicator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final Logger LOG
      • NON_CACHEABLE_PROTOCOLS

        private static final java.util.List<java.lang.String> NON_CACHEABLE_PROTOCOLS
    • Constructor Detail

      • CacheUtil

        public CacheUtil()
    • Method Detail

      • downloadAndGetCacheFile

        public static java.io.File downloadAndGetCacheFile​(java.net.URL location,
                                                           VersionString version)
        Caches a resource and returns a URL for it in the cache; blocks until resource is cached. If the resource location is not cacheable (points to a local file, etc) then the original URL is returned.
        Parameters:
        location - location of the resource
        version - the version, or null
        Returns:
        either the location in the cache or the original location
      • logCacheIds

        public static void logCacheIds​(java.lang.String filter)
      • isNonCacheable

        public static boolean isNonCacheable​(java.net.URL source)
        Returns whether the resource can be cached as a local file; if not, then URLConnection.openStream can be used to obtain the contents.
        Parameters:
        source - the url of resource
        Returns:
        whether this resource can be cached
      • isCacheable

        public static boolean isCacheable​(java.net.URL source)
        Returns whether the resource can be cached as a local file; if not, then URLConnection.openStream can be used to obtain the contents.
        Parameters:
        source - the url of resource
        Returns:
        whether this resource can be cached
      • urlToPath

        public static java.io.File urlToPath​(java.net.URL location,
                                             java.lang.String root)
        Converts a URL into a local path string within the given directory. For example a url with subdirectory /tmp/ will result in a File that is located somewhere within /tmp/
        Parameters:
        location - the url
        root - the subdirectory
        Returns:
        the file
      • hex

        public static java.lang.String hex​(java.lang.String origName,
                                           java.lang.String candidate)
                                    throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • waitForResources

        public static void waitForResources​(JNLPClassLoader jnlpClassLoader,
                                            ResourceTracker tracker,
                                            java.net.URL[] resources,
                                            java.lang.String title)
        Waits until the resources are downloaded, while showing a progress indicator.
        Parameters:
        jnlpClassLoader - the classloader
        tracker - the resource tracker
        resources - the resources to wait for
        title - name of the download
      • getProgressClass

        private static java.lang.String getProgressClass​(JNLPClassLoader jnlpClassLoader)