|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.resources.AbstractResourceFinder
com.uwyn.rife.resources.ResourceFinderDirectories
public class ResourceFinderDirectories
This class offers ResourceFinder capabilities for resources that
are available through a collection of directories.
The resources are looked up in the same order as the order in which the directories were specified. This means that if a resource is found in the first directory but it is also present in the second, only the first one will match.
ResourceFinder| Constructor Summary | |
|---|---|
ResourceFinderDirectories(File[] directories)
Creates a new instance for the provided array of directories. |
|
| Method Summary | ||
|---|---|---|
String |
getContent(URL resource,
String encoding)
Retrieves the complete content of the provided resource. |
|
long |
getModificationTime(URL resource)
Retrieves the modification time of the provided resource. |
|
URL |
getResource(String name)
Retrieves the resource that corresponds to the provided name. |
|
|
useStream(URL resource,
InputStreamUser user)
Returns a stream that can be used to read the contents of the provided resource. |
|
| Methods inherited from class com.uwyn.rife.resources.AbstractResourceFinder |
|---|
getContent, getContent, getContent, getModificationTime, useStream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceFinderDirectories(File[] directories)
directories - the directories where the resources should be
searched in.| Method Detail |
|---|
public URL getResource(String name)
ResourceFinder
This method never throws an exception, but returns null in
case of an exception.
name - the name of the resource to retrieve
URL object that corresponds to the provided
name; or
null if the resource couldn't be found or if an error
occurred.
public <ResultType> ResultType useStream(URL resource,
InputStreamUser user)
throws ResourceFinderErrorException,
InnerClassException
ResourceFinder
resource - the resource to retrieveuser - an instance of InputStreamUser
that contains the logic that will be executed with this stream
useInputStream method of
the provided InputStreamUser instance
ResourceFinderErrorException - when an error occurred during the
creation or opening of the stream.
InnerClassException - when errors occurs inside the
InputStreamUserInputStreamUser,
ResourceFinder.useStream(String, InputStreamUser)
public String getContent(URL resource,
String encoding)
throws ResourceFinderErrorException
ResourceFinder
resource - the resource to retrieve the content fromencoding - the encoding that should be used to read the content
String object that contains the complete content
of the resource with the provided name; or
null if the resource couldn't be found.
ResourceFinderErrorException - when an error occurred during the
retrieval of the content or when the encoding is not supported.ResourceFinder.getContent(String),
ResourceFinder.getContent(String, String),
ResourceFinder.getContent(URL)
public long getModificationTime(URL resource)
throws ResourceFinderErrorException
ResourceFinder
resource - the resource to retrieve the modification time from
long with the modification time in
milliseconds; or
-1 if the resource couldn't be found.
ResourceFinderErrorException - when an error occurred during the
retrieval of the modification time.ResourceFinder.getModificationTime(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||