Package 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>
Accumulates normalized paths during visitation.
Use with care on large file trees as each visited Path element is remembered.
- Since:
- 2.7
-
Constructor Summary
ConstructorsConstructorDescriptionAccumulatorPathVisitor
(Counters.PathCounters pathCounter) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Gets the list of visited directories.Gets the list of visited files.int
hashCode()
relativizeDirectories
(Path parent, boolean sort, Comparator<? super Path> comparator) Relativizes each directory path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.relativizeFiles
(Path parent, boolean sort, Comparator<? super Path> comparator) Relativizes each file path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.visitFile
(Path file, BasicFileAttributes attributes) static AccumulatorPathVisitor
Creates a new instance configured with a BigIntegerCounters.PathCounters
.static AccumulatorPathVisitor
Creates a new instance configured with a longCounters.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
-
Constructor Details
-
AccumulatorPathVisitor
Constructs a new instance.- Parameters:
pathCounter
- How to count path visits.
-
-
Method Details
-
withBigIntegerCounters
Creates a new instance configured with a BigIntegerCounters.PathCounters
.- Returns:
- a new instance configured with a BigInteger
Counters.PathCounters
.
-
withLongCounters
Creates a new instance configured with a longCounters.PathCounters
.- Returns:
- a new instance configured with a long
Counters.PathCounters
.
-
equals
- Overrides:
equals
in classCountingPathVisitor
-
getDirList
Gets the list of visited directories.- Returns:
- the list of visited directories.
-
getFileList
Gets the list of visited files.- Returns:
- the list of visited files.
-
hashCode
- Overrides:
hashCode
in classCountingPathVisitor
-
relativizeDirectories
public List<Path> relativizeDirectories(Path parent, boolean sort, Comparator<? super Path> comparator) Relativizes each directory path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.- Parameters:
parent
- A parent pathsort
- Whether to sortcomparator
- How to sort, null uses default sorting.- Returns:
- A new list
-
relativizeFiles
Relativizes each file path withPath.relativize(Path)
against the givenparent
, optionally sorting the result.- Parameters:
parent
- A parent pathsort
- Whether to sortcomparator
- How to sort, null uses default sorting.- Returns:
- A new list
-
visitFile
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classCountingPathVisitor
- Throws:
IOException
-