1 26 27 package net.sourceforge.groboutils.codecoverage.v2.logger; 28 29 import java.io.File ; 30 import java.io.IOException ; 31 32 import net.sourceforge.groboutils.codecoverage.v2.IChannelLogReader; 33 import net.sourceforge.groboutils.codecoverage.v2.IClassChannelLogReader; 34 35 42 public class DirectoryChannelLogReader implements IChannelLogReader 43 { 44 private static final org.apache.log4j.Logger LOG = 45 org.apache.log4j.Logger.getLogger( DirectoryChannelLogReader.class ); 46 private static final String EXTENTION = 47 DirectoryChannelLogger.CLASS_LOG_EXTENTION; 48 49 private File channelDir; 50 51 52 public DirectoryChannelLogReader( File baseDir, short channel ) 53 { 54 File newDir = new File ( baseDir, Short.toString( channel ) ); 55 if (!newDir.exists() || !newDir.isDirectory()) 56 { 57 throw new IllegalArgumentException ( "File "+newDir+ 58 " is not a directory or doesn't exist." ); 59 } 60 this.channelDir = newDir; 61 } 62 63 64 72 public IClassChannelLogReader getReaderForClassSignature( String signature ) 73 throws IOException 74 { 75 File logFile = new File ( this.channelDir, signature+EXTENTION ); 76 if (!logFile.exists()) 77 { 78 LOG.info( "Couldn't finding a log file for class "+signature+ 81 " in file "+logFile+"." ); 82 return new EmptyClassChannelLogReader(); 83 } 84 85 LOG.debug( "Loading class log reader from file "+logFile+"." ); 86 return new DirectoryClassChannelLogReader( logFile, signature ); 87 } 88 } 89 90 | Popular Tags |