Package com.ardor3d.util.resource
Class MultiFormatResourceLocator
java.lang.Object
com.ardor3d.util.resource.SimpleResourceLocator
com.ardor3d.util.resource.MultiFormatResourceLocator
- All Implemented Interfaces:
ResourceLocator
This class extends the behavior of the
SimpleResourceLocator
by replacing the resource's file extension with
different various provided extensions. If none of these work, it will try the original resource name as-is. You can
choose to have the original file searched for first, or last using setTrySpecifiedFormatFirst(boolean)
.-
Constructor Summary
ConstructorDescriptionMultiFormatResourceLocator
(URI baseDir, String... extensions) Construct a new MultiFormatResourceLocator using the given URI as our context and the list of possible extensions as extensions to try during file search.MultiFormatResourceLocator
(URL baseDir, String... extensions) Construct a new MultiFormatResourceLocator using the given URL as our context and the list of possible extensions as extensions to try during file search. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
locateResource
(String resourceName) Locates a resource according to the strategy of the resource locator implementation (subclass).void
setTrySpecifiedFormatFirst
(boolean trySpecifiedFormatFirst) Methods inherited from class com.ardor3d.util.resource.SimpleResourceLocator
cleanup, doRecursiveLocate, getBaseDir, hashCode, trimResourceName
-
Constructor Details
-
MultiFormatResourceLocator
Construct a new MultiFormatResourceLocator using the given URI as our context and the list of possible extensions as extensions to try during file search.- Parameters:
baseDir
- our base context. This is meant to be a "directory" wherein we will search for resources. Therefore, if it does not end in /, a / will be added to ensure we are talking about children of the given baseDir.extensions
- an array of extensions (eg. ".png", ".dds", ".tga", etc.) to try while searching for a resource with this locator. This is done by replacing any existing extension in the resource name with each of the given extensions.- Throws:
URISyntaxException
- if the given URI does not end in / and we can not make a new URI with a trailing / from it.
-
MultiFormatResourceLocator
Construct a new MultiFormatResourceLocator using the given URL as our context and the list of possible extensions as extensions to try during file search.- Parameters:
baseDir
- our base context. This is converted to a URI. This is meant to be a "directory" wherein we will search for resources. Therefore, if it does not end in /, a / will be added to ensure we are talking about children of the given baseDir.extensions
- an array of extensions (eg. ".png", ".dds", ".tga", etc.) to try while searching for a resource with this locator. This is done by replacing any existing extension in the resource name with each of the given extensions.- Throws:
URISyntaxException
- if this URL can not be converted to a URI, or if the converted URI does not end in / and we can not make a new URI with a trailing / from it.
-
-
Method Details
-
locateResource
Description copied from interface:ResourceLocator
Locates a resource according to the strategy of the resource locator implementation (subclass).- Specified by:
locateResource
in interfaceResourceLocator
- Overrides:
locateResource
in classSimpleResourceLocator
- Parameters:
resourceName
- the name of the resource to locate; it this is a path it must be slash separated (no backslashes)- Returns:
- a source for the resource, null if the resource was not found
- See Also:
-
isTrySpecifiedFormatFirst
public boolean isTrySpecifiedFormatFirst() -
setTrySpecifiedFormatFirst
public void setTrySpecifiedFormatFirst(boolean trySpecifiedFormatFirst) -
equals
- Overrides:
equals
in classSimpleResourceLocator
-