01: package org.umlgraph.doclet;
02:
03: import java.util.regex.Pattern;
04:
05: import com.sun.javadoc.ClassDoc;
06: import com.sun.javadoc.RootDoc;
07:
08: /**
09: * Matches every class that extends (directly or indirectly) a class
10: * matched by the regular expression provided.
11: */
12: public class SubclassMatcher implements ClassMatcher {
13:
14: protected RootDoc root;
15: protected Pattern pattern;
16:
17: public SubclassMatcher(RootDoc root, Pattern pattern) {
18: this .root = root;
19: this .pattern = pattern;
20: }
21:
22: public boolean matches(ClassDoc cd) {
23: // if it's the class we're looking for return
24: if (pattern.matcher(cd.toString()).matches())
25: return true;
26:
27: // recurse on supeclass, if available
28: if (cd.super class() != null)
29: return matches(cd.super class());
30:
31: return false;
32: }
33:
34: public boolean matches(String name) {
35: ClassDoc cd = root.classNamed(name);
36: if (cd == null)
37: return false;
38: return matches(cd);
39: }
40:
41: }
|