Class FileLookupHelper


  • public class FileLookupHelper
    extends Object
    Makes it easy to find files to process with AIGenerationTask etc.
    • Field Detail

      • LOG

        protected static final Logger LOG
      • 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 the FileSystem.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

      • 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).
      • 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 root
        filePathPattern - the file pattern to match
        pattern - the regex to look for in the file content
        recursive - whether to recurse into subdirectories
        Returns:
        a list of files
      • javaFile

        @Nonnull
        public File javaFile​(@Nonnull
                             String fullName)
        File from full java class name.
      • javaMdFile

        @Nonnull
        public File javaMdFile​(@Nonnull
                               String fullName)
        File for documenting a full java class name.