View Javadoc

1   package org.apache.maven.archiva.dependency.graph.walk;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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.model.ArtifactReference;
26  
27  import java.util.ArrayList;
28  import java.util.List;
29  
30  class WalkCollector
31      implements DependencyGraphVisitor
32  {
33      private List<String> walkPath = new ArrayList<String>();
34  
35      private int countDiscoverGraph = 0;
36  
37      private int countFinishGraph = 0;
38  
39      private int countDiscoverNode = 0;
40  
41      private int countFinishNode = 0;
42  
43      private int countDiscoverEdge = 0;
44  
45      private int countFinishEdge = 0;
46  
47      public void discoverEdge( DependencyGraphEdge edge )
48      {
49          countDiscoverEdge++;
50      }
51  
52      public void discoverGraph( DependencyGraph graph )
53      {
54          countDiscoverGraph++;
55      }
56  
57      public void discoverNode( DependencyGraphNode node )
58      {
59          countDiscoverNode++;
60          walkPath.add( ArtifactReference.toKey( node.getArtifact() ) );
61      }
62  
63      public void finishEdge( DependencyGraphEdge edge )
64      {
65          countFinishEdge++;
66      }
67  
68      public void finishGraph( DependencyGraph graph )
69      {
70          countFinishGraph++;
71      }
72  
73      public void finishNode( DependencyGraphNode node )
74      {
75          countFinishNode++;
76      }
77  
78      public List<String> getCollectedPath()
79      {
80          return walkPath;
81      }
82  
83      public int getCountDiscoverEdge()
84      {
85          return countDiscoverEdge;
86      }
87  
88      public int getCountDiscoverGraph()
89      {
90          return countDiscoverGraph;
91      }
92  
93      public int getCountDiscoverNode()
94      {
95          return countDiscoverNode;
96      }
97  
98      public int getCountFinishEdge()
99      {
100         return countFinishEdge;
101     }
102 
103     public int getCountFinishGraph()
104     {
105         return countFinishGraph;
106     }
107 
108     public int getCountFinishNode()
109     {
110         return countFinishNode;
111     }
112 
113 }