1 22 23 package org.gjt.sp.jedit.io; 24 25 import java.util.regex.Pattern ; 26 import org.gjt.sp.jedit.jEdit; 27 import org.gjt.sp.util.StandardUtilities; 28 29 37 public class GlobVFSFileFilter implements VFSFileFilter 38 { 39 40 public GlobVFSFileFilter(String glob) 41 { 42 this.glob = glob; 43 } 44 45 public boolean accept(VFSFile file) 46 { 47 if (file.getType() == VFSFile.DIRECTORY 48 || file.getType() == VFSFile.FILESYSTEM) 49 { 50 return true; 51 } 52 else 53 { 54 return accept(file.getName()); 55 } 56 } 57 58 public boolean accept(String url) 59 { 60 if (pattern == null) 61 { 62 pattern = Pattern.compile(StandardUtilities.globToRE(glob), 63 Pattern.CASE_INSENSITIVE); 64 } 65 return pattern.matcher(url).matches(); 66 } 67 68 public String getDescription() 69 { 70 return jEdit.getProperty("vfs.browser.file_filter.glob"); 71 } 72 73 public String toString() 74 { 75 return glob; 76 } 77 78 public void setGlob(String glob) 79 { 80 this.glob = glob; 81 pattern = null; 82 } 83 84 public String getGlob() 85 { 86 return glob; 87 } 88 89 private String glob; 90 private Pattern pattern; 91 92 } 93 94 | Popular Tags |