Package org.apache.commons.io.file
Class CountingPathVisitor
java.lang.Object
java.nio.file.SimpleFileVisitor<Path>
org.apache.commons.io.file.SimplePathVisitor
org.apache.commons.io.file.CountingPathVisitor
- All Implemented Interfaces:
FileVisitor<Path>
,PathVisitor
- Direct Known Subclasses:
AccumulatorPathVisitor
,CleaningPathVisitor
,CopyDirectoryVisitor
,DeletingPathVisitor
Counts files, directories, and sizes, as a visit proceeds.
- Since:
- 2.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builds instances ofCountingPathVisitor
.static class
Builds instances ofCountingPathVisitor
. -
Constructor Summary
ConstructorsConstructorDescriptionCountingPathVisitor
(Counters.PathCounters pathCounters) Constructs a new instance.CountingPathVisitor
(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter) Constructs a new instance.CountingPathVisitor
(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter, IOBiFunction<Path, IOException, FileVisitResult> visitFileFailed) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Gets the visitation counts.int
hashCode()
postVisitDirectory
(Path dir, IOException exc) preVisitDirectory
(Path dir, BasicFileAttributes attributes) toString()
protected void
updateDirCounter
(Path dir, IOException exc) Updates the counter for visiting the given directory.protected void
updateFileCounters
(Path file, BasicFileAttributes attributes) Updates the counters for visiting the given file.visitFile
(Path file, BasicFileAttributes attributes) static CountingPathVisitor
Constructs a new instance configured with aBigInteger
Counters.PathCounters
.static CountingPathVisitor
Constructs a new instance configured with along
Counters.PathCounters
.Methods inherited from class org.apache.commons.io.file.SimplePathVisitor
visitFileFailed
-
Constructor Details
-
CountingPathVisitor
Constructs a new instance.- Parameters:
pathCounters
- How to count path visits.- See Also:
-
CountingPathVisitor
public CountingPathVisitor(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter) Constructs a new instance.- Parameters:
pathCounters
- How to count path visits.fileFilter
- Filters which files to count.directoryFilter
- Filters which directories to count.- Since:
- 2.9.0
- See Also:
-
CountingPathVisitor
@Deprecated public CountingPathVisitor(Counters.PathCounters pathCounters, PathFilter fileFilter, PathFilter directoryFilter, IOBiFunction<Path, IOException, FileVisitResult> visitFileFailed) Deprecated.Constructs a new instance.- Parameters:
pathCounters
- How to count path visits.fileFilter
- Filters which files to count.directoryFilter
- Filters which directories to count.visitFileFailed
- Called onSimplePathVisitor.visitFileFailed(Path, IOException)
.- Since:
- 2.12.0
-
-
Method Details
-
withBigIntegerCounters
Constructs a new instance configured with aBigInteger
Counters.PathCounters
.- Returns:
- a new instance configured with a
BigInteger
Counters.PathCounters
.
-
withLongCounters
Constructs a new instance configured with along
Counters.PathCounters
.- Returns:
- a new instance configured with a
long
Counters.PathCounters
.
-
equals
-
getPathCounters
Gets the visitation counts.- Returns:
- the visitation counts.
-
hashCode
-
postVisitDirectory
- Specified by:
postVisitDirectory
in interfaceFileVisitor<Path>
- Overrides:
postVisitDirectory
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException - Specified by:
preVisitDirectory
in interfaceFileVisitor<Path>
- Overrides:
preVisitDirectory
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
toString
-
updateDirCounter
Updates the counter for visiting the given directory.- Parameters:
dir
- the visited directory.exc
- Encountered exception.- Since:
- 2.9.0
-
updateFileCounters
Updates the counters for visiting the given file.- Parameters:
file
- the visited file.attributes
- the visited file attributes.
-
visitFile
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
CountingPathVisitor.Builder
.