1 26 27 package net.sourceforge.groboutils.codecoverage.v2.module; 28 29 30 import java.util.HashSet ; 31 import java.util.Set ; 32 33 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisMetaData; 34 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule; 35 import net.sourceforge.groboutils.codecoverage.v2.IMethodCode; 36 37 46 public abstract class AbstractMeasure implements IAnalysisModule 47 { 48 private Set beenCovered = new HashSet (); 49 50 protected void markInstruction( IMethodCode method, int instrPos, 51 IAnalysisMetaData data, boolean allowDuplicates ) 52 { 53 boolean addMark = true; 54 if (!allowDuplicates) 55 { 56 String id = getPositionID( method, instrPos ); 57 if (this.beenCovered.contains( id )) 58 { 59 addMark = false; 60 } 61 else 62 { 63 this.beenCovered.add( id ); 64 } 65 } 66 67 if (addMark) 68 { 69 method.markInstruction( instrPos, data ); 70 } 71 } 72 73 74 private String getPositionID( IMethodCode m, int instrPos ) 75 { 76 StringBuffer sb = new StringBuffer ( m.getClassName() ); 77 sb.append( '#' ).append( m.getMethodName() ); 78 sb.append( '#' ).append( instrPos ); 79 80 return new String ( sb ); 82 } 83 } 84 85 | Popular Tags |