Class MapResourceFinder
- java.lang.Object
-
- org.codehaus.commons.compiler.util.resource.ResourceFinder
-
- org.codehaus.commons.compiler.util.resource.ListableResourceFinder
-
- org.codehaus.commons.compiler.util.resource.MapResourceFinder
-
public class MapResourceFinder extends ListableResourceFinder
AResourceFinder
that provides access to resource stored as byte arrays in aMap
.
-
-
Field Summary
-
Fields inherited from class org.codehaus.commons.compiler.util.resource.ResourceFinder
EMPTY_RESOURCE_FINDER
-
-
Constructor Summary
Constructors Constructor Description MapResourceFinder()
MapResourceFinder(Map<String,byte[]> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
addResource(String fileName, byte[] data)
Adds anotherResource
, so that it can later be found withfindResource(String)
,ResourceFinder.findResourceAsStream(String)
andresources()
.Resource
addResource(String fileName, String data)
Resource
addResource(Resource resource)
Adds anotherResource
, so that it can later be found withfindResource(String)
,ResourceFinder.findResourceAsStream(String)
andresources()
.Resource
findResource(String resourceName)
Finds a resource by name and return it as aResource
object.Iterable<Resource>
list(String resourceNamePrefix, boolean recurse)
Collection<Resource>
resources()
void
setLastModified(long lastModified)
-
Methods inherited from class org.codehaus.commons.compiler.util.resource.ResourceFinder
findResourceAsStream
-
-
-
-
Method Detail
-
addResource
@Nullable public Resource addResource(String fileName, byte[] data)
Adds anotherResource
, so that it can later be found withfindResource(String)
,ResourceFinder.findResourceAsStream(String)
andresources()
.- Returns:
- The resource that was previously associated with the fileName, or
null
-
addResource
@Nullable public Resource addResource(String fileName, String data)
- Parameters:
data
- The text to store (in platform default encoding)- Returns:
- The resource that was previously associated with the fileName, or
null
-
addResource
public Resource addResource(Resource resource)
Adds anotherResource
, so that it can later be found withfindResource(String)
,ResourceFinder.findResourceAsStream(String)
andresources()
.- Returns:
- The resource that was previously associated with the fileName, or
null
-
resources
public Collection<Resource> resources()
- Returns:
- All resources that were previously added with
addResource(Resource)
-
setLastModified
public final void setLastModified(long lastModified)
- Parameters:
lastModified
- The return value ofResource.lastModified()
for the next resources added
-
findResource
@Nullable public final Resource findResource(String resourceName)
Description copied from class:ResourceFinder
Finds a resource by name and return it as aResource
object.- Specified by:
findResource
in classResourceFinder
- Parameters:
resourceName
- Designates the resource; typically structured by slashes ("/") like "com/foo/pkg/Bar.class
"- Returns:
null
if the resource could not be found
-
-