01: package org.umlgraph.doclet;
02:
03: import com.sun.javadoc.ClassDoc;
04: import com.sun.javadoc.PackageDoc;
05: import com.sun.javadoc.RootDoc;
06:
07: /**
08: * A view designed for UMLDoc, filters out everything that it's not contained in
09: * the specified package.
10: * <p>
11: * As such, can be viewed as a simplified version of a {@linkplain View} using a
12: * single {@linkplain ClassMatcher}, and provides some extra configuration such
13: * as output path configuration (and it is specified in code rather than in
14: * javadoc comments).
15: * @author wolf
16: *
17: */
18: public class PackageView implements OptionProvider {
19:
20: private PackageDoc pd;
21: private OptionProvider parent;
22: private ClassMatcher matcher;
23: private String outputPath;
24:
25: public PackageView(String outputFolder, PackageDoc pd,
26: RootDoc root, OptionProvider parent) {
27: this .parent = parent;
28: this .pd = pd;
29: this .matcher = new PackageMatcher(pd);
30: this .outputPath = pd.name().replace('.', '/') + "/" + pd.name()
31: + ".dot";
32: }
33:
34: public String getDisplayName() {
35: return "Package view for package " + pd;
36: }
37:
38: public Options getGlobalOptions() {
39: Options go = parent.getGlobalOptions();
40:
41: go.setOption(new String[] { "-output", outputPath });
42: go.setOption(new String[] { "-hide" });
43:
44: return go;
45: }
46:
47: public Options getOptionsFor(ClassDoc cd) {
48: Options go = parent.getGlobalOptions();
49: overrideForClass(go, cd);
50: return go;
51: }
52:
53: public Options getOptionsFor(String name) {
54: Options go = parent.getGlobalOptions();
55: overrideForClass(go, name);
56: return go;
57: }
58:
59: public void overrideForClass(Options opt, ClassDoc cd) {
60: opt.showQualified = false;
61: if (!matcher.matches(cd)
62: || parent.getGlobalOptions().matchesHideExpression(
63: cd.name()))
64: opt.setOption(new String[] { "-hide" });
65: }
66:
67: public void overrideForClass(Options opt, String className) {
68: opt.showQualified = false;
69: if (!matcher.matches(className))
70: opt.setOption(new String[] { "-hide" });
71: }
72:
73: }
|