public class MapResourceFinder extends ListableResourceFinder
ResourceFinder that provides access to resource stored as
byte arrays in a Map.EMPTY_RESOURCE_FINDER| Constructor and Description |
|---|
MapResourceFinder() |
MapResourceFinder(Map<String,byte[]> map) |
| Modifier and Type | Method and Description |
|---|---|
Resource |
addResource(Resource resource)
Adds another
Resource, so that it can later be found with findResource(String), ResourceFinder.findResourceAsStream(String) and resources(). |
Resource |
addResource(String fileName,
byte[] data)
Adds another
Resource, so that it can later be found with findResource(String), ResourceFinder.findResourceAsStream(String) and resources(). |
Resource |
addResource(String fileName,
String data) |
Resource |
findResource(String resourceName)
Finds a resource by name and return it as a
Resource object. |
Iterable<Resource> |
list(String resourceNamePrefix,
boolean recurse)
Returns all resources who's names start with a given string.
|
Collection<Resource> |
resources() |
void |
setLastModified(long lastModified) |
findResourceAsStream@Nullable public Resource addResource(String fileName, byte[] data)
Resource, so that it can later be found with findResource(String), ResourceFinder.findResourceAsStream(String) and resources().null@Nullable public Resource addResource(String fileName, String data)
data - The text to store (in platform default encoding)nullpublic Resource addResource(Resource resource)
Resource, so that it can later be found with findResource(String), ResourceFinder.findResourceAsStream(String) and resources().nullpublic Collection<Resource> resources()
addResource(Resource)public final void setLastModified(long lastModified)
lastModified - The return value of Resource.lastModified() for the next resources added@Nullable public final Resource findResource(String resourceName)
ResourceFinderResource object.findResource in class ResourceFinderresourceName - Designates the resource; typically structured by slashes ("/") like
"com/foo/pkg/Bar.class"null if the resource could not be found@Nullable public Iterable<Resource> list(String resourceNamePrefix, boolean recurse)
ListableResourceFinder
If the prefix string ends with "/", you will get a proper directory listing (recurse=false)
or directory tree (recurse=true). Example:
resourceFinder.list("dir/", true) =>
dir/
dir/afile
dir/bfile
dir/adir/
dir/adir/file
dir/bdir/
dir/bdir/file
Otherwise, you will get a strange subset of a directory listing, resp. directory tree, as follows:
resourceFinder.list("dir/a", true) =>
dir/afile
dir/adir/
dir/adir/file
list in class ListableResourceFinderresourceNamePrefix - E.g. "" or "java/lang/"null iff
a location designated by the resourceNamePrefix does not existCopyright © 2023. All rights reserved.