|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ResourceFinder
This interface defines the methods that classes with
ResourceFinder functionalities have to implement.
A ResourceFinder provides an abstract way of working
with resources. According to a name, a resource can be searched for and its
location is returned as an URL object.
It also possible to obtain a stream to read the resource's content,
to retrieve all its contents as a String and to obtain the
modification time of the resource.
ResourceWriter| Method Summary | ||
|---|---|---|
String |
getContent(String name)
Retrieves the complete content of the resource that corresponds to the provided name. |
|
String |
getContent(String name,
String encoding)
Retrieves the complete content of the resource that corresponds to the provided name. |
|
String |
getContent(URL resource)
Retrieves the complete content of the provided resource. |
|
String |
getContent(URL resource,
String encoding)
Retrieves the complete content of the provided resource. |
|
long |
getModificationTime(String name)
Retrieves the modification time of the resource that corresponds to the provided name. |
|
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(String name,
InputStreamUser user)
Returns a stream that can be used to read the contents of 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. |
|
| Method Detail |
|---|
URL getResource(String name)
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.
<ResultType> ResultType useStream(String name,
InputStreamUser user)
throws ResourceFinderErrorException,
InnerClassException
name - the name of 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,
useStream(URL, InputStreamUser)
<ResultType> ResultType useStream(URL resource,
InputStreamUser user)
throws ResourceFinderErrorException,
InnerClassException
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,
useStream(String, InputStreamUser)
String getContent(String name)
throws ResourceFinderErrorException
name - the name of the resource to retrieve
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.getContent(String, String),
getContent(URL, String)
String getContent(String name,
String encoding)
throws ResourceFinderErrorException
name - the name of 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.getContent(String),
getContent(URL),
getContent(URL, String)
String getContent(URL resource)
throws ResourceFinderErrorException
resource - the resource to retrieve the content from
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.getContent(String),
getContent(String, String),
getContent(URL, String)
String getContent(URL resource,
String encoding)
throws ResourceFinderErrorException
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.getContent(String),
getContent(String, String),
getContent(URL)
long getModificationTime(String name)
throws ResourceFinderErrorException
name - the name of the resource to retrieve
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.getModificationTime(URL)
long getModificationTime(URL resource)
throws ResourceFinderErrorException
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.getModificationTime(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||