org.apache.commons.io.file

## Class AccumulatorPathVisitor

- java.lang.Object
- - java.nio.file.SimpleFileVisitor<Path>
  - - org.apache.commons.io.file.SimplePathVisitor
    - - org.apache.commons.io.file.CountingPathVisitor
      - - org.apache.commons.io.file.AccumulatorPathVisitor

- All Implemented Interfaces:
    FileVisitor<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 Summary

    Constructors
    Constructor and Description
    `AccumulatorPathVisitor(Counters.PathCounters pathCounter)` Constructs a new instance.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `List<Path>` | `getDirList()` Gets the list of visited directories.
    `List<Path>` | `getFileList()` Gets the list of visited files.
    `int` | `hashCode()`
    `List<Path>` | `relativizeDirectories(Path parent, boolean sort, Comparator<? super Path> comparator)` Relativizes each directory path with `Path.relativize(Path)` against the given `parent`, optionally sorting the result.
    `List<Path>` | `relativizeFiles(Path parent, boolean sort, Comparator<? super Path> comparator)` Relativizes each file path with `Path.relativize(Path)` against the given `parent`, optionally sorting the result.
    `FileVisitResult` | `visitFile(Path file, BasicFileAttributes attributes)`
    `static AccumulatorPathVisitor` | `withBigIntegerCounters()` Creates a new instance configured with a BigInteger `Counters.PathCounters`.
    `static AccumulatorPathVisitor` | `withLongCounters()` Creates a new instance configured with a long `Counters.PathCounters`.

    - ### Methods inherited from class org.apache.commons.io.file.CountingPathVisitor

      `getPathCounters, postVisitDirectory, toString, updateFileCounters`

    - ### Methods inherited from class java.nio.file.SimpleFileVisitor

      `preVisitDirectory, visitFileFailed`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AccumulatorPathVisitor

          public AccumulatorPathVisitor(Counters.PathCounters pathCounter)

      Constructs a new instance.
      Parameters:
        `pathCounter` - How to count path visits.

  - ### Method Detail

    - #### withBigIntegerCounters

          public static AccumulatorPathVisitor withBigIntegerCounters()

      Creates a new instance configured with a BigInteger `Counters.PathCounters`.
      Returns:
        a new instance configured with a BigInteger `Counters.PathCounters`.

    - #### withLongCounters

          public static AccumulatorPathVisitor withLongCounters()

      Creates a new instance configured with a long `Counters.PathCounters`.
      Returns:
        a new instance configured with a long `Counters.PathCounters`.

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `CountingPathVisitor`

    - #### getDirList

          public List<Path> getDirList()

      Gets the list of visited directories.
      Returns:
        the list of visited directories.

    - #### getFileList

          public List<Path> getFileList()

      Gets the list of visited files.
      Returns:
        the list of visited files.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `CountingPathVisitor`

    - #### relativizeDirectories

          public List<Path> relativizeDirectories(Path parent,
                                                  boolean sort,
                                                  Comparator<? super 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 List<Path> relativizeFiles(Path parent,
                                            boolean sort,
                                            Comparator<? super 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 FileVisitResult visitFile(Path file,
                                           BasicFileAttributes attributes)
                                    throws IOException

      Specified by:
        `visitFile` in interface `FileVisitor<Path>`
      Overrides:
        `visitFile` in class `CountingPathVisitor`
      Throws:
        `IOException`

Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.