|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectraccoon.core.utils.StdResolver
public final class StdResolver
Convenience methods for searching within the current classpath and working directory for a resource of any kind.
This class regroups the various utility methods that where dispersed within the Raccoon project, as such all classes should now use the methods within this class to load a resource file (property, xml, ...) The search sequence is the following:ClassLoader.getSystemResource(String)
ResourceNotFoundException
upon error.
The following errors are possible:
ErrorCodes.RESOURCE_INVALID
if the resource is invalid (invalid file name for example)
ErrorCodes.RESOURCE_NOT_FOUND
if the resource couldn't be found or if the resource is empty (zero
size resource) or if the resource is locked by another process and isn't available.
sample.xml
interpreted as current currentPackage/sample.xml
,
currentClasspath/sample.xml
and finally workingDir/sample.xml
dir.sample.xml
interpreted as currentPackage/dir.sample.xml
,
currentClasspath/dir.sample.xml
, workingDir/dir.sample.xml
or if this fails as
currentPackage/dir/sample.xml
,
currentClasspath/dir/sample.xml
, workingDir/dir/sample.xml
Constructor Summary | |
---|---|
StdResolver()
|
Method Summary | |
---|---|
java.io.InputStream |
getResourceAsStream(java.lang.Class pRequesterClass,
java.lang.String pDesiredRessource)
Locates the specified resource and provides an InputStream to it. |
java.io.InputStream |
getResourceAsStream(java.lang.String pDesiredRessource)
Locates the specified resource and provides an InputStream to it. |
static java.lang.String |
replaceDotWithSlash(java.lang.String pDesiredRessource)
Replaces all the dots with '/' in order to constitute a valid file URI. |
java.net.URL |
resolve(java.lang.Class pRequesterClass,
java.lang.String pDesiredRessource)
Locates the specified resource and provides the exact location to it. |
java.net.URL |
resolve(java.lang.String pDesiredRessource)
Locates the specified resource and provides the exact location to it. |
static java.net.URL |
staticResolve(java.lang.Class pRequesterClass,
java.lang.String pDesiredRessource)
Locates the specified resource and provides the exact location to it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StdResolver()
Method Detail |
---|
public final java.net.URL resolve(java.lang.String pDesiredRessource) throws ResourceNotFoundException
resolve
in interface IResolver
pDesiredRessource
- the resource that is to be located explicitly.
ResourceNotFoundException
- if the specified resource couldn't be found.public final java.net.URL resolve(java.lang.Class pRequesterClass, java.lang.String pDesiredRessource) throws ResourceNotFoundException
resolve
in interface IResolver
pRequesterClass
- the requesting class that is to be used as starting point for a relative search.pDesiredRessource
- the resource that is to be located explicitly, this can be a relative location from
the given requester class.
ResourceNotFoundException
- if the specified resource couldn't be found.public static java.net.URL staticResolve(java.lang.Class pRequesterClass, java.lang.String pDesiredRessource) throws ResourceNotFoundException
pRequesterClass
- the requesting class that is to be used as starting point for a relative search.pDesiredRessource
- the resource that is to be located explicitly, this can be a relative location from
the given requester class.
ResourceNotFoundException
- if the specified resource couldn't be found.public final java.io.InputStream getResourceAsStream(java.lang.String pDesiredRessource) throws ResourceNotFoundException
InputStream
to it.
getResourceAsStream
in interface IResolver
pDesiredRessource
- the resource that is to be located explicitly.
ResourceNotFoundException
- if the specified resource couldn't be found.public final java.io.InputStream getResourceAsStream(java.lang.Class pRequesterClass, java.lang.String pDesiredRessource) throws ResourceNotFoundException
InputStream
to it.
getResourceAsStream
in interface IResolver
pRequesterClass
- the requesting class that is to be used as starting point for a relative search.pDesiredRessource
- the resource that is to be located explicitly, this can be a relative location from
the given requester class.
ResourceNotFoundException
- if the specified resource couldn't be found.public static java.lang.String replaceDotWithSlash(java.lang.String pDesiredRessource)
pDesiredRessource
- the resource with the dots
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |