java.lang.Object
com.aoapps.hodgepodge.io.FilesystemIterator
- All Implemented Interfaces:
Comparable<FilesystemIterator>
Iterates through all of the files in a file system.
- Author:
- AO Industries, Inc.
-
Constructor Summary
ConstructorDescriptionFilesystemIterator
(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules) Constructs an iterator without any filename conversions and starting at all roots.FilesystemIterator
(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules, boolean isPreorder, boolean isSorted) Constructs an iterator without any filename conversions and starting at all roots.FilesystemIterator
(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules, String startPath) Constructs a file system iterator with the provided rules and conversion.FilesystemIterator
(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules, String startPath, boolean isPreorder, boolean isSorted) Constructs a file system iterator with the provided rules and conversion. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(FilesystemIterator other) Gets an iterator of filenames.protected String[]
Gets the file system roots.Gets the next file from the iterator ornull
if the iterator has completed the iteration of the file system.int
getNextFiles
(File[] files, int batchSize) Gets the next files, up to batchSize.Gets the start path for this iterator.protected boolean
isFilesystemRoot
(String filename) Determines if a path is a possible file system root.boolean
Gets the preorder flag for this iterator.boolean
isSorted()
Gets the sort flag for this iterator.
-
Constructor Details
-
FilesystemIterator
public FilesystemIterator(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules) Constructs an iterator without any filename conversions and starting at all roots. Performs a preorder traversal - directory before directory contents. The directories are sorted.- See Also:
-
FilesystemIterator
public FilesystemIterator(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules, boolean isPreorder, boolean isSorted) Constructs an iterator without any filename conversions and starting at all roots.- See Also:
-
FilesystemIterator
public FilesystemIterator(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules, String startPath) Constructs a file system iterator with the provided rules and conversion. Performs a preorder traversal - directory before directory contents. The directories are sorted.- See Also:
-
FilesystemIterator
public FilesystemIterator(Map<String, FilesystemIteratorRule> rules, Map<String, FilesystemIteratorRule> prefixRules, String startPath, boolean isPreorder, boolean isSorted) Constructs a file system iterator with the provided rules and conversion.- Parameters:
rules
- the rules that will be applied during iterationstartPath
- if "", all roots will be used, otherwise starts at the provided path
-
-
Method Details
-
getNextFile
Gets the next file from the iterator ornull
if the iterator has completed the iteration of the file system. This method is internally synchronized and is thread-safe.- Throws:
IOException
-
getNextFiles
Gets the next files, up to batchSize.- Returns:
- the number of files in the array, zero (0) indicates iteration has completed
- Throws:
IOException
-
getFilesystemRoots
Gets the file system roots. It will only include the root if it has at least one backup-enabled rule. An empty rule ("") will implicitly allow all roots.- Throws:
IOException
-
isFilesystemRoot
Determines if a path is a possible file system root.- Throws:
IOException
-
getFilenameIterator
Gets an iterator of filenames.- Throws:
IOException
-
getStartPath
Gets the start path for this iterator. -
isPreorder
public boolean isPreorder()Gets the preorder flag for this iterator. -
isSorted
public boolean isSorted()Gets the sort flag for this iterator. -
compareTo
- Specified by:
compareTo
in interfaceComparable<FilesystemIterator>
-