|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.resource.ResourceBundle
com.threerings.resource.FileResourceBundle
public class FileResourceBundle
A resource bundle provides access to the resources in a jar file.
| Field Summary | |
|---|---|
protected File |
_cache
A directory into which we unpack files from our bundle. |
protected JarFile |
_jarSource
The jar file from which we load resources. |
protected File |
_source
The file from which we construct our jar file. |
protected long |
_sourceLastMod
The last modified time of our source jar file. |
protected static File |
_tmpdir
A directory in which we temporarily unpack our resource files. |
protected File |
_unpacked
A file whose timestamp indicates whether or not our existing jar file has been unpacked. |
| Constructor Summary | |
|---|---|
FileResourceBundle(File source)
Constructs a resource bundle with the supplied jar file. |
|
FileResourceBundle(File source,
boolean delay,
boolean unpack)
Constructs a resource bundle with the supplied jar file. |
|
| Method Summary | |
|---|---|
protected void |
closeJar()
Closes our (possibly opened) jar file. |
boolean |
containsResource(String path)
Returns true if this resource bundle contains the resource with the specified path. |
static File |
getCacheDir()
Returns the cache directory used for unpacked resources. |
String |
getIdent()
Uniquely identifies this resource bundle. |
BufferedImage |
getImageResource(String path,
boolean useFastIO)
Decodes and returns the specified image resource. |
InputStream |
getResource(String path)
Fetches the named resource from this bundle. |
File |
getResourceFile(String path)
Returns a file from which the specified resource can be loaded. |
File |
getSource()
Returns the File from which resources are fetched for this bundle. |
boolean |
isUnpacked()
|
protected boolean |
resolveJarFile()
Creates the internal jar file reference if we've not already got it; we do this lazily so as to avoid any jar- or zip-file-related antics until and unless doing so is required, and because the resource manager would like to be able to create bundles before the associated files have been fully downloaded. |
static void |
setCacheDir(File tmpdir)
Specifies the directory in which our temporary resource files should be stored. |
boolean |
sourceIsReady()
Called by the resource manager once it has ensured that our resource jar file is up to date and ready for reading. |
protected static String |
stripSuffix(String path)
Strips the .jar off of jar file paths. |
String |
toString()
|
void |
wipeBundle(boolean deleteJar)
Clears out everything associated with this resource bundle in the hopes that we can download it afresh and everything will work the next time around. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected File _source
protected long _sourceLastMod
protected File _unpacked
protected File _cache
protected JarFile _jarSource
protected static File _tmpdir
| Constructor Detail |
|---|
public FileResourceBundle(File source)
source - a file object that references our source jar file.
public FileResourceBundle(File source,
boolean delay,
boolean unpack)
source - a file object that references our source jar file.delay - if true, the bundle will wait until someone calls sourceIsReady()
before allowing access to its resources.unpack - if true the bundle will unpack itself into a temporary directory| Method Detail |
|---|
public String getIdent()
ResourceBundle
getIdent in class ResourceBundle
public InputStream getResource(String path)
throws IOException
ResourceBundlesounds/scream.au.
getResource in class ResourceBundlepath - the path to the resource in this jar file.
IOException - thrown if an error occurs locating the resource in the jar file.
public BufferedImage getImageResource(String path,
boolean useFastIO)
throws IOException
ResourceBundle
getImageResource in class ResourceBundleIOExceptionpublic File getSource()
File from which resources are fetched for this bundle.
public boolean isUnpacked()
public boolean sourceIsReady()
public void wipeBundle(boolean deleteJar)
public File getResourceFile(String path)
throws IOException
path - the path to the resource in this jar file.
IOExceptionpublic boolean containsResource(String path)
public String toString()
toString in class Object
protected boolean resolveJarFile()
throws IOException
IOExceptionprotected void closeJar()
public static File getCacheDir()
public static void setCacheDir(File tmpdir)
protected static String stripSuffix(String path)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||