org.josql.filters
Class StackTraceElementFilter

java.lang.Object
  extended by org.josql.filters.AbstractJoSQLFilter
      extended by org.josql.filters.StackTraceElementFilter

public class StackTraceElementFilter
extends AbstractJoSQLFilter

This class allows you to filter the stack trace of a Throwable, so cutting down on the (sometimes) pointless long stack traces.

Usage:

    SELECT *
    FROM   java.lang.StackTraceElement
    WHERE  className LIKE 'org.josql.%'
 
And then to use in code:
    StackTraceElementFilter f = new StackTraceElementFilter (sql);
    f.filter (new Throwable ());
 


Field Summary
 
Fields inherited from class org.josql.filters.AbstractJoSQLFilter
badQuery, exp, q
 
Constructor Summary
StackTraceElementFilter(Query q)
          Init this file filter with the query already built and parsed.
StackTraceElementFilter(String q)
          Init this filter with the query.
 
Method Summary
 boolean accept(Object o)
           
 boolean accept(StackTraceElement s)
          Returns true if the where clause evaluates to true for the passed in StackTraceElement.
 void filter(Throwable t)
          Filter the throwable, but will also filter any causes (right up the cause chain) as well.
 void filter(Throwable t, boolean filterCause)
          Filter the throwable, but will also filter any causes (right up the cause chain) as well if the filterCause boolean is set to true.
 StackTraceElement[] filterStackTrace(StackTraceElement[] s)
          Filter the specified stack trace and return the new stack trace that can then be set in the throwable.
 Class getExpectedClass()
          Get the expected class.
 
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

StackTraceElementFilter

public StackTraceElementFilter(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 equal to the expected class.

StackTraceElementFilter

public StackTraceElementFilter(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 as expected.
Method Detail

getExpectedClass

public Class getExpectedClass()
Get the expected class.

Specified by:
getExpectedClass in class AbstractJoSQLFilter
Returns:
StackTraceElement.

accept

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

accept

public boolean accept(StackTraceElement s)
               throws QueryExecutionException
Returns true if the where clause evaluates to true for the passed in StackTraceElement.

Parameters:
s - The object to evaluate the WHERE clause against.
Returns:
true if the WHERE clause evaluates to true for the specified object.
Throws:
QueryExecutionException

filterStackTrace

public StackTraceElement[] filterStackTrace(StackTraceElement[] s)
                                     throws QueryExecutionException
Filter the specified stack trace and return the new stack trace that can then be set in the throwable.

Parameters:
s - The stack trace.
Returns:
The new stack trace, filtered.
Throws:
QueryExecutionException - If the where clause cannot be executed against a particular element.

filter

public void filter(Throwable t)
            throws QueryExecutionException
Filter the throwable, but will also filter any causes (right up the cause chain) as well. Equivalent to calling: filter(Throwable,boolean) with the boolean set to true.

Parameters:
t - The throwable instance to filter.
Throws:
QueryExecutionException - If the where clause cannot be executed.

filter

public void filter(Throwable t,
                   boolean filterCause)
            throws QueryExecutionException
Filter the throwable, but will also filter any causes (right up the cause chain) as well if the filterCause boolean is set to true.

Parameters:
t - The throwable instance to filter.
filterCause - When set to true will also filter the cause chain as well.
Throws:
QueryExecutionException - If the where clause cannot be executed.


  Copyright © 2008 Gary Bentley. All Rights Reserved.