1 15 package org.josql.filters; 16 17 import java.util.logging.Filter ; 18 import java.util.logging.LogRecord ; 19 20 import org.josql.Query; 21 import org.josql.QueryParseException; 22 23 56 public class JoSQLLogRecordFilter extends AbstractJoSQLFilter implements Filter 57 { 58 59 protected Class expected = LogRecord .class; 60 61 68 public JoSQLLogRecordFilter (String q) 69 throws QueryParseException 70 { 71 72 super (q); 73 74 } 75 76 83 public JoSQLLogRecordFilter (Query q) 84 throws IllegalStateException , 85 QueryParseException 86 { 87 88 super (q); 89 90 } 91 92 public boolean accept (Object o) 93 { 94 95 if (!(o instanceof LogRecord )) 96 { 97 98 throw new IllegalArgumentException ("Expected object to be of type: " + 99 LogRecord .class.getName () + 100 ", got: " + 101 o.getClass ().getName ()); 102 103 } 104 105 return this.accept ((LogRecord ) o); 106 107 } 108 109 119 public boolean isLoggable (LogRecord l) 120 { 121 122 if (this.badQuery) 123 { 124 125 return false; 126 127 } 128 129 try 130 { 131 132 return this.q.getWhereClause ().isTrue (l, 133 this.q); 134 135 } catch (Exception e) { 136 137 this.badQuery = true; 138 139 this.exp = e; 140 141 } 142 143 return false; 144 145 } 146 147 152 public Class getExpectedClass () 153 { 154 155 return LogRecord .class; 156 157 } 158 159 } 160 | Popular Tags |