Class AccumulatorPathVisitor

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

    public class AccumulatorPathVisitor
    extends CountingPathVisitor
    Accumulates normalized paths during visitation.

    Use with care on large file trees as each visited Path element is remembered.

    Since:
    2.7
    • Constructor Detail

      • AccumulatorPathVisitor

        public AccumulatorPathVisitor​(Counters.PathCounters pathCounter)
        Constructs a new instance.
        Parameters:
        pathCounter - How to count path visits.
    • Method Detail

      • getDirList

        public java.util.List<java.nio.file.Path> getDirList()
        Gets the list of visited directories.
        Returns:
        the list of visited directories.
      • getFileList

        public java.util.List<java.nio.file.Path> getFileList()
        Gets the list of visited files.
        Returns:
        the list of visited files.
      • relativizeDirectories

        public java.util.List<java.nio.file.Path> relativizeDirectories​(java.nio.file.Path parent,
                                                                        boolean sort,
                                                                        java.util.Comparator<? super java.nio.file.Path> comparator)
        Relativizes each directory path with Path.relativize(Path) against the given parent, optionally sorting the result.
        Parameters:
        parent - A parent path
        sort - Whether to sort
        comparator - How to sort, null uses default sorting.
        Returns:
        A new list
      • relativizeFiles

        public java.util.List<java.nio.file.Path> relativizeFiles​(java.nio.file.Path parent,
                                                                  boolean sort,
                                                                  java.util.Comparator<? super java.nio.file.Path> comparator)
        Relativizes each file path with Path.relativize(Path) against the given parent, optionally sorting the result.
        Parameters:
        parent - A parent path
        sort - Whether to sort
        comparator - How to sort, null uses default sorting.
        Returns:
        A new list
      • visitFile

        public java.nio.file.FileVisitResult visitFile​(java.nio.file.Path file,
                                                       java.nio.file.attribute.BasicFileAttributes attributes)
                                                throws java.io.IOException
        Specified by:
        visitFile in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Overrides:
        visitFile in class CountingPathVisitor
        Throws:
        java.io.IOException