Class DefaultDocumentFileReader

  • All Implemented Interfaces:
    DocumentFileReader, java.nio.file.FileVisitor<java.nio.file.Path>

    public class DefaultDocumentFileReader
    extends AbstractDocumentFileReader
    implements java.nio.file.FileVisitor<java.nio.file.Path>, DocumentFileReader
    Non-threadsafe implementation that implements FileVisitor as a way of descending one or more file paths.
    • Constructor Detail

      • DefaultDocumentFileReader

        public DefaultDocumentFileReader()
        Calls initialize to instantiate some default DocumentFileProcessor objects.
    • Method Detail

      • readDocumentFiles

        public java.util.List<DocumentFile> readDocumentFiles​(java.lang.String... paths)
        Walk the file tree at each of the given paths, applying any configured DocumentFileProcessor instances on each DocumentFile that is constructed by a File.
        Specified by:
        readDocumentFiles in interface DocumentFileReader
        Parameters:
        paths -
        Returns:
        list of DocumentFile objects in the given paths
      • constructPath

        protected java.nio.file.Path constructPath​(java.lang.String path)
        The path is first wrapped in a File; this prevents a bug in Gradle when Gradle is run in daemon mode, where it will try to resolve the path from its daemon directory.
        Parameters:
        path -
        Returns:
        a Path object based on the given string path
      • preVisitDirectory

        public java.nio.file.FileVisitResult preVisitDirectory​(java.nio.file.Path dir,
                                                               java.nio.file.attribute.BasicFileAttributes attrs)
                                                        throws java.io.IOException
        Specified by:
        preVisitDirectory in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Throws:
        java.io.IOException
      • visitFileFailed

        public java.nio.file.FileVisitResult visitFileFailed​(java.nio.file.Path file,
                                                             java.io.IOException exc)
                                                      throws java.io.IOException
        Specified by:
        visitFileFailed in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Throws:
        java.io.IOException
      • postVisitDirectory

        public java.nio.file.FileVisitResult postVisitDirectory​(java.nio.file.Path dir,
                                                                java.io.IOException exc)
                                                         throws java.io.IOException
        Specified by:
        postVisitDirectory in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Throws:
        java.io.IOException
      • visitFile

        public java.nio.file.FileVisitResult visitFile​(java.nio.file.Path path,
                                                       java.nio.file.attribute.BasicFileAttributes attrs)
                                                throws java.io.IOException
        Specified by:
        visitFile in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Throws:
        java.io.IOException
      • acceptPath

        protected boolean acceptPath​(java.nio.file.Path path,
                                     java.nio.file.attribute.BasicFileAttributes attrs)
        Parameters:
        path -
        attrs -
        Returns:
        false if any of the configured FileFilter objects do not accept the Path, else true
      • buildDocumentFile

        protected DocumentFile buildDocumentFile​(java.nio.file.Path path,
                                                 java.nio.file.Path currentRootPath)
      • initialize

        protected void initialize()
      • addFileFilter

        public void addFileFilter​(java.io.FileFilter fileFilter)
      • getFileFilters

        public java.util.List<java.io.FileFilter> getFileFilters()
      • setFileFilters

        public void setFileFilters​(java.util.List<java.io.FileFilter> fileFilters)
      • setUriPrefix

        public void setUriPrefix​(java.lang.String uriPrefix)