Coverage Report - org.apache.torque.util.SimpleScanner
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleScanner
0%
0/19
0%
0/8
2.333
 
 1  
 package org.apache.torque.util;
 2  
 
 3  
 import java.io.File;
 4  
 import java.util.ArrayList;
 5  
 import java.util.List;
 6  
 
 7  
 import org.codehaus.plexus.util.DirectoryScanner;
 8  
 
 9  
 /**
 10  
  * This class provides a simple method for scanning a directory for files that match include/exclude patterns
 11  
  */
 12  
 public class SimpleScanner extends DirectoryScanner {
 13  0
         private static final String FS = System.getProperty("file.separator");
 14  
 
 15  
         public SimpleScanner() {
 16  0
                 this(null, null, null);
 17  0
         }
 18  
 
 19  
         public SimpleScanner(File baseDir, String include, String exclude) {
 20  0
                 super();
 21  0
                 if (baseDir != null) {
 22  0
                         setBasedir(baseDir);
 23  
                 }
 24  0
                 if (include != null) {
 25  0
                         setIncludes(new String[] { include });
 26  
                 }
 27  0
                 if (exclude != null) {
 28  0
                         setExcludes(new String[] { exclude });
 29  
                 }
 30  0
         }
 31  
 
 32  
         /**
 33  
          * This method returns files that match an include pattern but do not match an exclude pattern
 34  
          */
 35  
         public List<File> getFiles() {
 36  0
                 scan();
 37  0
                 String[] includedFiles = getIncludedFiles();
 38  0
                 List<File> files = new ArrayList<File>();
 39  0
                 for (String includedFile : includedFiles) {
 40  0
                         String filename = getBasedir().getAbsolutePath() + FS + includedFile;
 41  0
                         File file = new File(filename);
 42  0
                         files.add(file);
 43  
                 }
 44  0
                 return files;
 45  
         }
 46  
 }