org.josql.filters
Class JoSQLLogRecordFilter

java.lang.Object
  extended by org.josql.filters.AbstractJoSQLFilter
      extended by org.josql.filters.JoSQLLogRecordFilter
All Implemented Interfaces:
Filter

public class JoSQLLogRecordFilter
extends AbstractJoSQLFilter
implements Filter

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

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

Examples:

   SELECT *
   FROM   java.tuil.logging.LogRecord
   WHERE  name $LIKE '%.html'
   AND    millis > toDateMillis('12-04-2004')
   AND    sequenceNumber BETWEEN (10000 AND 20000)
   AND    message $LIKE '%internal%'
   AND    loggerName = 'internal_logger'
   AND    level.name IN ('SEVERE', 'WARNING')
 

If you are using a custom log record then you can always just extend this class and override the getExpectedClass() method to return your specific sub-class.


Field Summary
protected  Class expected
           
 
Fields inherited from class org.josql.filters.AbstractJoSQLFilter
badQuery, exp, q
 
Constructor Summary
JoSQLLogRecordFilter(Query q)
          Init this filter with the query already built and parsed.
JoSQLLogRecordFilter(String q)
          Init this filter with the query.
 
Method Summary
 boolean accept(Object o)
           
 Class getExpectedClass()
          Always returns LogRecord.
 boolean isLoggable(LogRecord l)
          Apply the WHERE clause of the statement to the LogRecord passed in.
 
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
 

Field Detail

expected

protected Class expected
Constructor Detail

JoSQLLogRecordFilter

public JoSQLLogRecordFilter(String q)
                     throws QueryParseException
Init this 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 LogRecord.

JoSQLLogRecordFilter

public JoSQLLogRecordFilter(Query q)
                     throws IllegalStateException,
                            QueryParseException
Init this 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 LogRecord.
Method Detail

accept

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

isLoggable

public boolean isLoggable(LogRecord l)
Apply the WHERE clause of the statement to the LogRecord 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 LogRecord objects). You can get access to exception by using: AbstractJoSQLFilter.getException().

Specified by:
isLoggable in interface Filter
Parameters:
l - The log record to evaluate the WHERE on.
Returns:
true if the WHERE clause evaluates to true.

getExpectedClass

public Class getExpectedClass()
Always returns LogRecord.

Specified by:
getExpectedClass in class AbstractJoSQLFilter
Returns:
The log record class.


  Copyright © 2008 Gary Bentley. All Rights Reserved.