Methods Summary |
---|
protected java.lang.String[] | extractPatterns(java.lang.String pattern)
return StringUtil.current().parts( pattern, PATTERN_SEPARATOR ) ;
|
protected java.lang.Character | getDigitWildcard()
return digitWildcard ;
|
protected char | getDigitWildcardChar()
if ( this.hasDigitWildcard() )
return this.getDigitWildcard().charValue() ;
else
return '\0" ;
|
protected FileHandler | getFileHandler()
return fileHandler ;
|
protected boolean | getGoOn()
return goOn ;
|
protected boolean | hasDigitWildcard()
return this.getDigitWildcard() != null ;
|
protected void | setDigitWildcard(java.lang.Character newValue) digitWildcard = newValue ;
|
public void | setDigitWildcardChar(char digitWildcard)Sets the given character as a wildcard character to match
digits ('0'-'9') only.
if ( digitWildcard <= 0 )
{
this.setDigitWildcard( null ) ;
}
else
{
this.setDigitWildcard( new Character( digitWildcard ) ) ;
}
|
protected void | setFileHandler(FileHandler newValue) fileHandler = newValue ;
|
protected void | setGoOn(boolean newValue) goOn = newValue ;
|
protected long | walkThrough(java.lang.String dir, java.io.FilenameFilter filter, boolean recursive)
long counter = 0 ;
File directory = null ;
File file = null ;
File[] files = null ;
int index = 0 ;
directory = new File( dir ) ;
files = directory.listFiles( filter ) ;
if ( files == null ) // BUGFIX suggested by Kyle Gossman
return counter ;
this.setGoOn( this.getFileHandler().directoryStart( directory, files.length ) ) ;
if ( ! this.getGoOn() )
return counter ;
for ( index = 0 ; index < files.length ; index++ )
{
file = files[index] ;
if ( file.isDirectory() )
{
if ( recursive )
{
counter += this.walkThrough( file.getPath(), filter, recursive ) ;
}
}
else
{
this.setGoOn( this.getFileHandler().handleFile( file ) ) ;
counter++ ;
}
if ( ! this.getGoOn() )
break ;
} // for
this.setGoOn( this.getFileHandler().directoryEnd( directory ) ) ;
return counter ;
|
public long | walkThrough(java.lang.String dir, java.lang.String pattern, boolean recursive)This method starts in the given directory to search for all files
matching the given pattern(s).
There can be more than one pattern in the pattern parameter. They have
to be separated by the PATTERN_SEPARATOR (';').
If recursive is true it goes down to each subdirectory and doing
the same there.
For each matching file (non-directory) the defined FileHandler.handle()
is called.
ExtendedFileFilter filter = null ;
String[] patterns = null ;
String strPattern ;
this.setGoOn( true ) ;
filter = new ExtendedFileFilter() ;
patterns = this.extractPatterns( pattern ) ;
for (int i = 0; i < patterns.length; i++)
{
strPattern = patterns[i] ;
if ( this.hasDigitWildcard() )
{
filter.addPattern( strPattern, true, this.getDigitWildcardChar() ) ;
}
else
{
filter.addPattern( strPattern, true ) ;
}
}
if ( recursive )
filter.alwaysIncludeDirectories() ;
else
filter.alwaysExcludeDirectories() ;
return this.walkThrough( dir, filter, recursive ) ;
|