1 package net.sourceforge.pmd; 2 3 import java.io.File ; 4 5 10 public class SourceFileSelector { 11 12 private boolean selectJavaFiles = true; 13 14 private boolean selectJspFiles = false; 16 17 23 public boolean isWantedFile(String fileName) { 24 int lastDotIndex = fileName.lastIndexOf('.'); 25 if (lastDotIndex < 0) { 26 return false; 27 } 28 29 String extensionUppercase = fileName.substring(1 + lastDotIndex) 30 .toUpperCase(); 31 32 if (selectJavaFiles 33 && extensionUppercase 34 .equals(SourceFileConstants.JAVA_EXTENSION_UPPERCASE)) { 35 return true; 36 } 37 38 if (selectJspFiles 39 && (extensionUppercase 40 .equals(SourceFileConstants.JSP_EXTENSION_UPPERCASE) || extensionUppercase 41 .equals(SourceFileConstants.JSPX_EXTENSION_UPPERCASE))) { 42 return true; 43 } 44 45 return false; 46 } 47 48 54 public boolean isWantedFile(File file) { 55 return isWantedFile(file.getAbsolutePath()); 56 } 57 58 61 public boolean isSelectJavaFiles() { 62 return selectJavaFiles; 63 } 64 65 68 public void setSelectJavaFiles(boolean selectJavaFiles) { 69 this.selectJavaFiles = selectJavaFiles; 70 } 71 72 75 public boolean isSelectJspFiles() { 76 return selectJspFiles; 77 } 78 79 82 public void setSelectJspFiles(boolean selectJspFiles) { 83 this.selectJspFiles = selectJspFiles; 84 } 85 } 86 | Popular Tags |