Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 100   Methods: 3
NCLOC: 82   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
AddCopyright.java 0% 0% 0% 0%
coverage
 1   
 // ===========================================================================
 2   
 // Copyright (c) 2002 DAgora Team. All rights reserved.
 3   
 // ---------------------------------------------------------------------------
 4   
 package nmp.util;
 5   
 
 6   
 import java.io.*;
 7   
 
 8   
 public class AddCopyright
 9   
 {
 10   
     private static String []newCopyright = {
 11   
         "// ===========================================================================",
 12   
         "// Copyright (c) 2002 DAgora Team. All rights reserved.",
 13   
         "// ---------------------------------------------------------------------------"
 14   
         };
 15   
 
 16   
     private static String []oldCopyright = {
 17   
         "// ===========================================================================",
 18   
         "// Copyright (c) 2002 DAgora Team. All rights reserved.",
 19   
         "// ---------------------------------------------------------------------------"
 20   
         };
 21   
     
 22  0
     private static void processOne( BufferedReader reader, PrintWriter writer) throws IOException {
 23  0
         for( int i = 0; i < newCopyright.length; i++)
 24  0
             writer.println( newCopyright[i]);
 25   
         
 26  0
         String line = null;
 27   
         
 28   
         // process old copyright
 29  0
         String []l = new String[oldCopyright.length];
 30  0
         int pos = 0;
 31  0
         boolean isoldcopyright = true;
 32  0
         boolean endoffile = false;
 33  0
         for( ; isoldcopyright && pos < oldCopyright.length; pos++) {
 34  0
             l[pos] = reader.readLine();
 35  0
             if( l[pos] == null) {
 36  0
                 isoldcopyright = false;
 37  0
                 endoffile = true;
 38  0
                 break;
 39   
             }
 40  0
             if( ! l[pos].equals( oldCopyright[pos])) {
 41  0
                 isoldcopyright = false;
 42   
             }
 43   
         }
 44  0
         if( ! isoldcopyright)
 45  0
             for( int i = 0; i < pos; i++)
 46  0
                 writer.println( l[i]);
 47  0
         if( ! endoffile)
 48  0
             for( ; ; ) {
 49  0
                 String str = reader.readLine();
 50  0
                 if( str == null)
 51  0
                     break;
 52  0
                 writer.println( str);
 53   
             }
 54   
     }
 55   
     
 56  0
     private static void addOne( String filename) throws IOException {
 57  0
         String auxfilename = filename + "._old";
 58  0
         File f = new File( filename);
 59  0
         File faux = new File( auxfilename);
 60  0
         BufferedReader reader = new BufferedReader( new FileReader( f));
 61  0
         PrintWriter writer = new PrintWriter( new FileWriter( faux));
 62   
         
 63  0
         processOne( reader, writer);
 64   
         
 65  0
         writer.flush();
 66  0
         writer.close();
 67  0
         reader.close();
 68   
         
 69  0
         if( f.delete() == false)
 70  0
             throw new IOException( "Could not delete :" + f.getPath());
 71  0
         if( faux.renameTo( f) == false) 
 72  0
             throw new IOException( "Could not rename :" + faux.getPath());
 73   
     }
 74   
     
 75   
     
 76  0
     public static void main(String[] args)
 77   
     {
 78  0
         try {
 79  0
         if( args.length != 1) {
 80  0
             System.out.println( "Usages:\nnmp.util.AddCopyright [filename|@filename]");
 81  0
             System.exit( 0);
 82   
         }
 83  0
         if( args[0].startsWith("@")) {
 84  0
             BufferedReader reader = new BufferedReader( new FileReader( args[0].substring(1)));
 85  0
             for( ; ;) {
 86  0
                 String line = reader.readLine();
 87  0
                 if( line == null)
 88  0
                     break;
 89  0
                 addOne( line);
 90   
             }
 91  0
             reader.close();
 92   
         } else
 93  0
             addOne( args[0]);
 94   
         } catch( Throwable th) {
 95  0
             th.printStackTrace();
 96   
         }
 97   
                                    
 98   
     }
 99   
 }
 100