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
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class org.apache.commons.io.file.CountingPathVisitor
EMPTY_STRING_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionAccumulatorPathVisitor(Counters.PathCounters pathCounter) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the list of visited directories.Gets the list of visited files.inthashCode()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 AccumulatorPathVisitorCreates a new instance configured with a BigIntegerCounters.PathCounters.static AccumulatorPathVisitorCreates a new instance configured with a longCounters.PathCounters.Methods inherited from class org.apache.commons.io.file.CountingPathVisitor
getPathCounters, postVisitDirectory, toString, updateFileCountersMethods inherited from class java.nio.file.SimpleFileVisitor
preVisitDirectory, visitFileFailed
-
Field Details
-
dirList
-
fileList
-
-
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:
equalsin 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
public int hashCode()- Overrides:
hashCodein 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:
visitFilein interfaceFileVisitor<Path>- Overrides:
visitFilein classCountingPathVisitor- Throws:
IOException
-