1 26 27 package net.sourceforge.groboutils.codecoverage.v2.logger; 28 29 import java.io.File ; 30 import java.io.FileWriter ; 31 import java.io.IOException ; 32 import java.util.HashSet ; 33 import java.util.Set ; 34 35 36 45 public class MinDirChannelLogger extends DirectoryChannelLogger 46 { 47 private final Set covered = new HashSet ( 10000, 0.75f ); 48 49 50 public MinDirChannelLogger( File baseDir ) 51 { 52 super( baseDir ); 53 } 54 55 56 68 public void cover( String classSignature, short methodIndex, 69 short markIndex ) 70 { 71 if (this.baseDir != null) 72 { 73 char[] out = createCoverString( methodIndex, markIndex ); 74 75 int csl = classSignature.length(); 78 char cs[] = new char[ csl + 3 ]; 79 classSignature.getChars( 0, csl, cs, 0 ); 80 cs[csl] = '-'; 81 cs[csl+1] = (char)methodIndex; 82 cs[csl+2] = (char)markIndex; 83 String key = new String ( cs ); 84 85 synchronized (this) 86 { 87 if (!covered.contains( key )) 89 { 90 covered.add( key ); 91 92 File f = getClassFile( this.baseDir, classSignature ); 93 FileWriter fw = null; 94 try 95 { 96 fw = new FileWriter ( f.toString(), true ); 97 try 98 { 99 fw.write( out ); 100 fw.flush(); 101 } 102 finally 103 { 104 fw.close(); 105 } 106 } 107 catch (IOException ioe) 108 { 109 ioe.printStackTrace(); 111 112 this.baseDir = null; 114 } 115 } 116 } 117 } 118 } 119 } 120 121 | Popular Tags |