Coverage Report - org.apache.maven.archiva.dependency.graph.tasks.UpdateScopesVisitor
 
Classes in this File Line Coverage Branch Coverage Complexity
UpdateScopesVisitor
0%
0/17
0%
0/2
0
 
 1  
 package org.apache.maven.archiva.dependency.graph.tasks;
 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.commons.collections.Predicate;
 23  
 import org.apache.maven.archiva.dependency.graph.DependencyGraph;
 24  
 import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
 25  
 import org.apache.maven.archiva.dependency.graph.functors.EdgeFromPredicate;
 26  
 import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
 27  
 import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
 28  
 import org.apache.maven.archiva.model.DependencyScope;
 29  
 
 30  
 import java.util.Stack;
 31  
 
 32  
 /**
 33  
  * UpdateScopesVisitor 
 34  
  *
 35  
  * @version $Id: UpdateScopesVisitor.java 755277 2009-03-17 15:18:35Z brett $
 36  
  */
 37  
 public class UpdateScopesVisitor
 38  
     extends BaseVisitor
 39  
     implements DependencyGraphVisitor
 40  
 {
 41  
     private Stack<String> scopeStack;
 42  
 
 43  
     private Predicate rootEdgePredicate;
 44  
 
 45  
     public UpdateScopesVisitor()
 46  0
     {
 47  0
         scopeStack = new Stack<String>();
 48  
         // Default setting.
 49  0
         scopeStack.add( DependencyScope.COMPILE );
 50  0
     }
 51  
 
 52  
     public void discoverGraph( DependencyGraph graph )
 53  
     {
 54  0
         super.discoverGraph( graph );
 55  0
         rootEdgePredicate = new EdgeFromPredicate( graph.getRootNode() );
 56  0
     }
 57  
 
 58  
     public void discoverEdge( DependencyGraphEdge edge )
 59  
     {
 60  0
         super.discoverEdge( edge );
 61  
         
 62  0
         String scope = edge.getScope();
 63  
 
 64  0
         if ( !rootEdgePredicate.evaluate( edge ) )
 65  
         {
 66  
             // Not a root edge.  Set the scope.
 67  0
             scope = (String) scopeStack.peek();
 68  0
             edge.setScope( scope );
 69  
         }
 70  
         
 71  
         // Push the scope used onto the stack.
 72  0
         scopeStack.push( scope );
 73  0
     }
 74  
 
 75  
     public void finishEdge( DependencyGraphEdge edge )
 76  
     {
 77  0
         super.finishEdge( edge );
 78  
 
 79  0
         scopeStack.pop();
 80  0
     }
 81  
 }