FindFilterpublic class FindFilter extends Object implements FilenameFilterClass to encapsulate the filtration for Find.
For now just setTTTFilter() methods. Really needs to be a real
data structure to allow complex things like
-n "*.html" -a \( -size < 0 -o mtime < 5 \). |
Fields Summary |
---|
boolean | sizeSet | int | size | String | name | RE | nameRE |
Constructors Summary |
---|
public FindFilter()
|
Methods Summary |
---|
public boolean | accept(java.io.File dir, java.lang.String fileName)Do the filtering. For now, only filter on name
File f = new File(dir, fileName);
if (f.isDirectory()) {
return true; // allow recursion
}
if (name != null) {
return nameRE.match(fileName);
}
// TODO size handling.
// Catchall
return false;
| void | setNameFilter(java.lang.String nameFilter)Convert the given shell wildcard pattern into internal form (an RE)
name = nameFilter;
StringBuffer sb = new StringBuffer('^");
for (int i = 0; i < nameFilter.length(); i++) {
char c = nameFilter.charAt(i);
switch(c) {
case '.": sb.append("\\."); break;
case '*": sb.append(".*"); break;
case '?": sb.append('."); break;
default: sb.append(c); break;
}
}
sb.append('$");
Debug.println("name", "RE=\"" + sb + "\".");
try {
nameRE = new RE(sb.toString());
} catch (RESyntaxException ex) {
System.err.println("For shame! " + ex);
}
| void | setSizeFilter(java.lang.String sizeFilter)
size = Integer.parseInt(sizeFilter);
sizeSet = true;
|
|