|
From: David K. <dav...@al...> - 2003-10-08 10:14:24
|
Hi people, I noticed that the filtering in DirectoryScanner, and the underlying ScannerWorker, was not actually implemented, and since I needed it I added some code that seems to work: ScannerWorker: - Added a private List of filters - Did the TODO in addFilter to feed the above List - Added a private method checkFilter(filter, string) - Added code to acceptEntry that checks the supplied string against the supplied filter and any already configured filters in the above List DirectoryScanner: - Added a private String for the (configured) filter - Added code to get the filter string if configured - Added code to acceptFile to use the configured filter and actually do some filtering using the code now in ScannerWorker The logic is: If no filter is specified and no filters are present in the List, the string matches, regardless. If filters are present, the string matches if it matches any of the filters. If a filter is also supplied in the method call, that filter is also checked, but only if it is not already present in the List. I have tested all changes and they seem to work, and they are fully backwards compatible, i.e no changes need to be done to existing configurations - they work as before. Example configuration snippet for a DirectoryScanner: <scanner-name>.filter=.*\.xml The above filter (obviously) matches files named *.xml and nothing else. It uses the regular expression support in the String class. So that might require 1.4-level Java support? Patch attached. Please review, and apply if correct && useful. Regards, David Kinnvall |