|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.lib.Resource
A Resource is an object that encapsulates a path to a Wyvern file resource, such as a map, archetype, code, artwork, or music file. Using this class can save you a lot of code dedicated to manipulating file paths and permissions.
A Resource object keeps track of many attributes of a resource, including its absolute path, relative path, file extension, version number, and (for Wizard resources) the name of the owning Wizard.
Resources are obtained using the Factory methods getRelative() and getAbsolute(). Any two Resources referring to the same file can be compared for equality using the "==" operator, even if one was obtained using getRelative() and the other using getAbsolute().
All the methods on this class are thread-safe.
Field Summary | |
static Resource |
NULL
|
Method Summary | |
boolean |
exists()
Returns true if the file actually exists on disk. |
static Resource |
getAbsolute(java.lang.String abspath)
Returns a Resource encapsulating the requested file. |
java.lang.String |
getAbsoluteDir()
Returns the directory containing this Resource. |
java.lang.String |
getAbsolutePath()
Returns the absolute path to this Resource. |
java.lang.String |
getDotExtension()
Returns the file extension for the file encapsulated by this resource. |
java.lang.String |
getExtension()
Returns the file extension for the file encapsulated by this Resource. |
java.io.File |
getFile()
Returns a java.io.File object for this resource. |
java.lang.String |
getFilename()
Returns the filename, without the path. |
java.lang.String |
getFilenameNoExt()
Returns the filename, without its path or extension. |
static Resource |
getRelative(java.lang.String relpath)
Returns a Resource encapsulating the requested file. |
java.lang.String |
getRelativeDir()
Returns the directory containing this Resource. |
java.lang.String |
getRelativePath()
Returns the relative path to this Resource. |
java.lang.String |
getRelativePathNoExt()
Returns the relative path to this resource, sans extension. |
static java.util.List |
getSupportedExtensions()
Returns a List of the supported extensions, e.g. ".map", ".arch", etc. |
java.lang.String |
getWizard()
Returns the Wizard's name (lowercase) who created this resource. |
boolean |
isBuiltin()
Returns true if this Resource is a built-in game resource. |
boolean |
isWizResource()
Returns true if this Resource is in a Wizard directory. |
static void |
main(java.lang.String[] args)
Tests out the initialization functions. |
java.lang.String |
toString()
Returns a debugging representation of this Resource. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Resource NULL
Method Detail |
public static Resource getRelative(java.lang.String relpath)
relpath
- the relative path to the file, such as
"wiz/foobar/arch/mything.arch", or, as an example of
a built-in game resource, "monsters/goblin/goblin.S.gif".
The relative path needs to include the file extension.
java.lang.IllegalArgumentException
- if the Resource
can't be determined from the path. This only happens
for built-in game resources where the extension isn't
in the list returned from getSupportedExtensions().public static Resource getAbsolute(java.lang.String abspath)
abspath
- the absolute path to the file, such as
"/games/wyvern/wiz/foobar/arch/mything.arch", or, as an
example of a built-in game resource,
"/games/wyvern/art/game/monsters/goblin/goblin.S.gif".
The path needs to include the file extension.
public java.lang.String getAbsolutePath()
public java.lang.String getRelativePath()
public java.lang.String getRelativePathNoExt()
public boolean isWizResource()
public boolean isBuiltin()
public java.lang.String getWizard()
public java.lang.String getExtension()
public java.lang.String getDotExtension()
public java.lang.String toString()
public java.io.File getFile()
public boolean exists()
public java.lang.String getFilename()
public java.lang.String getFilenameNoExt()
public java.lang.String getAbsoluteDir()
public java.lang.String getRelativeDir()
public static java.util.List getSupportedExtensions()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |