-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathSubclassMatcher.java
More file actions
35 lines (27 loc) · 879 Bytes
/
SubclassMatcher.java
File metadata and controls
35 lines (27 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.umlgraph.doclet;
import java.util.regex.Pattern;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.RootDoc;
/**
* Matches every class that extends (directly or indirectly) a class
* matched by the regular expression provided.
*/
public class SubclassMatcher implements ClassMatcher {
protected RootDoc root;
protected Pattern pattern;
public SubclassMatcher(RootDoc root, Pattern pattern) {
this.root = root;
this.pattern = pattern;
}
public boolean matches(ClassDoc cd) {
// if it's the class we're looking for return
if(pattern.matcher(cd.toString()).matches())
return true;
// recurse on supeclass, if available
return cd.superclass() == null ? false : matches(cd.superclass());
}
public boolean matches(String name) {
ClassDoc cd = root.classNamed(name);
return cd == null ? false : matches(cd);
}
}