1 26 27 package net.sourceforge.groboutils.codecoverage.v2.logger; 28 29 import java.util.ArrayList ; 30 import java.util.HashMap ; 31 import java.util.Iterator ; 32 import java.util.List ; 33 34 import net.sourceforge.groboutils.codecoverage.v2.compiler.ParseCoverageLogger; 35 36 37 44 public class TestLogger 45 { 46 public static class MarkData 47 { 48 public String classSig; 49 public short measureIndex; 50 public short methodIndex; 51 public short markIndex; 52 53 public MarkData( String sig, short meaI, short metI, short marI ) 54 { 55 this.classSig = sig; 56 this.measureIndex = meaI; 57 this.methodIndex = metI; 58 this.markIndex = marI; 59 } 60 61 public String toString() 62 { 63 return "[Class Sig="+this.classSig+";measure="+ 64 this.measureIndex+";method="+this.methodIndex+ 65 ";mark="+this.markIndex+"]"; 66 } 67 } 68 69 private static HashMap marksPerThread = new HashMap (); 70 71 public static ParseCoverageLogger createPCL() 72 { 73 return new ParseCoverageLogger( TestLogger.class, "cover" ); 74 } 75 76 77 public static void cover( String classSig, 78 short methodIndex, short channel, short markIndex ) 79 { 80 List list = getThreadList(); 82 MarkData md = new MarkData( classSig, channel, methodIndex, 83 markIndex ); 84 synchronized( list ) 85 { 86 list.add( md ); 88 } 89 } 90 91 92 public static void reset() 93 { 94 List list = getThreadList(); 95 synchronized( list ) 96 { 97 list.clear(); 98 } 99 } 100 101 102 public static int size() 103 { 104 return getThreadList().size(); 105 } 106 107 108 public static Iterator getMarkData() 109 { 110 return getThreadList().iterator(); 111 } 112 113 114 private static List getThreadList() 115 { 116 List list; 117 synchronized( TestLogger.class ) 118 { 119 list = (List )marksPerThread.get( Thread.currentThread() ); 120 if (list == null) 121 { 122 list = new ArrayList (); 123 marksPerThread.put( Thread.currentThread(), list ); 124 } 125 } 126 return list; 127 } 128 } 129 130 | Popular Tags |