1 | |
package org.apache.maven.archiva.dependency.graph.tasks; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.archiva.dependency.graph.DependencyGraph; |
23 | |
import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge; |
24 | |
import org.apache.maven.archiva.dependency.graph.DependencyGraphNode; |
25 | |
import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor; |
26 | |
import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class GraphCopier |
34 | |
extends BaseVisitor |
35 | |
implements DependencyGraphVisitor |
36 | |
{ |
37 | |
protected DependencyGraph copiedGraph; |
38 | |
|
39 | |
public DependencyGraph getGraph() |
40 | |
{ |
41 | 0 | return copiedGraph; |
42 | |
} |
43 | |
|
44 | |
public void setGraph( DependencyGraph graph ) |
45 | |
{ |
46 | 0 | this.copiedGraph = graph; |
47 | 0 | } |
48 | |
|
49 | |
public void discoverNode( DependencyGraphNode node ) |
50 | |
{ |
51 | 0 | if ( copiedGraph == null ) |
52 | |
{ |
53 | 0 | copiedGraph = new DependencyGraph( node ); |
54 | |
} |
55 | 0 | } |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
public void discoverEdge( DependencyGraphEdge edge ) |
62 | |
{ |
63 | 0 | copyEdge( edge ); |
64 | 0 | } |
65 | |
|
66 | |
public void copyEdge( DependencyGraphEdge edge ) |
67 | |
{ |
68 | 0 | DependencyGraphNode nodeFrom = graph.getNode( edge.getNodeFrom() ); |
69 | 0 | DependencyGraphNode nodeTo = graph.getNode( edge.getNodeTo() ); |
70 | |
|
71 | 0 | this.copiedGraph.addNode( nodeFrom ); |
72 | 0 | this.copiedGraph.addNode( nodeTo ); |
73 | 0 | this.copiedGraph.addEdge( edge ); |
74 | 0 | } |
75 | |
|
76 | |
public void reset() |
77 | |
{ |
78 | 0 | this.copiedGraph = null; |
79 | 0 | } |
80 | |
} |