1 26 package org.hammurapi.inspectors.metrics; 27 28 import java.util.HashSet ; 29 import java.util.Iterator ; 30 import java.util.Set ; 31 import java.util.Vector ; 32 33 import com.pavelvlasov.jsel.TypeDefinition; 34 35 41 public class CouplingMetricOfPackage extends CouplingMetric { 42 43 public Set listAfferentPackage = new HashSet (); 44 public Set listEfferentPackage = new HashSet (); 45 46 protected String packageName = ""; 47 48 private Vector listOfCouplingMetricOfClass = new Vector (); 49 50 public CouplingMetricOfPackage( String _packageName){ 51 super(); 52 this.packageName = _packageName; 53 } 54 55 public void aggregate(CouplingMetric cCmc) { 56 57 this.afferentMethodCounterProjectInternal 58 += cCmc.afferentMethodCounterProjectInternal; 59 this.efferentMethodCounterProjectInternal 60 += cCmc.efferentMethodCounterProjectInternal; 61 62 this.afferentMethodCounter += cCmc.afferentMethodCounter; 63 this.efferentMethodCounter += cCmc.efferentMethodCounter; 64 this.efferentMethodUnresolvedCounter 65 += cCmc.efferentMethodUnresolvedCounter; 66 this.reflectiveMethodCounter += cCmc.reflectiveMethodCounter; 67 this.afferentVariableCounter += cCmc.afferentVariableCounter; 68 this.efferentVariableCounter += cCmc.efferentVariableCounter; 69 this.reflectiveVariableCounter += cCmc.reflectiveVariableCounter; 70 71 this.instability = this.getInstability(); 73 } 74 75 public String getRootPackageName( String fcn){ 76 return fcn; 78 } 79 public void aggregate(CouplingMetricOfClass cCmc) { 80 81 this.aggregate( (CouplingMetric)cCmc ); 82 83 for (Iterator it = cCmc.listAfferentTypes.iterator(); it.hasNext();){ 84 TypeDefinition t = (TypeDefinition)it.next(); 85 if( t.getFcn() != null ){ 86 listAfferentPackage.add(this.getRootPackageName( t.getFcn())); 87 } 88 } 89 90 for (Iterator it = cCmc.listEfferentTypes.iterator(); it.hasNext();){ 91 TypeDefinition t = (TypeDefinition)it.next(); 92 if( t.getFcn() != null ){ 93 listEfferentPackage.add( this.getRootPackageName( t.getFcn()) ); 94 } 95 } 96 97 listOfCouplingMetricOfClass.add(cCmc); 98 } 99 143 } 144 145 | Popular Tags |