com.sibvisions.util
Class FileSearch

java.lang.Object
  extended by com.sibvisions.util.FileSearch

public class FileSearch
extends Object

The FileSearch is a utility class to search files and directories.


Constructor Summary
FileSearch()
          Creates a new instance of FileSearch.
 
Method Summary
 void clear()
          Clear previous search results.
 Hashtable<String,List<String>> getFilesPerDirectory()
          Gets a list of found files per found directory.
 List<String> getFoundDirectories()
          Gets the found directories of a previous search.
 List<String> getFoundFiles()
          Gets the found files of a previous search.
 Set<String> getHierarchicalDirectoryList()
          Gets the hierarchial directory tree as flat list: directory-1 |- sub-1.1 |- sub-1.2 |- sub-1.3 | |- sub 1.3.1 | |- sub 1.3.2 |- sub 1.4 will return a list with following elements: directory-1 sub-1.1 sub-1.2 sub-1.3 sub-1.3.1 sub-1.3.2 sub-1.4 .
 void search(File pAnalyse, boolean pDeepSearch, String... pPathPattern)
          Searches files and directories.
 void search(String pAnalyse, boolean pDeepSearch, String... pPathPattern)
          Searches files and directories.
static File searchFirstFile(File pSource, String... pPattern)
          Searches the first file which fits the given pattern(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSearch

public FileSearch()
Creates a new instance of FileSearch.

Method Detail

search

public void search(String pAnalyse,
                   boolean pDeepSearch,
                   String... pPathPattern)
Searches files and directories. The result will be appended to previous search results.

Parameters:
pAnalyse - the start directory/file
pDeepSearch - true to search files and directories recursive (include subdirectories)
pPathPattern - a list of path patterns (regular expression) or null if all files are valid. If the first character is ! then the pattern is an exclude pattern (all except...). Directories end with a /, e.g. a directory pattern */.
See Also:
clear()

search

public void search(File pAnalyse,
                   boolean pDeepSearch,
                   String... pPathPattern)
Searches files and directories. The result will be appended to previous search results.

Parameters:
pAnalyse - the start directory/file
pDeepSearch - true to search files and directories recursive (include subdirectories)
pPathPattern - a list of path patterns (regular expression) or null if all files are valid. If the first character is ! then the pattern is an exclude pattern (all except...). Directories end with a /, e.g. a directory pattern */.
See Also:
clear()

clear

public void clear()
Clear previous search results.


getFoundFiles

public List<String> getFoundFiles()
Gets the found files of a previous search.

Returns:
the absolute path for all found files

getFoundDirectories

public List<String> getFoundDirectories()
Gets the found directories of a previous search.

Returns:
the absolute path for all found directories

getFilesPerDirectory

public Hashtable<String,List<String>> getFilesPerDirectory()
Gets a list of found files per found directory.

Returns:
the absolute path for all files per directory (also as absolute path)

getHierarchicalDirectoryList

public Set<String> getHierarchicalDirectoryList()
Gets the hierarchial directory tree as flat list:
 directory-1
 |- sub-1.1
 |- sub-1.2
 |- sub-1.3
 |  |- sub 1.3.1
 |  |- sub 1.3.2
 |- sub 1.4
 
 will return a list with following elements:
 
 directory-1
 sub-1.1
 sub-1.2
 sub-1.3
 sub-1.3.1
 sub-1.3.2
 sub-1.4
 
.

Returns:
a flat list of a hierarchical directory tree

searchFirstFile

public static File searchFirstFile(File pSource,
                                   String... pPattern)
Searches the first file which fits the given pattern(s).

Parameters:
pSource - the start directory
pPattern - the file pattern(s). If a pattern starts with ! then the pattern is an exclude pattern
Returns:
the found file or null if no file was found


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.