1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.dependency.tree;
20
21 import java.io.Writer;
22 import java.util.List;
23
24 import org.apache.maven.shared.dependency.graph.DependencyNode;
25 import org.apache.maven.shared.dependency.graph.traversal.DependencyNodeVisitor;
26
27
28
29
30
31
32
33
34 public class DOTDependencyNodeVisitor extends AbstractSerializingVisitor implements DependencyNodeVisitor {
35
36
37
38
39
40
41 public DOTDependencyNodeVisitor(Writer writer) {
42 super(writer);
43 }
44
45
46
47
48 @Override
49 public boolean visit(DependencyNode node) {
50 if (node.getParent() == null || node.getParent() == node) {
51 writer.write("digraph \"" + node.toNodeString() + "\" { " + System.lineSeparator());
52 }
53
54
55
56 List<DependencyNode> children = node.getChildren();
57
58 for (DependencyNode child : children) {
59 writer.println("\t\"" + node.toNodeString() + "\" -> \"" + child.toNodeString() + "\" ; ");
60 }
61
62 return true;
63 }
64
65
66
67
68 @Override
69 public boolean endVisit(DependencyNode node) {
70 if (node.getParent() == null || node.getParent() == node) {
71 writer.write(" } ");
72 }
73 return true;
74 }
75 }