Package rife.resources
Class ResourceFinderGroup
java.lang.Object
rife.resources.AbstractResourceFinder
rife.resources.ResourceFinderGroup
- All Implemented Interfaces:
ResourceFinder
Allows a group of resource finders to acts as if they are one single
resource finders. They will be consecutively used in their order of addition
to the group.
- Since:
- 1.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(ResourceFinder resourceFinder) 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.getResource
(String name) Retrieves the resource that corresponds to the provided name.<ResultType>
ResultTypeuseStream
(URL resource, InputStreamUser<ResultType, ?> user) Returns a stream that can be used to read the contents of the provided resource.Methods inherited from class rife.resources.AbstractResourceFinder
getContent, getContent, getContent, getModificationTime, useStream
-
Constructor Details
-
ResourceFinderGroup
public ResourceFinderGroup()
-
-
Method Details
-
add
-
getResource
Description copied from interface:ResourceFinder
Retrieves the resource that corresponds to the provided name.This method never throws an exception, but returns
null
in case of an exception.- Parameters:
name
- the name of the resource to retrieve- Returns:
- the
URL
object that corresponds to the provided name; ornull
if the resource couldn't be found or if an error occurred.
-
useStream
public <ResultType> ResultType useStream(URL resource, InputStreamUser<ResultType, ?> user) throws ResourceFinderErrorExceptionDescription copied from interface:ResourceFinder
Returns a stream that can be used to read the contents of the provided resource.- Parameters:
resource
- the resource to retrieveuser
- an instance ofInputStreamUser
that contains the logic that will be executed with this stream- Returns:
- the return value from the
useInputStream
method of the providedInputStreamUser
instance - Throws:
ResourceFinderErrorException
- when an error occurred during the creation or opening of the stream.- See Also:
-
getContent
Description copied from interface:ResourceFinder
Retrieves the complete content of the provided resource.- Parameters:
resource
- the resource to retrieve the content fromencoding
- the encoding that should be used to read the content- Returns:
- a
String
object that contains the complete content of the resource with the provided name; ornull
if the resource couldn't be found. - Throws:
ResourceFinderErrorException
- when an error occurred during the retrieval of the content or when the encoding is not supported.- See Also:
-
getModificationTime
Description copied from interface:ResourceFinder
Retrieves the modification time of the provided resource.- Parameters:
resource
- the resource to retrieve the modification time from- Returns:
- a positive
long
with the modification time in milliseconds; or-1
if the resource couldn't be found. - Throws:
ResourceFinderErrorException
- when an error occurred during the retrieval of the modification time.- See Also:
-