Package net.sourceforge.jnlp.cache
Class CacheUtil
- java.lang.Object
-
- net.sourceforge.jnlp.cache.CacheUtil
-
public class CacheUtil extends java.lang.ObjectProvides static methods to interact with the cache, download indicator, and other utility methods.- Version:
- $Revision: 1.17 $
-
-
Field Summary
Fields Modifier and Type Field Description private static LoggerLOGprivate static java.util.List<java.lang.String>NON_CACHEABLE_PROTOCOLS
-
Constructor Summary
Constructors Constructor Description CacheUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.FiledownloadAndGetCacheFile(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 DownloadServiceListenergetDownloadServiceListener(JNLPClassLoader jnlpClassLoader, java.lang.String title, java.net.URL[] undownloaded, DownloadIndicator indicator)private static java.lang.StringgetProgressClass(JNLPClassLoader jnlpClassLoader)static java.lang.Stringhex(java.lang.String origName, java.lang.String candidate)static booleanisCacheable(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 booleanisNonCacheable(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 voidlogCacheIds(java.lang.String filter)static java.io.FileurlToPath(java.net.URL location, java.lang.String root)Converts a URL into a local path string within the given directory.static voidwaitForResources(JNLPClassLoader jnlpClassLoader, ResourceTracker tracker, java.net.URL[] resources, java.lang.String title)Waits until the resources are downloaded, while showing a progress indicator.
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
NON_CACHEABLE_PROTOCOLS
private static final java.util.List<java.lang.String> NON_CACHEABLE_PROTOCOLS
-
-
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 resourceversion- the version, ornull- 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 urlroot- 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 classloadertracker- the resource trackerresources- the resources to wait fortitle- name of the download
-
getDownloadServiceListener
private static DownloadServiceListener getDownloadServiceListener(JNLPClassLoader jnlpClassLoader, java.lang.String title, java.net.URL[] undownloaded, DownloadIndicator indicator)
-
getProgressClass
private static java.lang.String getProgressClass(JNLPClassLoader jnlpClassLoader)
-
-