public interface ResourceLocater
While conceptually file-based, this could actually be implemented on top of anything.
| Modifier and Type | Method and Description |
|---|---|
ResourceName |
findResource(ResourceName parent,
java.lang.String name)
Searches for a resource with the given name, returns the full path to it.
|
ResourceName |
findResource(java.lang.String name)
Searches for a resource with the given name, returns the full path to it.
|
long |
getModifiedTime(ResourceName resourceName)
Gets a value which indicates when the resource was modified.
|
java.io.Reader |
getReader(ResourceName resourceName)
Gets a
Reader to read the contents of the given resource. |
ResourceName findResource(@Nullable ResourceName parent, java.lang.String name) throws CarrotException
This will search for the resource in the given path first, if not found there will search a locator-specific search path for the resource before giving up.
parent - The parent to look for the resource in. If not found here, we will also do a search for a
non-relative name. May be null to search only in the search path.name - The name of the resource to search file.ResourceName representing the resolved name of the resource.CarrotException - If the resource cannot be found.ResourceName findResource(java.lang.String name) throws CarrotException
name - The name of the resource to search file.ResourceName representing the resolved name of the resource.CarrotException - If the resource cannot be found.long getModifiedTime(ResourceName resourceName) throws CarrotException
The value is used to determine whether we need to flush our caches, and this function will be called for every request to render a template, so calling this needs to be quick.
Zero indicates this ResourceLocater doesn't support modification detection, and resources will be cached
indefinitely.
resourceName - The ResourceName of the resource.CarrotException - If the resource cannot be found.java.io.Reader getReader(ResourceName resourceName) throws CarrotException
Reader to read the contents of the given resource.resourceName - The ResourceName of the resource.Reader for reading the contents of the resource.CarrotException - If the resource cannot be found.