jodd.io.findfile
Class FindFile

java.lang.Object
  extended by jodd.io.findfile.FindFile
Direct Known Subclasses:
FilterFindFile, RegExpFindFile, WildcardFindFile

public class FindFile
extends java.lang.Object

Generic iterative file finder. Searches all files on specified search path.

See Also:
WildcardFindFile, RegExpFindFile, todo: Add sorting and comparators

Field Summary
protected  java.util.LinkedList<java.io.File> fileList
           
protected  boolean includeDirs
           
protected  boolean includeFiles
           
protected  boolean listSubfilesAfterFolder
           
protected  boolean recursive
           
 
Constructor Summary
FindFile()
           
 
Method Summary
protected  boolean acceptFile(java.io.File currentFile)
          Called on each file entry (file or directory) and returns true if file passes search criteria.
protected  void addSearchPath(java.io.File searchPath)
          Adds existing search path to the file list.
 boolean isIncludeDirs()
           
 boolean isIncludeFiles()
           
 boolean isListSubfilesAfterFolder()
           
 boolean isRecursive()
           
 java.util.Iterator<java.io.File> iterator()
          Returns file walker iterator.
protected  void listFiles(java.io.File directory)
          List all files and folders in specified directory.
 java.io.File nextFile()
          Finds the next file.
 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... searchPaths)
          Specifies search paths.
 FindFile searchPath(java.lang.String searchPath)
          Specifies the search path.
 FindFile searchPath(java.net.URI... 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 searchPath(java.net.URL searchPath)
          Specifies the search path.
 FindFile setIncludeDirs(boolean includeDirs)
          Include directories in search.
 FindFile setIncludeFiles(boolean includeFiles)
          Include files in search.
 FindFile setListSubfilesAfterFolder(boolean listSubfilesAfterFolder)
          If set to true then all subfiles of a folder will be listed directly after the folder, while folder will be listed first.
 FindFile setRecursive(boolean recursive)
          Activates recursive search.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recursive

protected boolean recursive

includeDirs

protected boolean includeDirs

includeFiles

protected boolean includeFiles

fileList

protected java.util.LinkedList<java.io.File> fileList

listSubfilesAfterFolder

protected boolean listSubfilesAfterFolder
Constructor Detail

FindFile

public FindFile()
Method Detail

isRecursive

public boolean isRecursive()

setRecursive

public FindFile setRecursive(boolean recursive)
Activates recursive search.


isIncludeDirs

public boolean isIncludeDirs()

setIncludeDirs

public FindFile setIncludeDirs(boolean includeDirs)
Include directories in search.


isIncludeFiles

public boolean isIncludeFiles()

setIncludeFiles

public FindFile setIncludeFiles(boolean includeFiles)
Include files in search.


addSearchPath

protected void addSearchPath(java.io.File searchPath)
Adds existing search path to the file list. If path is a folder, it will be scanned for all files.


searchPath

public FindFile searchPath(java.io.File searchPath)
Specifies single search path.


searchPath

public FindFile searchPath(java.io.File... searchPath)
Specifies a set of search paths.


searchPath

public FindFile searchPath(java.lang.String searchPath)
Specifies the search path. If provided path contains File.pathSeparator than string will be tokenized and each part will be added separately as a search path.


searchPath

public FindFile searchPath(java.lang.String... searchPaths)
Specifies search paths.

See Also:
searchPath(String)

searchPath

public FindFile searchPath(java.net.URI searchPath)
Specifies the search path. Throws an exception if URI is invalid.


searchPath

public FindFile searchPath(java.net.URI... searchPath)
Specifies the search path.


searchPath

public FindFile searchPath(java.net.URL searchPath)
Specifies the search path. Throws an exception if URL is invalid.


searchPath

public FindFile searchPath(java.net.URL... searchPath)
Specifies the search path.


isListSubfilesAfterFolder

public boolean isListSubfilesAfterFolder()

setListSubfilesAfterFolder

public FindFile setListSubfilesAfterFolder(boolean listSubfilesAfterFolder)
If set to true then all subfiles of a folder will be listed directly after the folder, while folder will be listed first. Otherwise, sub files will be listed after the all files of current folder.


nextFile

public java.io.File nextFile()
Finds the next file. Returns founded file that matches search configuration or null if no more files can be found.


iterator

public java.util.Iterator<java.io.File> iterator()
Returns file walker iterator.


listFiles

protected void listFiles(java.io.File directory)
List all files and folders in specified directory. All folders are added to the list (because of possible recursion). Opposite, files are filtered first and added if matched.


acceptFile

protected boolean acceptFile(java.io.File currentFile)
Called on each file entry (file or directory) and returns true if file passes search criteria.



Copyright © 2003-2012 Jodd Team