Class DirectoryResourceFinder
- java.lang.Object
-
- org.codehaus.commons.compiler.util.resource.ResourceFinder
-
- org.codehaus.commons.compiler.util.resource.ListableResourceFinder
-
- org.codehaus.commons.compiler.util.resource.FileResourceFinder
-
- org.codehaus.commons.compiler.util.resource.DirectoryResourceFinder
-
public class DirectoryResourceFinder extends FileResourceFinder
AFileResourceFinder
that finds file resources in a directory. The name of the file is constructed by concatenating a dirctory name with the resource name such that slashes in the resource name map to file separators.
-
-
Field Summary
-
Fields inherited from class org.codehaus.commons.compiler.util.resource.ResourceFinder
EMPTY_RESOURCE_FINDER
-
-
Constructor Summary
Constructors Constructor Description DirectoryResourceFinder(java.io.File directory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.File
findResourceAsFile(java.lang.String resourceName)
Converts a given resource resource name into aFile
.java.lang.Iterable<Resource>
list(java.lang.String resourceNamePrefix, boolean recurse)
Returns all resources who's names start with a given string.java.lang.String
toString()
-
Methods inherited from class org.codehaus.commons.compiler.util.resource.FileResourceFinder
findResource
-
Methods inherited from class org.codehaus.commons.compiler.util.resource.ResourceFinder
findResourceAsStream
-
-
-
-
Method Detail
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
findResourceAsFile
@Nullable protected final java.io.File findResourceAsFile(java.lang.String resourceName)
Description copied from class:FileResourceFinder
Converts a given resource resource name into aFile
.- Specified by:
findResourceAsFile
in classFileResourceFinder
-
list
@Nullable public java.lang.Iterable<Resource> list(java.lang.String resourceNamePrefix, boolean recurse)
Description copied from class:ListableResourceFinder
Returns all resources who's names start with a given string. Only resources with a content are included, no "special entries" of any kind, e.g. directories.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
- Specified by:
list
in classListableResourceFinder
- Parameters:
resourceNamePrefix
- E.g.""
or"java/lang/"
- Returns:
- All resources who's name starts with the given prefix;
null
iff a location designated by the resourceNamePrefix does not exist
-
-