Class CacheUtil

java.lang.Object
net.sourceforge.jnlp.cache.CacheUtil

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

    • LOG

      private static final Logger LOG
    • NON_CACHEABLE_PROTOCOLS

      private static final List<String> NON_CACHEABLE_PROTOCOLS
  • Constructor Details

    • CacheUtil

      public CacheUtil()
  • Method Details

    • downloadAndGetCacheFile

      public static File downloadAndGetCacheFile(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(String filter)
    • isNonCacheable

      public static boolean isNonCacheable(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(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 File urlToPath(URL location, 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 String hex(String origName, String candidate) throws NoSuchAlgorithmException
      Throws:
      NoSuchAlgorithmException
    • waitForResources

      public static void waitForResources(JNLPClassLoader jnlpClassLoader, ResourceTracker tracker, URL[] resources, 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
    • getDownloadServiceListener

      private static DownloadServiceListener getDownloadServiceListener(JNLPClassLoader jnlpClassLoader, String title, URL[] undownloaded, DownloadIndicator indicator)
    • getProgressClass

      private static String getProgressClass(JNLPClassLoader jnlpClassLoader)