Class FileLookupHelper
- java.lang.Object
-
- net.stoerr.ai.aigenpipeline.framework.task.FileLookupHelper
-
public class FileLookupHelper extends Object
Makes it easy to find files to process withAIGenerationTasketc.
-
-
Field Summary
Fields Modifier and Type Field Description protected static PatternBINARYFILEPATTERNPattern matching file names of files which have binary content (*.jpg, *.gif, *.jar etc.), which we ignore in the search.protected Filedirectoryprotected static intFILE_MAXSIZEThe maximum filesize we search in.static StringHTML_PATTERNprotected static LoggerLOGprotected static PatternNOMETAPREFIXPATTERNA pattern matching a prefix of a file name that ends with a / and has no meta characters of theFileSystem.getPathMatcher(String)in it.
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileLookupHelper(String path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Filefile(String relpath)File relative to repository root - that doesn't need to exist (might be output file).List<File>files(String relpathDirectory, String filePathPattern, boolean recursive)Files in a directory, matching an ant style pattern - more specifically likeFileSystem.getPathMatcher(String)glob patterns (without "glob:" prefix).List<File>filesContaining(String relpathDirectory, String filePathPattern, Pattern pattern, boolean recursive)All files matching a filePathRegex that contain a pattern.static FileLookupHelperfromEnv(String envVar, String relativePath)Make repository from environment variable.static FileLookupHelperfromPath(String... relativePaths)FilejavaFile(String fullName)File from full java class name.FilejavaMdFile(String fullName)File for documenting a full java class name.
-
-
-
Field Detail
-
LOG
protected static final Logger LOG
-
HTML_PATTERN
public static final String HTML_PATTERN
- See Also:
- Constant Field Values
-
NOMETAPREFIXPATTERN
protected static final Pattern NOMETAPREFIXPATTERN
A pattern matching a prefix of a file name that ends with a / and has no meta characters of theFileSystem.getPathMatcher(String)in it.
-
FILE_MAXSIZE
protected static final int FILE_MAXSIZE
The maximum filesize we search in.- See Also:
- Constant Field Values
-
BINARYFILEPATTERN
protected static final Pattern BINARYFILEPATTERN
Pattern matching file names of files which have binary content (*.jpg, *.gif, *.jar etc.), which we ignore in the search.
-
directory
protected final File directory
-
-
Constructor Detail
-
FileLookupHelper
protected FileLookupHelper(String path)
-
-
Method Detail
-
fromPath
public static FileLookupHelper fromPath(String... relativePaths)
-
fromEnv
public static FileLookupHelper fromEnv(@Nonnull String envVar, @Nullable String relativePath)
Make repository from environment variable.
-
file
public File file(String relpath)
File relative to repository root - that doesn't need to exist (might be output file).
-
files
@Nonnull public List<File> files(@Nonnull String relpathDirectory, @Nullable String filePathPattern, boolean recursive)
Files in a directory, matching an ant style pattern - more specifically likeFileSystem.getPathMatcher(String)glob patterns (without "glob:" prefix).- Parameters:
relpathDirectory- the directory relative to the repository rootfilePathPattern- the file pattern to match, seeFileSystem.getPathMatcher(String)glob patternrecursive- whether to recurse into subdirectories- Returns:
- a list of files
- See Also:
FileSystem.getPathMatcher(String)
-
filesContaining
@Nonnull public List<File> filesContaining(@Nonnull String relpathDirectory, @Nonnull String filePathPattern, @Nonnull Pattern pattern, boolean recursive)
All files matching a filePathRegex that contain a pattern.- Parameters:
relpathDirectory- the directory relative to the repository rootfilePathPattern- the file pattern to matchpattern- the regex to look for in the file contentrecursive- whether to recurse into subdirectories- Returns:
- a list of files
-
-