Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 103   Methods: 9
NCLOC: 83   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
DuoOutputStream.java 0% 0% 0% 0%
coverage
 1   
 package nmp.io;
 2   
 
 3   
 import java.io.*;
 4   
 import java.text.*;
 5   
 import java.util.*;
 6   
 
 7   
 public final class DuoOutputStream
 8   
     extends OutputStream
 9   
 {
 10   
     protected static final SimpleDateFormat dateFormat;
 11   
 
 12   
     static
 13   
     {
 14  0
         dateFormat = new SimpleDateFormat("dd-MMM-yyyy---HH_mm_ss");
 15  0
         TimeZone tz = TimeZone.getTimeZone("GMT");
 16  0
         dateFormat.setTimeZone(tz);
 17   
     }
 18   
 
 19   
     private OutputStream out1, out2;
 20   
     private String logFilename = "unknown";
 21   
 
 22   
     /**
 23   
      * Transform the given string into a valid filename
 24   
      */
 25  0
     private String validFilename( String name) {
 26  0
         StringBuffer buf = new StringBuffer();
 27  0
         for( int i = 0; i < name.length(); i++) {
 28  0
             char ch = name.charAt(i);
 29  0
             if( Character.isLetterOrDigit( ch))
 30  0
                 buf.append( ch);
 31   
             else
 32  0
                 switch( ch) {
 33   
                 case '\\':
 34  0
                     buf.append( ch);
 35  0
                     break;
 36   
                 case '-':
 37  0
                     buf.append( ch);
 38  0
                     break;
 39   
                 default:
 40  0
                     buf.append('_');
 41  0
                     break;
 42   
                 }
 43   
         }
 44  0
         return buf.toString();
 45   
     }
 46   
 
 47   
     /**
 48   
      * Base bane us 
 49   
      */
 50  0
     public DuoOutputStream( String baseName0, OutputStream out1) throws IOException {
 51  0
         String baseName = validFilename( baseName0);
 52  0
         this.out1 = out1;
 53  0
         this.out2 = new FileOutputStream( logFilename = baseName + "-debug-" + dateFormat.format( new java.util.Date()) + ".log");
 54   
     }
 55   
     
 56  0
     public DuoOutputStream( OutputStream out1) throws IOException {
 57  0
         this.out1 = out1;
 58  0
         this.out2 = new FileOutputStream( logFilename = "debug-" + dateFormat.format( new java.util.Date()) + ".log");
 59   
     }
 60   
     
 61  0
     public DuoOutputStream( File basedir, String baseName0, OutputStream out1) throws IOException {
 62  0
         String baseName = validFilename( baseName0);
 63  0
         this.out1 = out1;
 64  0
         this.out2 = new FileOutputStream( new File( basedir, logFilename = baseName + "-debug-" + dateFormat.format( new java.util.Date()) + ".log"));
 65   
     }
 66   
     
 67  0
     public DuoOutputStream( File basedir, OutputStream out1) throws IOException {
 68  0
         this.out1 = out1;
 69  0
         this.out2 = new FileOutputStream( new File( basedir, logFilename = "debug-" + dateFormat.format( new java.util.Date()) + ".log"));
 70   
     }
 71   
     
 72  0
     public DuoOutputStream( OutputStream out1, OutputStream out2) {
 73  0
         this.out1 = out1;
 74  0
         this.out2 = out2;
 75   
     }
 76   
     
 77  0
     public void write( int b ) throws IOException {
 78  0
         if( out1 != null) {
 79  0
             out1.write( b);
 80  0
             out1.flush();
 81   
         }
 82  0
         if( out2 != null) {
 83  0
             out2.write( b);
 84  0
             out2.flush();
 85   
         }
 86   
     }
 87   
 
 88  0
     public void write( byte b[], int off, int len ) throws IOException {
 89  0
         if( out1 != null) {
 90  0
             out1.write( b, off, len);
 91  0
             out1.flush();
 92   
         }
 93  0
         if( out2 != null) {
 94  0
             out2.write( b, off, len);
 95  0
             out2.flush();
 96   
         }
 97   
     }
 98   
     
 99  0
     public String logFilename() {
 100  0
         return logFilename;
 101   
     }
 102   
 }
 103