public class MemoryResourceLocator extends java.lang.Object implements ResourceLocater
ResourceLocater that just keeps stuff in memory.| Constructor and Description |
|---|
MemoryResourceLocator(java.util.Map<java.lang.String,java.lang.String> resources)
Constructs a new
MemoryResourceLocator using the given Configuration and base path to search for
resources in. |
| 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. |
public MemoryResourceLocator(java.util.Map<java.lang.String,java.lang.String> resources)
MemoryResourceLocator using the given Configuration and base path to search for
resources in.resources - A mapping of strings to resources.public ResourceName findResource(@Nullable ResourceName parent, java.lang.String name) throws CarrotException
ResourceLocaterThis 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.
findResource in interface ResourceLocaterparent - 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.public ResourceName findResource(java.lang.String name) throws CarrotException
ResourceLocaterfindResource in interface ResourceLocatername - The name of the resource to search file.ResourceName representing the resolved name of the resource.CarrotException - If the resource cannot be found.public long getModifiedTime(ResourceName resourceName) throws CarrotException
ResourceLocaterThe 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.
getModifiedTime in interface ResourceLocaterresourceName - The ResourceName of the resource.CarrotException - If the resource cannot be found.public java.io.Reader getReader(ResourceName resourceName) throws CarrotException
ResourceLocaterReader to read the contents of the given resource.getReader in interface ResourceLocaterresourceName - The ResourceName of the resource.Reader for reading the contents of the resource.CarrotException - If the resource cannot be found.