Coverage Report - org.apache.maven.archiva.dependency.graph.tasks.GraphCopier
 
Classes in this File Line Coverage Branch Coverage Complexity
GraphCopier
0%
0/17
0%
0/2
1.167
 
 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.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  
  * GraphCopier 
 30  
  *
 31  
  * @version $Id: GraphCopier.java 718864 2008-11-19 06:33:35Z brett $
 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  
      * Be sure to override and NOT call this method in your sub class,
 59  
      * if you want to copy edges based on some kind of criteria.
 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  
 }