1 15 package org.josql.filters; 16 17 import java.io.FileFilter ; 18 import java.io.File ; 19 20 import org.josql.Query; 21 import org.josql.QueryParseException; 22 23 50 public class JoSQLFileFilter extends AbstractJoSQLFilter implements FileFilter 51 { 52 53 60 public JoSQLFileFilter (String q) 61 throws QueryParseException 62 { 63 64 super (q); 65 66 } 67 68 75 public JoSQLFileFilter (Query q) 76 throws IllegalStateException , 77 QueryParseException 78 { 79 80 super (q); 81 82 } 83 84 public boolean accept (Object o) 85 { 86 87 if (!(o instanceof File )) 88 { 89 90 throw new IllegalArgumentException ("Expected object to be of type: " + 91 File .class.getName () + 92 ", got: " + 93 o.getClass ().getName ()); 94 95 } 96 97 return this.accept ((File ) o); 98 99 } 100 101 111 public boolean accept (File f) 112 { 113 114 if (this.badQuery) 115 { 116 117 return false; 118 119 } 120 121 try 122 { 123 124 return this.q.getWhereClause ().isTrue (f, 125 this.q); 126 127 } catch (Exception e) { 128 129 this.badQuery = true; 130 131 this.exp = e; 132 133 } 134 135 return false; 136 137 } 138 139 144 public Class getExpectedClass () 145 { 146 147 return File .class; 148 149 } 150 151 } 152 | Popular Tags |