Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 78   Methods: 3
NCLOC: 66   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
DumpTree.java 0% 0% 0% 0%
coverage
 1   
 package nmp.file_utils;
 2   
 
 3   
 import java.io.*;
 4   
 import java.util.*;
 5   
 
 6   
 public class DumpTree
 7   
 {
 8  0
     public static void main(String[] args) {
 9  0
         doit( args, System.out, System.err);
 10   
     }
 11  0
     public static int doit(String[] args, PrintStream ps, PrintStream es) {
 12  0
         if( args.length < 2) {
 13  0
             es.println( "Use: DumpTree filter ( +dir | -dir)*\n+dir - directory to include\n-dir - directory not to include\n--dir - exclude all directories with this name");
 14  0
             return -1;
 15   
         }
 16  0
         String basedir = System.getProperty( "user.dir");
 17  0
         FilenameFilter filter = new SimpleFilenameFilter( args[0]);
 18  0
         Vector excludepath = new Vector();
 19  0
         Vector excludedirname = new Vector();
 20  0
         for( int i = 1; i < args.length; i++) {
 21  0
             if( args[i].startsWith( "--")) {
 22  0
                 es.println( "Excluding name: " + args[i].substring( 2));
 23  0
                 excludedirname.addElement( args[i].substring( 2));
 24  0
             } else if( args[i].startsWith( "-")) {
 25  0
                 es.println( "Excluding path: " + args[i].substring( 1));
 26  0
                 excludepath.addElement( args[i].substring( 1));
 27   
             }
 28   
         }
 29  0
         for( int i = 1; i < args.length; i++) {
 30  0
             if( args[i].startsWith( "-"))
 31  0
                 continue;
 32  0
             File f = null;
 33  0
             if( args[i].startsWith( "+"))
 34  0
                 f = new File( args[i].substring( 1));
 35   
             else
 36  0
                 f = new File( args[i]);
 37  0
             dumpDir( ps, filter, f.getParentFile(), f, true, excludepath, excludedirname);
 38   
         }
 39  0
         return 0;
 40   
     }
 41   
     
 42   
     /**
 43   
      * Dumps the contents of the given directory according to the given filter
 44   
      * @param filter Files to be displayed
 45   
      * @param dir File containing the directory to be dumped
 46   
      * @param recursively True if it should dump files recursively
 47   
      * @param excludepath Vector with paths to exclude (subdirectories are also excluded)
 48   
      * @param excludedir Vector with directory names to exclude, independently of the path (subdirectories are also excluded)
 49   
      */
 50  0
     private static void dumpDir( PrintStream ps, FilenameFilter filter, File parent, File file, boolean recursively, Vector excludepath, Vector excludedirname) {
 51  0
         if( ! file.exists())
 52  0
             return;
 53  0
         if( parent != null) {
 54  0
             Enumeration enum = excludepath.elements();
 55  0
             while( enum.hasMoreElements()) {
 56  0
                 String prefix = (String)enum.nextElement();
 57  0
                 if( parent.getPath().startsWith( prefix))
 58  0
                     return;
 59   
             }
 60  0
             enum = excludedirname.elements();
 61  0
             while( enum.hasMoreElements()) {
 62  0
                 String prefix = (String)enum.nextElement();
 63  0
                 if( parent.getName().equalsIgnoreCase( prefix))
 64  0
                     return;
 65   
             }
 66   
         }
 67  0
         if( file.isDirectory() && recursively) {
 68  0
             File[] files = file.listFiles();
 69  0
             if( files != null)
 70  0
                 for( int i = 0; i < files.length; i++)
 71  0
                     dumpDir( ps, filter, file, files[i], recursively, excludepath, excludedirname);
 72  0
             return;
 73   
         }
 74  0
         if( filter.accept( parent, file.getName()))
 75  0
             ps.println( file.getPath());
 76   
     }
 77   
 }
 78