1 2 24 package org.enhydra.tool.archive; 25 26 import org.enhydra.tool.common.PathHandle; 28 29 import java.io.File ; 31 import java.io.FileFilter ; 32 33 public class ClassFilter implements FileFilter { 35 protected static final String TEMP_NFS = ".nfs"; 38 private final String MANIFEST = "MANIFEST.MF"; 41 private final String GEN_SOURCE = "Generated Source"; private final String DEP_CACHE = "dependency cache"; 45 private final String TYPE_JAVA = ".java"; private final String TYPE_JSP = ".jsp"; 49 private PathHandle root = null; 51 52 53 public ClassFilter() {} 55 56 ; 57 public ClassFilter(String r) { 58 setRoot(r); 59 } 60 61 public void setRoot(String r) { 62 root = PathHandle.createPathHandle(r); 63 } 64 65 public String getRoot() { 66 return root.getPath(); 67 } 68 69 public boolean accept(File file) { 70 boolean include = false; 71 PathHandle filePath = null; 72 73 filePath = PathHandle.createPathHandle(file); 74 if (root.parentOf(filePath)) { 75 if (filePath.isDirectory()) { 76 include = true; 77 } else { 78 String relative = null; 79 80 relative = 81 file.getAbsolutePath().substring(root.getPath().length() 82 + 1); 83 if (relative.startsWith(GEN_SOURCE)) { 84 85 } else if (relative.startsWith(DEP_CACHE)) { 87 88 } else if (relative.toUpperCase().endsWith(MANIFEST)) { 90 91 } else if (relative.toLowerCase().endsWith(TYPE_JAVA)) { 93 94 } else if (relative.toLowerCase().endsWith(TYPE_JSP)) { 96 97 } else if (file.getName().toLowerCase().startsWith(ClassFilter.TEMP_NFS)) { 99 100 } else { 102 include = true; 103 } 104 } 105 } 106 return include; 107 } 108 109 } 110 | Popular Tags |