01: package tijmp.filter;
02:
03: import tijmp.ui.Translator;
04:
05: /** A filter that only matches classes in a given package.
06: */
07: public class PackageFilter implements Filter {
08: private String pkg;
09:
10: public PackageFilter(String pkg) {
11: if (!pkg.endsWith("."))
12: pkg += ".";
13: this .pkg = pkg;
14: }
15:
16: public boolean accept(Class<?> c) {
17: String n = Translator.translate(c);
18: if (!n.startsWith(pkg))
19: return false;
20: int l = pkg.length() + 1;
21: if (n.length() <= l)
22: return false;
23: return n.indexOf('.', l) == -1;
24: }
25: }
|