public class FindFile
extends java.lang.Object
implements java.lang.Iterable<java.io.File>
WildcardFindFile
,
RegExpFindFile
,
InExRules
Modifier and Type | Class and Description |
---|---|
protected class |
FindFile.FilesIterator
Files iterator simply walks over files array.
|
static class |
FindFile.Match
Match type.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
includeDirs |
protected boolean |
includeFiles |
protected java.io.File |
lastFile |
protected FindFile.Match |
matchType |
protected java.util.LinkedList<java.io.File> |
pathList |
protected java.util.LinkedList<java.io.File> |
pathListOriginal |
protected boolean |
recursive |
protected java.io.File |
rootFile |
protected java.lang.String |
rootPath |
protected InExRules<java.lang.String,java.lang.String,?> |
rules |
protected java.util.List<java.util.Comparator<java.io.File>> |
sortComparators |
protected java.util.LinkedList<FindFile.FilesIterator> |
todoFiles |
protected java.util.LinkedList<java.io.File> |
todoFolders |
protected boolean |
walking |
Constructor and Description |
---|
FindFile() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptFile(java.io.File file)
Determine if file is accepted, based on include and exclude
rules.
|
protected void |
addComparator(java.util.Comparator<java.io.File> comparator) |
protected void |
addPath(java.io.File path)
Adds existing search path to the file list.
|
static FindFile |
create() |
static RegExpFindFile |
createRegExpFF() |
protected InExRules<java.lang.String,java.lang.String,?> |
createRulesEngine()
Creates rule engine.
|
static WildcardFindFile |
createWildcardFF() |
FindFile |
exclude(java.lang.String... patterns)
Defines exclude patterns.
|
FindFile |
exclude(java.lang.String pattern)
Defines exclude pattern.
|
FindFile |
excludeAll()
Enables whitelist mode.
|
java.util.List<java.io.File> |
findAll()
Finds all files and returns list of founded files.
|
protected java.lang.String |
getMatchingFilePath(java.io.File file)
Resolves file path depending on
matching type
Returned path is formatted in unix style. |
FindFile |
include(java.lang.String... patterns)
Defines include patterns.
|
FindFile |
include(java.lang.String pattern)
Defines include pattern.
|
FindFile |
includeAll()
Enables blacklist mode.
|
FindFile |
includeDirs(boolean includeDirs)
Include directories in search.
|
FindFile |
includeFiles(boolean includeFiles)
Include files in search.
|
protected void |
init()
Initializes file walking.
|
java.util.Iterator<java.io.File> |
iterator()
Returns file walking iterator.
|
java.io.File |
lastFile()
Returns last founded file.
|
FindFile |
matchFullPath() |
FindFile |
matchOnlyFileName() |
FindFile |
matchRelativePath() |
FindFile |
matchType(FindFile.Match match)
Set
matching type . |
java.io.File |
nextFile()
Finds the next file.
|
FindFile |
onFile(java.util.function.Consumer<java.io.File> fileConsumer)
Registers file consumer
|
FindFile |
recursive(boolean recursive)
Activates recursive search.
|
void |
reset()
Reset the search so it can be run again with very
same parameters (and sorting options).
|
FindFile |
searchPath(java.io.File... searchPath)
Specifies a set of search paths.
|
FindFile |
searchPath(java.io.File searchPath)
Specifies single search path.
|
FindFile |
searchPath(java.lang.String searchPath)
Specifies the search path.
|
FindFile |
searchPath(java.net.URI searchPath)
Specifies the search path.
|
FindFile |
searchPath(java.net.URL searchPath)
Specifies the search path.
|
FindFile |
searchPaths(java.lang.String... searchPaths)
Specifies search paths.
|
FindFile |
searchPaths(java.net.URI... searchPath)
Specifies the search path.
|
FindFile |
searchPaths(java.net.URL... searchPath)
Specifies the search path.
|
FindFile |
sortByExtension()
Sorts files by file extension.
|
FindFile |
sortByExtensionDesc()
Sorts files by file extension descending.
|
FindFile |
sortByName()
Sorts files by file name, using natural sort.
|
FindFile |
sortByNameDesc()
Sorts files by file names descending, using natural sort.
|
FindFile |
sortByTime()
Sorts files by last modified time.
|
FindFile |
sortByTimeDesc()
Sorts files by last modified time descending.
|
FindFile |
sortFoldersFirst()
Puts folders before files.
|
FindFile |
sortFoldersLast()
Puts files before folders.
|
FindFile |
sortNone()
Removes ALL sorting options.
|
FindFile |
sortWith(java.util.Comparator<java.io.File> fileComparator)
Adds generic sorting.
|
FindFile |
walking(boolean walking)
Sets the walking recursive mode.
|
protected boolean recursive
protected boolean includeDirs
protected boolean includeFiles
protected boolean walking
protected FindFile.Match matchType
protected final InExRules<java.lang.String,java.lang.String,?> rules
protected java.util.LinkedList<java.io.File> pathList
protected java.util.LinkedList<java.io.File> pathListOriginal
protected java.util.LinkedList<java.io.File> todoFolders
protected java.util.LinkedList<FindFile.FilesIterator> todoFiles
protected java.io.File lastFile
protected java.io.File rootFile
protected java.lang.String rootPath
protected java.util.List<java.util.Comparator<java.io.File>> sortComparators
public static WildcardFindFile createWildcardFF()
public static RegExpFindFile createRegExpFF()
public static FindFile create()
public FindFile recursive(boolean recursive)
public FindFile includeDirs(boolean includeDirs)
public FindFile includeFiles(boolean includeFiles)
public FindFile walking(boolean walking)
When walking mode is turned off, folders are processed once all files are processed, one after the other. The order is not natural, but memory consumption is optimal.
recursive(boolean)
public FindFile matchType(FindFile.Match match)
matching type
.public FindFile matchOnlyFileName()
public FindFile matchFullPath()
public FindFile matchRelativePath()
public FindFile onFile(java.util.function.Consumer<java.io.File> fileConsumer)
public FindFile searchPath(java.io.File searchPath)
public FindFile searchPath(java.io.File... searchPath)
public FindFile searchPath(java.lang.String searchPath)
File.pathSeparator
than string will be tokenized
and each part will be added separately as a search path.public FindFile searchPaths(java.lang.String... searchPaths)
searchPath(String)
public FindFile searchPath(java.net.URI searchPath)
public FindFile searchPaths(java.net.URI... searchPath)
public FindFile searchPath(java.net.URL searchPath)
public FindFile searchPaths(java.net.URL... searchPath)
protected InExRules<java.lang.String,java.lang.String,?> createRulesEngine()
public FindFile include(java.lang.String pattern)
public FindFile include(java.lang.String... patterns)
public FindFile excludeAll()
public FindFile includeAll()
public FindFile exclude(java.lang.String pattern)
public FindFile exclude(java.lang.String... patterns)
protected boolean acceptFile(java.io.File file)
true
if file passes search criteria.
File is matched using matching file path
.InExRules
protected java.lang.String getMatchingFilePath(java.io.File file)
matching type
Returned path is formatted in unix style.public java.io.File lastFile()
null
at the very beginning.protected void addPath(java.io.File path)
public void reset()
public java.io.File nextFile()
null
if no more files can be found.public java.util.List<java.io.File> findAll()
protected void init()
public java.util.Iterator<java.io.File> iterator()
iterator
in interface java.lang.Iterable<java.io.File>
protected void addComparator(java.util.Comparator<java.io.File> comparator)
public FindFile sortNone()
public FindFile sortWith(java.util.Comparator<java.io.File> fileComparator)
public FindFile sortFoldersFirst()
public FindFile sortFoldersLast()
public FindFile sortByName()
public FindFile sortByNameDesc()
public FindFile sortByExtension()
public FindFile sortByExtensionDesc()
public FindFile sortByTime()
public FindFile sortByTimeDesc()
Copyright © 2003-present Jodd Team