1 2 24 package org.enhydra.tool.common; 25 26 import java.io.File ; 28 import javax.swing.filechooser.FileFilter ; 29 30 34 public class FilenameFilter extends FileFilter 35 implements java.io.FileFilter { 36 private String includeName = new String (); 37 private String descTitle = new String (); 38 private boolean directoryValid = true; 39 private boolean excludeOnly = false; 40 41 44 public FilenameFilter() {} 45 46 49 public boolean accept(File f) { 50 boolean acceptFile = false; 51 PathHandle handle = null; 52 53 if (f == null) { 54 acceptFile = true; 55 } else if (f.isDirectory()) { 56 acceptFile = isDirectoryValid(); 57 } else { 58 handle = PathHandle.createPathHandle(f); 59 acceptFile = handle.endsWith(File.separator + includeName); 60 } 61 return acceptFile; 62 } 63 64 67 public String getDescription() { 68 StringBuffer desc = new StringBuffer (); 69 70 desc.append(getDescriptionTitle()); 71 desc.append(' '); 72 desc.append('('); 73 desc.append(includeName); 74 desc.append(')'); 75 return desc.toString(); 76 } 77 78 82 public void setDescriptionTitle(String d) { 83 this.descTitle = d; 84 } 85 86 90 public String getDescriptionTitle() { 91 return descTitle; 92 } 93 94 public void setDirectoryValid(boolean valid) { 95 directoryValid = valid; 96 } 97 98 public boolean isDirectoryValid() { 99 return directoryValid; 100 } 101 102 public void setIncludeName(String n) { 103 includeName = n; 104 } 105 106 public String getIncludeName() { 107 return includeName; 108 } 109 110 111 112 } 113 | Popular Tags |