|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.resources.ResourceLocator
public class ResourceLocator
The ResourceLocator serves as an abstraction layer to locate resources from
a base folder or base URL.
Use the create(String) method to create an instance and the getResource(String)
or getResourceAsStream(String) method to get child resources.
You can also create sub-ResourceLocators to handle sub-locations more easily.
If you want to use a specific instance as a singleton, you the setSingletonInstance(ResourceLocator)
or useAsSingletonInstance() method. Then you can also use the ResLoc
class to have shorter commands in your coding.
ResLoc| Constructor Summary | |
|---|---|
protected |
ResourceLocator(java.io.File baseFolder)
Creates a new ResourceLocator instance. |
protected |
ResourceLocator(java.lang.Object dummy,
java.lang.String baseResource)
Creates a new ResourceLocator instance. |
protected |
ResourceLocator(java.lang.String foldername)
Creates a new ResourceLocator instance. |
|
ResourceLocator(java.net.URL baseURL)
Creates a new ResourceLocator instance with the given base-URL. |
| Method Summary | |
|---|---|
static ResourceLocator |
create(java.lang.String baseResource)
Creates a new ResourceLocator instance. |
org.jagatoo.loaders.textures.locators.TextureStreamLocator |
createAndAddTSL()
Creates a TextureStreamLocator and adds it to the TextureLoader. |
org.jagatoo.loaders.textures.locators.TextureStreamLocator |
createAndAddTSL(java.lang.String resourceName)
Creates a TextureStreamLocator and adds it to the TextureLoader. |
java.util.List<java.net.URL> |
findAllResources(java.lang.String extension,
boolean recursively,
boolean foldersToo)
Searches for all child resources in this ResourceLoator. |
java.net.URL |
getBaseURL()
|
static ResourceLocator |
getInstance()
If you want to use one ResourceLocator as a singleton, use this. |
java.net.URL |
getResource(java.lang.String name)
Creates a resource as a URL from this ResourceLocator. |
java.io.InputStream |
getResourceAsStream(java.lang.String name)
Creates a resource as a URL from this ResourceLocator. |
ResourceLocator |
getSubLocator(java.lang.String subResource)
Creates a new ResourceLocator instance with the sub-URL as its baseURL. |
org.jagatoo.loaders.textures.locators.TextureStreamLocatorURL |
getTSL()
Creates a TextureStreamLocator to be added to the TextureLoader. |
org.jagatoo.loaders.textures.locators.TextureStreamLocatorURL |
getTSL(java.lang.String resourceName)
Creates a TextureStreamLocator to be added to the TextureLoader. |
protected void |
setBaseURL(java.io.File baseFolder)
Sets the baseURL. |
protected void |
setBaseURL(java.lang.String foldername)
Sets the baseURL. |
protected void |
setBaseURL(java.net.URL baseURL)
Sets the base-URL of this ResourceLocator. |
static void |
setSingletonInstance(ResourceLocator resLoc)
If you want to use one ResourceLocator as a singleton, first invoke this and then use the getInstance() method to access the instance everywhere. |
void |
useAsSingletonInstance()
If you want to use one ResourceLocator as a singleton, first invoke this and then use the getInstance() method to access the instance everywhere. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceLocator(java.net.URL baseURL)
baseURL -
protected ResourceLocator(java.io.File baseFolder)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException
baseFolder -
java.io.FileNotFoundException - if the folder does not exist
java.lang.IllegalArgumentException - if the baseFolder is not a directory
protected ResourceLocator(java.lang.String foldername)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException
foldername -
java.io.FileNotFoundException - if the folder does not exist
java.lang.IllegalArgumentException - if the baseFolder is not a directory
protected ResourceLocator(java.lang.Object dummy,
java.lang.String baseResource)
baseResource -
java.lang.IllegalArgumentException - if something is wrong with the given baseResource| Method Detail |
|---|
public static void setSingletonInstance(ResourceLocator resLoc)
resLoc - the ResourceLocator instance to use as the singleton instanceuseAsSingletonInstance(),
getInstance(),
ResLocpublic void useAsSingletonInstance()
setSingletonInstance(ResourceLocator),
getInstance(),
ResLocpublic static ResourceLocator getInstance()
setSingletonInstance(ResourceLocator),
ResLocprotected void setBaseURL(java.net.URL baseURL)
protected void setBaseURL(java.io.File baseFolder)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException
baseFolder -
java.io.FileNotFoundException - if the folder does not exist
java.lang.IllegalArgumentException - if the baseFolder is not a directory
protected void setBaseURL(java.lang.String foldername)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException
foldername -
java.io.FileNotFoundException - if the folder does not exist
java.lang.IllegalArgumentException - if the baseFolder is not a directorypublic java.net.URL getBaseURL()
public ResourceLocator getSubLocator(java.lang.String subResource)
throws java.net.MalformedURLException
subResource - the relative resource to complete with this
instance's baseURL to the new instance's baseURL
java.net.MalformedURLException - if something was wrong with the resource
public java.net.URL getResource(java.lang.String name)
throws java.net.MalformedURLException
name - the relative resource to complete with this
instance's baseURL to an absolute one
java.net.MalformedURLException - if something was wrong with the resource
public java.io.InputStream getResourceAsStream(java.lang.String name)
throws java.net.MalformedURLException,
java.io.IOException
name - the relative resource to complete with this
instance's baseURL to an absolute one
java.net.MalformedURLException - if something was wrong with the resource
java.io.IOException - when the InputStream could not be created
public java.util.List<java.net.URL> findAllResources(java.lang.String extension,
boolean recursively,
boolean foldersToo)
extension - recursively - foldersToo -
public org.jagatoo.loaders.textures.locators.TextureStreamLocatorURL getTSL(java.lang.String resourceName)
throws java.net.MalformedURLException
resourceName - the relative resource to complete with this
instance's baseURL to an absolute one
It is taken as the constructor's argument for the TextureStreamLocatorURL.
java.net.MalformedURLException - if something was wrong with the resourcepublic org.jagatoo.loaders.textures.locators.TextureStreamLocatorURL getTSL()
public org.jagatoo.loaders.textures.locators.TextureStreamLocator createAndAddTSL(java.lang.String resourceName)
throws java.net.MalformedURLException
resourceName - the relative resource to complete with this
instance's baseURL to an absolute one
It is taken as the constructor's argument for the TextureStreamLocatorURL.
java.net.MalformedURLException - if something was wrong with the resourcepublic org.jagatoo.loaders.textures.locators.TextureStreamLocator createAndAddTSL()
public static ResourceLocator create(java.lang.String baseResource)
baseResource -
java.lang.IllegalArgumentException - if something is wrong with the given baseResource
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||