public class ResourceLoader
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
protected static java.util.ArrayList<java.lang.String> |
appletSearchPaths |
|
protected static boolean |
cacheEnabled |
|
protected static boolean |
canceled |
|
protected static java.lang.String |
downloadURL |
|
protected static java.util.Set<java.lang.String> |
extractExtensions |
|
protected static java.lang.String |
LINUX_DEFAULT_CACHE |
|
protected static int |
maxPaths |
|
static java.io.FileFilter |
OSP_CACHE_FILTER |
|
protected static java.io.File |
ospCache |
|
protected static java.lang.String |
OSX_DEFAULT_CACHE |
|
protected static java.util.ArrayList<java.lang.String> |
pathsNotFound |
|
protected static java.util.Hashtable<java.lang.String,Resource> |
resources |
|
protected static java.lang.String |
SEARCH_CACHE_SUBDIRECTORY |
|
protected static java.util.ArrayList<java.lang.String> |
searchPaths |
|
protected static boolean |
webConnected |
|
protected static java.lang.String |
WIN_XP_DEFAULT_CACHE |
|
protected static java.lang.String |
WINDOWS_DEFAULT_CACHE |
|
protected static java.net.URLClassLoader |
xsetZipLoader |
|
protected static java.util.Map<java.lang.String,java.net.URLClassLoader> |
zipLoaders |
|
protected static boolean |
zipURLsOK |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
addAppletSearchPath(java.lang.String base) |
Adds a search path at the beginning of the applet's search path list.
|
static void |
addExtractExtension(java.lang.String extension) |
Adds an extension to the end of the extractExtensions list.
|
static void |
addSearchPath(java.lang.String base) |
Adds a path at the beginning of the searchPaths list.
|
static java.io.File |
chooseOSPCache(java.awt.Component parent) |
Uses a JFileChooser to select a cache directory.
|
static boolean |
clearOSPCache(java.io.File cache,
boolean clearSearchCache) |
Clears an OSP cache.
|
static boolean |
clearOSPCacheHost(java.io.File hostDir) |
Clears an OSP cache host directory.
|
static boolean |
copyAllFiles(java.io.File inFile,
java.io.File outFile) |
Copies a source file to a target file.
|
static java.io.File |
copyHTMLToOSPCache(java.lang.String htmlPath) |
Copies an HTML file with associated images and stylesheet to the OSP cache.
|
static boolean |
deleteFile(java.io.File file) |
Deletes a file or folder.
|
static java.io.File |
download(java.lang.String urlPath,
java.io.File target,
boolean alwaysOverwrite) |
Downloads a file from the web to a target File.
|
static java.io.File |
downloadToOSPCache(java.lang.String urlPath,
java.lang.String fileName,
boolean alwaysOverwrite) |
Downloads a file from the web to the OSP Cache.
|
static java.io.File |
extractFileFromZIP(java.lang.String source,
java.io.File target,
boolean alwaysOverwrite) |
Extracts a file from a ZIP archive to a target file.
|
static java.applet.AudioClip |
getAudioClip(java.lang.String path) |
Gets an audio clip.
|
static java.awt.image.BufferedImage |
getBufferedImage(java.lang.String path) |
Gets a buffered image.
|
static java.awt.image.BufferedImage |
getBufferedImage(java.lang.String path,
int bufferedImageType) |
Gets a buffered image.
|
static java.io.File |
getDefaultOSPCache() |
Gets the default directory for cached files.
|
static java.util.List<java.io.File> |
getFiles(java.io.File directory,
java.io.FileFilter filter) |
Gets the list of files in a directory and its subdirectories that are accepted by a FileFilter.
|
static java.lang.String |
getHTMLCode(java.lang.String path) |
Returns the HTML code for a local or web HTML page.
|
static javax.swing.Icon |
getIcon(java.lang.String path) |
Gets an icon.
|
static java.awt.Image |
getImage(java.lang.String path) |
Gets an image.
|
static java.lang.String |
getNonURIPath(java.lang.String uriPath) |
Removes protocol and "%20" from URI paths.
|
static java.io.File |
getOSPCache() |
Gets the directory for cached files.
|
static java.io.File |
getOSPCacheFile(java.lang.String urlPath) |
Gets the cache file associated with a URL path.
|
static java.io.File |
getOSPCacheFile(java.lang.String urlPath,
java.lang.String name) |
Gets the cache file associated with a URL path.
|
static Resource |
getResource(java.lang.String name) |
Gets a resource specified by name.
|
static Resource |
getResource(java.lang.String name,
boolean searchFiles) |
Gets a resource specified by name.
|
static Resource |
getResource(java.lang.String name,
java.lang.Class<?> type) |
Gets a resource specified by name and Class.
|
static Resource |
getResource(java.lang.String name,
java.lang.Class<?> type,
boolean searchFiles) |
Gets a resource specified by name and Class.
|
static Resource |
getResource(java.lang.String basePath,
java.lang.String name) |
Gets a resource specified by base path and name.
|
static Resource |
getResource(java.lang.String basePath,
java.lang.String name,
boolean searchFiles) |
Gets a resource specified by base path and name.
|
static Resource |
getResource(java.lang.String basePath,
java.lang.String name,
java.lang.Class<Resource> type) |
Gets a resource specified by base path, name and class.
|
static Resource |
getResource(java.lang.String basePath,
java.lang.String name,
java.lang.Class<Resource> type,
boolean searchFiles) |
Gets a resource specified by base path, name and class.
|
static Resource |
getResourceZipURLsOK(java.lang.String name) |
Gets a resource specified by name.
|
static java.io.File |
getSearchCache() |
Gets the search cache directory.
|
static java.io.File |
getSearchCacheFile(java.lang.String urlPath) |
Gets the search cache (XML) file associated with a URL path.
|
static java.lang.String |
getString(java.lang.String path) |
Gets a string.
|
static java.lang.String |
getStyleSheetFromHTMLCode(java.lang.String code) |
Returns the first stylesheet link, if any, in an HTML page.
|
static java.lang.String |
getTitleFromHTMLCode(java.lang.String code) |
Returns the title, if any, of an HTML page.
|
static java.lang.String |
getURIPath(java.lang.String path) |
Converts a path to URI form (spaces replaced by "%20", etc).
|
static java.util.Set<java.lang.String> |
getZipContents(java.lang.String zipPath) |
Gets the contents of a zip file.
|
static boolean |
isCacheEnabled() |
Gets the cacheEnabled property.
|
static boolean |
isCanceled() |
Determines if the current operation is canceled.
|
static boolean |
isOSPCachePath(java.lang.String path) |
Determines if a path defines a file in the OSP cache.
|
static boolean |
isURLAvailable(java.lang.String urlPath) |
Determines if a url path is available (ie both valid and connected).
|
static java.io.InputStream |
openInputStream(java.lang.String path) |
Opens and returns an input stream.
|
static java.io.Reader |
openReader(java.lang.String path) |
Opens and returns a reader.
|
static void |
removeAppletSearchPath(java.lang.String base) |
Removes a path from the applet search path list.
|
static void |
removeSearchPath(java.lang.String base) |
Removes a path from the searchPaths list.
|
static void |
setCacheEnabled(boolean enabled) |
Sets the cacheEnabled property.
|
static void |
setCanceled(boolean cancel) |
Cancels the current operation when true.
|
static void |
setOSPCache(java.io.File newCache) |
Sets the directory for cached files.
|
static java.util.Set<java.io.File> |
unzip(java.lang.String zipPath,
java.io.File targetDir,
boolean alwaysOverwrite) |
Unzips a ZIP file into the given directory.
|
public static final java.io.FileFilter OSP_CACHE_FILTER
protected static final java.lang.String WIN_XP_DEFAULT_CACHE
protected static final java.lang.String WINDOWS_DEFAULT_CACHE
protected static final java.lang.String OSX_DEFAULT_CACHE
protected static final java.lang.String LINUX_DEFAULT_CACHE
protected static final java.lang.String SEARCH_CACHE_SUBDIRECTORY
protected static java.util.ArrayList<java.lang.String> searchPaths
protected static java.util.ArrayList<java.lang.String> appletSearchPaths
protected static int maxPaths
protected static java.util.Hashtable<java.lang.String,Resource> resources
protected static boolean cacheEnabled
protected static boolean canceled
protected static java.util.Map<java.lang.String,java.net.URLClassLoader> zipLoaders
protected static java.net.URLClassLoader xsetZipLoader
protected static java.util.Set<java.lang.String> extractExtensions
protected static java.util.ArrayList<java.lang.String> pathsNotFound
protected static java.io.File ospCache
protected static boolean zipURLsOK
protected static boolean webConnected
protected static java.lang.String downloadURL
public static Resource getResource(java.lang.String name)
name - the file or URL namepublic static Resource getResourceZipURLsOK(java.lang.String name)
name - the file or URL namepublic static Resource getResource(java.lang.String name, boolean searchFiles)
name - the file or URL namesearchFiles - true to search filespublic static Resource getResource(java.lang.String name, java.lang.Class<?> type)
name - the file or URL nametype - the Class providing default ClassLoader resource loadingpublic static Resource getResource(java.lang.String name, java.lang.Class<?> type, boolean searchFiles)
name - the file or URL nametype - the Class providing default ClassLoader resource loadingsearchFiles - true to search filespublic static Resource getResource(java.lang.String basePath, java.lang.String name)
basePath - the base pathname - the file or URL namepublic static Resource getResource(java.lang.String basePath, java.lang.String name, boolean searchFiles)
basePath - the base pathname - the file or URL namesearchFiles - true to search filespublic static Resource getResource(java.lang.String basePath, java.lang.String name, java.lang.Class<Resource> type)
basePath - the base pathname - the file or URL nametype - the Class providing ClassLoader resource loadingpublic static Resource getResource(java.lang.String basePath, java.lang.String name, java.lang.Class<Resource> type, boolean searchFiles)
basePath - the base pathname - the file or URL nametype - the Class providing ClassLoader resource loadingsearchFiles - true to search filespublic static void addSearchPath(java.lang.String base)
base - the base path to addpublic static void removeSearchPath(java.lang.String base)
base - the base path to removepublic static void addAppletSearchPath(java.lang.String base)
base - the base path to addpublic static void removeAppletSearchPath(java.lang.String base)
base - the base path to removepublic static void setCacheEnabled(boolean enabled)
enabled - true to enable the cachepublic static boolean isCacheEnabled()
public static void addExtractExtension(java.lang.String extension)
extension - the extension to addpublic static void setCanceled(boolean cancel)
cancel - true to cancelpublic static boolean isCanceled()
public static java.io.InputStream openInputStream(java.lang.String path)
path - the pathpublic static java.io.Reader openReader(java.lang.String path)
path - the pathpublic static java.lang.String getString(java.lang.String path)
path - the pathpublic static javax.swing.Icon getIcon(java.lang.String path)
path - the pathpublic static java.awt.Image getImage(java.lang.String path)
path - the pathpublic static java.awt.image.BufferedImage getBufferedImage(java.lang.String path)
path - the pathpublic static java.awt.image.BufferedImage getBufferedImage(java.lang.String path,
int bufferedImageType)
path - the pathbufferedImageType - one of the types defined by the BufferedImage classpublic static java.applet.AudioClip getAudioClip(java.lang.String path)
path - the pathpublic static void setOSPCache(java.io.File newCache)
newCache - the desired cache directorypublic static java.io.File getOSPCache()
public static java.io.File getDefaultOSPCache()
public static java.io.File chooseOSPCache(java.awt.Component parent)
parent - a component to own the file chooserpublic static boolean isOSPCachePath(java.lang.String path)
path - the pathpublic static java.io.File getOSPCacheFile(java.lang.String urlPath)
urlPath - the path to the filepublic static java.io.File getOSPCacheFile(java.lang.String urlPath,
java.lang.String name)
urlPath - the path to the filename - name of the file (may be null)public static java.io.File getSearchCache()
public static java.io.File getSearchCacheFile(java.lang.String urlPath)
urlPath - the path to the filepublic static java.io.File downloadToOSPCache(java.lang.String urlPath,
java.lang.String fileName,
boolean alwaysOverwrite)
urlPath - the path to the filefileName - the name to assign the downloaded filealwaysOverwrite - true to overwrite an existing file, if anypublic static java.lang.String getHTMLCode(java.lang.String path)
path - the path to the HTML pagepublic static java.lang.String getTitleFromHTMLCode(java.lang.String code)
code - the HTML codepublic static java.lang.String getStyleSheetFromHTMLCode(java.lang.String code)
code - the HTML codepublic static java.io.File copyHTMLToOSPCache(java.lang.String htmlPath)
htmlPath - the path to the source HTML filepublic static boolean copyAllFiles(java.io.File inFile,
java.io.File outFile)
inFile - the sourceoutFile - the targetpublic static boolean clearOSPCache(java.io.File cache,
boolean clearSearchCache)
cache - the cache to clearclearSearchCache - true to clear the search cachepublic static boolean clearOSPCacheHost(java.io.File hostDir)
hostDir - the cache host directory to clearpublic static boolean deleteFile(java.io.File file)
file - the file to deletepublic static java.util.List<java.io.File> getFiles(java.io.File directory,
java.io.FileFilter filter)
directory - the directory to searchfilter - the FileFilterpublic static java.util.Set<java.lang.String> getZipContents(java.lang.String zipPath)
zipPath - the path to the zip filepublic static java.util.Set<java.io.File> unzip(java.lang.String zipPath,
java.io.File targetDir,
boolean alwaysOverwrite)
zipPath - the (url) path to the zip filetargetDir - target directory to save the extracted filesalwaysOverwrite - true to overwrite existing files, if anypublic static java.io.File download(java.lang.String urlPath,
java.io.File target,
boolean alwaysOverwrite)
urlPath - the path to the filetarget - the target filealwaysOverwrite - true to overwrite an existing file, if anypublic static java.io.File extractFileFromZIP(java.lang.String source,
java.io.File target,
boolean alwaysOverwrite)
source - the path of the file to be extracted (eg "http:/www.server/folder/images.zip!/image1.png")target - target file to savealwaysOverwrite - true to overwrite existing files, if anypublic static boolean isURLAvailable(java.lang.String urlPath)
urlPath - the path in URI formpublic static java.lang.String getNonURIPath(java.lang.String uriPath)
uriPath - the path in URI formpublic static java.lang.String getURIPath(java.lang.String path)
path - the path