org.josql.filters
Class JoSQLFileFilter

java.lang.Object
  extended by org.josql.filters.AbstractJoSQLFilter
      extended by org.josql.filters.JoSQLFileFilter
All Implemented Interfaces:
FileFilter

public class JoSQLFileFilter
extends AbstractJoSQLFilter
implements FileFilter

A FileFilter that uses a JoSQL statement to provide the filtering. The value returned by the accept(File) method is determined by executing the WHERE clause of a JoSQL statement on each File passed in.

Since this uses a sub-set of the JoSQL functionality certain restrictions apply:

Examples:

   SELECT *
   FROM   java.io.File
   WHERE  name $LIKE '%.html'
   AND    lastModified > toDateMillis('12-04-2004')
   AND    file
 


Field Summary
 
Fields inherited from class org.josql.filters.AbstractJoSQLFilter
badQuery, exp, q
 
Constructor Summary
JoSQLFileFilter(Query q)
          Init this file filter with the query already built and parsed.
JoSQLFileFilter(String q)
          Init this file filter with the query.
 
Method Summary
 boolean accept(File f)
          Apply the WHERE clause of the statement to the File passed in.
 boolean accept(Object o)
           
 Class getExpectedClass()
          Always returns File.
 
Methods inherited from class org.josql.filters.AbstractJoSQLFilter
clearException, getException, getQuery, setQuery, setQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoSQLFileFilter

public JoSQLFileFilter(String q)
                throws QueryParseException
Init this file filter with the query.

Parameters:
q - The query.
Throws:
QueryParseException - If there is an issue with the parsing of the query, or if the FROM class is not File.

JoSQLFileFilter

public JoSQLFileFilter(Query q)
                throws IllegalStateException,
                       QueryParseException
Init this file filter with the query already built and parsed.

Parameters:
q - The query.
Throws:
IllegalStateException - If the Query object has not been parsed.
QueryParseException - If the FROM class is not File.
Method Detail

accept

public boolean accept(Object o)
Specified by:
accept in class AbstractJoSQLFilter

accept

public boolean accept(File f)
Apply the WHERE clause of the statement to the File passed in. If an exception is thrown by the execution of the WHERE clause the Query is marked as "dirty" and the where clause is no longer executed on the passed in files (since it is likely that the WHERE clause will fail for all File objects). You can get access to exception by using: AbstractJoSQLFilter.getException().

Specified by:
accept in interface FileFilter
Parameters:
f - The file to evaluate the WHERE on.
Returns:
true if the WHERE clause evaluates to true.

getExpectedClass

public Class getExpectedClass()
Always returns File.

Specified by:
getExpectedClass in class AbstractJoSQLFilter
Returns:
The file class.


  Copyright © 2008 Gary Bentley. All Rights Reserved.