1 package org.columba.core.base; 17 18 import java.io.File ; 19 20 import javax.swing.filechooser.FileFilter ; 21 22 public class cFileFilter extends FileFilter { 23 public static final int FILEPROPERTY_FILE = 0x0001; 24 25 public static final int FILEPROPERTY_DIRECTORY = 0x0002; 26 27 public static final int FILEPROPERTY_HIDDEN = 0x0004; 28 29 private int property; 30 31 public cFileFilter() { 32 this.property = 0x0000; } 34 35 38 @Override 39 public boolean accept(File f) { 40 boolean result = true; 41 42 if (f == null) { 43 return false; 44 } 45 46 if (!f.exists()) { 47 return true; } 49 50 if ((this.property & FILEPROPERTY_FILE) > 0) { 51 result = result && f.isFile(); 52 } 53 54 if ((this.property & FILEPROPERTY_DIRECTORY) > 0) { 55 result = result && f.isDirectory(); 56 } 57 58 if ((this.property & FILEPROPERTY_HIDDEN) > 0) { 59 result = result && f.isHidden(); 60 } 61 62 return result; 63 } 64 65 public void acceptFilesWithProperty(int newprop) { 66 this.property = newprop; 67 } 68 69 72 @Override 73 public String getDescription() { 74 return new String ("Columba File Filter"); } 77 } 78 | Popular Tags |